I need to run a job at everyday 4 PM.For this I have written a cron scheduler (standlone class) by referring quartz examples.
Now I'm planning to deploy in on websphere. So that the scheduler can be started when I deploy the application and can bcome a part of the project.
I'm not finding any doc (step-by-step) on setting up quartz in app server.
I have following doubts :
1. what all properties are required in properties file ?
2.Properties file always needed ? As none of the example on quartz website is using property file.
3. What all configuration files will be needed to achieve the above tasks and where to place them ?
Any doc or link will be highly appreciated.
Thanks in advance.
hp
On the quartz's website you'll find everything you need to configure it.
Basically:
you need the quartz.properties
you'll need, somehow, to start the scheduler. You can achieve that by simply adding the QuartzInitializerListener to your web.xml. You can also integrate quartz with spring:
<!-- quartz scheduler -->
<bean id="my-quartz-factory"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean" >
<property name="configLocation" value="classpath:spring/quartz.properties" />
</bean>
All those files must be placed in your war.
HIH
Related
I am using TFS 2012 on a build server to do continuous integration, and also builds for other environments. I am deploying a .net 4.0 webforms solution containing two websites and a console app to a build server and in the drop folder I get a _PublishedWebsites folder containing the deployment package for the custom configuration I have specified (ie not Debug or Release). I get the correct .Web_Package for each website.
I am using the MSBuildArgumments setting in the build process as follows:
/p:DeployOnBuild=true /p:PublishProfile=Development/p:VisualStudioVersion=10.0
Everything works well, but the team lead wants the actual deployment in the drop-folder and not the deployment package.
I have looked at the MS Documentation but it does not appear to help in my case.
I have tried creating a script, but I dont want to go into a huge series of powershell scripts, and I struggle with powershell anyway. I just cant get it to do what I want.
My question is: can this be done, and what is the best way of doing it? If it does mean creating a script then so be it ( perhaps one line for each object) - I am really having a hard time working out which direction I should be going in.
I thought something a script containing one line for each deployment -3 lines like this:
_PublishedWebsites/<project name>.Web_Package/<project name>.deploy.cmd /T: /M:<site> /U:<user> /P:<password>
But where to put the script and how to call?
I ended up using the solution as described in this blog post:
http://blog.degree.no/2012/03/automatic-config-transformations/
To get what I needed, I needed to change the project files of the projects to be deployed - adding this extra node at the top of each.csproj file
<Target Name="TransformConfigFiles" AfterTargets="AfterBuild" Condition="'$(TransformConfigFiles)'=='true'">
<ItemGroup>
<DeleteAfterBuild Include="$(WebProjectOutputDir)\Web.*.config" />
</ItemGroup>
<TransformXml Source="Web.config" Transform="$(ProjectConfigTransformFileName)" Destination="$(WebProjectOutputDir)\Web.config" />
<Delete Files="#(DeleteAfterBuild)" />
</Target>
and adding this switch to the MSBuildArguments in the build definition:
/p:TransformConfigFiles=true
When I run my builds using the DeployOnBuild switch, my builds output two folders, one with the Package, and one with just all the website files (both under PublishedWebsites). Is that not what you want?
I have:
BuildDrop_PublishedWebsites\Website
BuildDrop_PublishedWebsites\Website_Package
I am trying to deploy approval process to cutomer Production orgs. It is difficult to do the manual creation of approval in each customer org. Anybody know this can be done by ANT/Eclipse ? Thanks in advance
if you want to use Ant for deployment SF-apps you also need Ant-plugin - ant-salesforce.jar. So you can use the following script in build.xml
<project name="ExampleProject" default="ExampleProject" basedir="." xmlns:sf="antlib:com.salesforce">
<taskdef resource="com/salesforce/antlib.xml" classPath="ant-salesforce.jar" uri="antlib:com.salesforce"/>
<target name="ExampleProject">
<sf:deploy deployRoot="Application/src" username="your_sf_username" password="your_sf_password_and_token" serverurl="https://login.salesforce.com" runAllTests="true" rollbackOnError="true" />
</target>
</project>
(It's just an example, not working script)
Also you can use Eclipse with SF-plugin, which allow to deploy SF-apps and parts of them (also approval processes) to sandboxes. This plugin also has a lot of other useful functions.
I everyone, I am using Eclipse, Subclipse, and ANT. I would like to generate a build manifest with the files that have changed, added, updated, deleted, from the repo (with the individual version numbers on my current system).
<propertyfile file="${dist.dir}\deploymentManifest.txt"
comment="This file is automatically generated - DO NOT EDIT">
<entry key="buildtime" value="${builtat}"/>
<entry key="build" value="${svnversion}"/>
<entry key="version" value="${version}"/>
<entry key="systemLocation" value="${directory/filename.ext}"/>
</propertyfile>
How do I peel that information from the files in Eclipse? or how do I use ANY to retrieve this info?
Thanks,
Frank
Well, ${buildtat} could be taken from the <tstamp> task in Ant. The others could be parsed by doing a svn log --xml and then using the resulting XML from a <xmlproperties> task. Right off the top of my head (i.e. no error checking):
<!-- Gets the Time Stamp -->
<tstamp>
<format property="buildtat" pattern="MM/dd/yyyy HH:MM"/>
</tstamp>
<!-- Generates the revision information you need-->
<exec
executable="svn"
output="${svn.log.file}">
<arg line="log --xml -rHEAD/>
</exec>
<!-- Reads that information into a Property -->
<xmlproperty file="${svn.log.file}"/>
<echo message="Subversion Rev: ${log.logentry{revision}}"/>
However, I'd recommend you look at a continuous build system like Jenkins. Whenever you make a change in your Subversion repository, Jenkins picks up the change and automatically does a new build. Not only does this allow you to verify that your changes don't break your build, but Jenkins can do other things too like run JUnit tests. Jenkins then stores your build and the results of your tests and the whole build log in an easy to get to HTML page.
Where Jenkins will work for you is that Jenkins automatically exposes such things as the Subversion Revision as part of the build process. You can fetch the Subversion Revision, the Jenkins build number, the name of the Jenkins project and many other things as environment variables. Then, you could do this:
<property env="env."/>
<propertyfile file="${dist.dir}\deploymentManifest.txt"
comment="This file is automatically generated - DO NOT EDIT">
<entry key="buildtime" value="${env.BUILD_ID}"/>
<entry key="build" value="${env.SVN_REVISION}"/>
<entry key="version" value="${BUILD_NUMBER}"/>
<entry key="systemLocation" value="${directory/filename.ext}"/>
</propertyfile>
Take a look at Jenkins. It's fairly easy to understand and use.
It should take you about 5 minutes to download and maybe 10 minutes on a Linux system to get up and running. Windows is more complex and might take as long as 15 to 20 minutes to get up and running. You can run it on your desktop system for now, and play around with it.
It should take you maybe another half hour to figure out how to setup a project that can automatically do builds whenever someone does a commit.
Jenkins is web based, but comes with its own light weight web based application engine. All you need is Java 1.6 to run it. (And, if you're using Eclipse, you should already have that).
I've built a set of generic deployment scripts which work great for the majority of our stuff. We've just however introduced our largest project to the setup and we're now finding times are far too varied and long for our liking.
The project size as it stands is 33,226files at a size of 400Mb plus. Times are currently taking between 13mins & 55mins (the last deployments time) depending on certain decisions made by ANT ( more below ).
In terms of the steps we currently do the following on x2 servers:-
1) ANT exports the project from SVN to both servers (made up of 3 parts).
2) It begins to shutdown the Web Services on Server #1.
This was the workaround we put in to stop Windows (2003) file locking failing the deployment.
3) ANT runs a "move" task on the current version (all parts) into temporary folders & moves the exported new version into its place.
4) Customised deployment code is run - one part being to move permanant features from the temporary folder into the new (i.e system files / Web Server Admin tools).
5) Delete the temporary folder.
6) Bring the Web Services back online
... rinse and repeat for the 2nd server steps 2 -> 6.
7) Save the ANT logs.
The main issue I'm having is that the ANT move task seems to make one of two decisions. It either:
a) Very simply swaps the versions over and moves on - taking a minute or two to handling it or
b) Goes through some kind of integrity check that it moves every file and folder from one place to the other. This floods the logs and takes a fair length of time to complete. Hence the 40+ minutes extra added on.
I can't find anything online that explains what causes ANT/OS to make that decision. Option A would be the ideal full-time situation.
I've tried copy, delete separately. I've tried the sync task. All seem to have this slow performance.
So really I'm asking what others with more experienced than me do with deployments of this scale. Do you have any hints / tips on how I could improve / speed this process up? Any ideas what the move is doing and if there is maybe a better way of doing all this?
Thanks a lot,
James
Thanks for the input all.
Just to add an answer to this one I've made the following changes which seem to have knocked a few minutes of it.
The first one was I've changed how the swapping happens off the back of the comment I mentioned before. It seems that ANT will try and do the following :-
"If the target directory does not already exist, Ant will do a rename of the directory. But if the target directory exists, it instead does a copy into the directory and delete from the source directory instead."
I think what's happened is ANT is trying to put the new version in before the old version has been completely removed. So instead of trying to rename the old I've now moved it into a temporary folder and deleted this at the end of the build. That seems to have stabled things on that front.
A few other things I've added to make ANT a bit smart :-)
1) I've set it up so ANT will not deploy any part of the build that is the same as what currently exists. So if part 1 is selected and that's on the Test environment already then it's removed from the build and SVN exports.
2) With the service shutdown / startup I've got ANT reading the response that comes back. If a service tells it that it's already started when calls, as sometimes happens if a service relies on others Windows automatically boots them up, then I've told ANT to hang around and move onto the next one.
Little steps like that seem to have improved things by a fair bit. I'd like to still try and get more out of them but these certaintly have given them a big step.
Thanks again,
James
even we faced this problem of auto deployment script taking longer time in our organization. So initially we had our script running in sequential like cleaning, stopping tomcats, updating, starting tomcats and making sure that all webapps are properly deployed.
So we have done following things like:
1. parallely cleaning and stopping all tomcats
2. do svn swith
3. parallely start all tomcats
4. make sure all webapps are deployed properly using jmx
here is the piece of code :
<target name="all_clean_parallel">
<parallel>
<antcall target="x1_clean"/>
<antcall target="x2_clean"/>
<antcall target="x3_clean"/>
</parallel>
</target>
<target name="all_start_parallel">
<parallel>
<antcall target="x1_start"/>
<antcall target="x2_start"/>
<antcall target="x3_start"/>
</parallel>
</target>
And the piece of code to check whether webapp is deployed propely or not with jmx help :
<macrodef name="mStatus">
<attribute name="aModule" />
<attribute name="aHost" default="localhost"/>
<attribute name="aPort" default="9012"/>
<attribute name="aMaxWait" default="240"/>
<attribute name="aTomcat" default=""/>
<attribute name="aState" default="1"/>
<sequential>
<waitfor maxwait="#{aMaxWait}" maxwaitunit="second" timeoutproperty="#{aHost}.#{aTomcat}.#{aModule}.#{aPort}.server.timeout" >
<and>
<jmx:equals
host="#{aHost}"
port="#{aPort}"
ref="#{aHost}.#{aTomcat}.#{aModule}.#{aPort}"
name="Catalina:j2eeType=WebModule,name=//localhost/#{aModule},J2EEApplication=none,J2EEServer=none"
attribute="state"
value="#{aState}"
/>
</and>
</waitfor>
<if>
<equals arg1="${#{aHost}.#{aTomcat}.#{aModule}.#{aPort}.server.timeout}" arg2="true" />
<then>
<var name="failBuild" value="true"/>
<echo message="*************************Host.Tomcat.Module = #{aHost}.#{aTomcat}.#{aModule} is not deployed into the tomcat" />
</then>
<else>
<echo message="#{aHost}.#{aModule} is deployed into the tomcat" />
</else>
</if>
</sequential>
I created a template project named sample and started it with spring tc server. The application gets deployed but then when I go to http://localhost:8080/sample/ I get the following error
INFO: Server startup in 12669 ms
WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/sample/] in DispatcherServlet with name 'appServlet'
I followed the same steps as shown in http://www.youtube.com/watch?v=Y0V4oEnCcyA to create a spring web App.
I asked my friend to follow the same steps and test it on his Ubuntu 10.04 machine and it worked fine out of the box. I came up with the conclusion that it must be something with my machine. I'm facing this problem on Mac osx 10.4 and
SpringSource Tool Suite
Version: 2.6.0.RELEASE
My host file contains the following entry
127.0.0.1 localhost
Can anyone guide me as to how to rectify this problem?
Thanks.
That warning means that you didn't set something up right in your project, plain and simple. Without code we can only guess.
Speaking of guessing, check your web.xml and make sure it actually says "sample".
Template project does not work for me either.
I changed the servlet mapping onto
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
Follow up the request mapping in the controller
#RequestMapping(value = "/home.do", method = RequestMethod.GET)
Now you can open http://localhost:8080/sample/home.do
Check the log in your eclipse server console window (bottom screen). If you're like me, there's a bug when resolving the path for the home.jsp file. It comes from the servlet-context.xml file :
<beans:property name="suffix" value="/" />
should be
<beans:property name="suffix" value=".jsp" />
Make sure you clean and restart the server after doing that change, because it seems like this servlet-context.xml file is heavily cached.