Deploying java class files without restarting JBoss - java

I would like to know if its possible to deploy java class files without restarting JBoss server. I am using jboss v4.2.2.
Also, when I try to deploy jsp files, it works fine and server picks up the changes almost instantly.
Thanks a lot in advance :)

I'm better with Tomcat than JBoss, but it should be possible (as in Tomcat) to restart the application without restarting the app server. If the server has a "development mode" and this is active, then it should be possible to trigger an app restart simply by touching WEB-INF/web.xml, i.e. updating its timestamp. That should get your previously replaced class file loaded.

Theoretically, you never have to restart the whole server, you only restart specific applications (ear-s). JBoss (with default settings) will automatically redeploy your ear if it notices any changes in it. Just copy the new version over it.
If you're not using it already, check out JBoss Tools set of eclipse plugins, to simplify whole process of deploys during development: http://www.jboss.org/tools

Yes, it is possible to re-deploy your class files without stopping and starting the server each time.
The only thing you have to do is to make a junction or a symbolic link to the application directory (in eclipse is usually "WebContent") and put the name you want in Jboss.
I've made a step-by-step tutorial here.

Deploy the app as exploded (project.war folder), add in your web.xml:
<web-app>
<context-param>
<param-name>org.jboss.weld.development</param-name>
<param-value>true</param-value>
</context-param>
Overwrite the web.xml every-time you deploy:
set PRJ_HOME=C:\Temp2\MyProject\src\main\webapp
set PRJ_CLSS_HOME=%PRJ_HOME%\WEB-INF\classes\com\myProject
set JBOSS_HOME= C:\Java\jboss-4.2.3.GA-jdk6\server\default\deploy\MyProject.war
set JBOSS_CLSS_HOME= %JBOSS_HOME%\WEB-INF\classes\com\myProject
copy %PRJ_CLSS_HOME%\frontend\actions\profile\ProfileAction.class %JBOSS_CLSS_HOME%\frontend\actions\profile\ProfileAction.class
copy %PRJ_CLSS_HOME%\frontend\actions\profile\AjaxAction.class %JBOSS_CLSS_HOME%\frontend\actions\profile\AjaxAction.class
ECHO.>>%JBOSS_HOME%\WEB-INF\web.xml

Related

Why does JBoss always redeploy .WAR files that have already been deployed but not changed?

I am new to using the JBoss 7.1.1 server and am confused by a behavior that I have observed.
My JBoss server is deploying the six jBPM .war files (designer, drools-guvnor, jbpm-form-builder, jbpm-gwt-console, jbpm-gwt-console-server, jbpm-human-task-war) which I have placed in the .\jboss-as-7.1.1.Final\standalone\deployments folder.
When I launched the server for the very first time it detected these files and deployed them. I see the deploymentNNN and tempNNN folders appear in the .\jboss-as-7.1.1.Final\standalone\tmp\vfs folder. This is similar to the behavior I'm familiar with from my use of the tomcat server.
I then shut the server down and observe that the two folders created in .\jboss-as-7.1.1.Final\standalone\tmp\vfs are retained but their contents are automatically deleted. When I restart the server it once again deploys the six jBPM files into a new pair of folders in .\jboss-as-7.1.1.Final\standalone\tmp\vfs.
This is very surprising because no changes have been made to the six jBPM files and the problem is that this redeployment takes 3 to 4 minutes.
If this was just happening in a "production" environment then perhaps this would not be much of an issue. However, I am trying to integrate the JBoss server into use with Eclipse Kepler in a development environment and having to wait 3 to 4 minutes for each code change and server launch is not practical.
1) Can anyone explain why JBoss goes to the trouble to redeploy files that have not been changed?
2) Is this a behaviour that can be changed through a configuration setting?
3) Is there any settings where we can stop the jboss to redeploy the war files when it restarted
Thank you,
All
In order to stop JBoss from re-deploying your apps (and deleting on shutdown),
try deploying the apps in unpacked form.
extract the files to {name}.war directories (e.g /designer.war, /drools-guvnor.war)
and then deploy these directories (i.e copy them to the deployments folder)
Alternatively, try to deploy them using the JBoss CLI
Deploying differently won't change the fact that at startup JBOSS reloads your application to the JVM.
This can take time because your application stores data from database to your server memory. (You could as well be hitting this WFLY-925 bug... Or the one they are talking about here...)
The thing is you normally don't need to restart your server completely when redeploying. You can hot-deploy your module - see also full doc. at Auto-deploy mode. (make sure the feature isn't disabled
If you need some context to be reloaded, I advise you have a specific procedure in your code that you can call to reload all cached info. instead of restarting completely (e.g. have a call to a specific URL from your application do it...)

Avoid Server restart after publishing resource in eclipse?

i am using eclipse server to the publish my web application to my local tomcat server.Whenever i modify
java or non java resource, it gets published to server(as i have selected automatically publish when resource change).But problem
is as soon as resource is published, server gets restarted which i want to avoid as it takes ample amount of time. How to avoid server restart ?
I think you are looking for hot deployment?
Heres a good tutorial I seen a while ago http://www.mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/
Whenever you change your code, Automatically eclipse detect your source has modified, and start redeploying your actual code into server. So that Tomcat server is restarting in a particular time interval.
You can configure tomcat for reload automatically, configure the attribute reloadable to true of the Context.
For do Tomcat 7 you must do.
Edit CATALINA_HOME/conf/context.xml
Change:
<Context>
For:
<Context reloadable="true">
Where CATALINA_HOME is your tomcat installation.
clicks on the “Module” view, make sure “Auto Reload” is “Disabled“. Default is enabled. It will stop the auto restart.
To do it in one go for all modules
In server options, uncheck option Modules auto reload by default
Also have a look at Stop Eclipse restarting my web app on file save

Change Deployment descriptor web.xml on glassfish 3

Is there anyway to change certain web.xml parameters of an already deployed application in the glassfish?
If you change directly in the file-system, no one will understand later, why and when the changes have been done. So this is bad!
But it's easy: Just change the web.xml of the deployed application and restart the glassfish domain. You will find the web.xml somewhere near
/PATH/TO/glassfish3/glassfish/domains/DOMAIN/applications/APP-NAME/WAR-NAME/WEB-INF/web.xml
if deployed in a standalone instance. Otherwise it is somewhere below the ..../nodes folder.
Edit: In a cluster environment, a sync from the deployment manager will override your changes.

Need to restart server for the sake of mailing

I developed an application having mailing operation in it, I am using tomcat 6 for deploying the application, I have ant script for building the war.
Now my problem is whenever I build the project, mailing stops working until I restart the server, and I came to know from one of professional saying that mailing context needs to be reloaded hence when you restart server the mailing works again.
But I don't want to restart the server every time I deploy new build, at the same time mailing should work. Is there any way to reload the mailing context when ever I build the project and deploy?
To make context reload on application file modification change the context.xml configuration file
from
<Context>
to
<Context reloadable="true">

How to work with a shared Tomcat?

Sorry, but I tried searching for this subject, but I didn't find related to my problem.
Recently, I bought a domain and web hosting for it. I bought it especially for using it for my Java projects.
I have Tomcat available as server on the hosting.
My question is: how do I work with a hosted Tomcat, which, in my opinion, it is quite different from localhost (where you could have unlimited access)?
For example, if I create a Spring project that looks like this:
project-name
src
war
index.jsp
WEB-INF
web.xml
The index.jsp outputs a simple This is a test
web.xml
<welcome-file-list>
<welcome-file>
index.jsp
</welcome-file>
</welcome-file-list>
I created an Ant build.xml that will build the project, but when I access from http://domain.com/project-name it will not work, and I only cand access the file from http://domain.com/project-name/war
If I had done this on localhost, I'd deploy it in tomcat-path/webapps, but how does this work online?
The solution is to install Tomcat Manager Webapp in order to deploy applications on a shared hosting that uses Tomcat as server.
EDIT:
If the hosting doesn't offer you Tomcat Manager (as was in my case), you can still make it through by asking the administrator of your hosting to configure your jk_mod file to deploy your war files.
Append these lines
jkMount /*.war ajp3
jkMount /* ajp3 ## I'm still not sure if this made it work, because it makes tomcat listen on the entire public_html
But be aware, if your version of Tomcat is brought to you by cPanel's EasyApache, you will have to deal with some issues there too - the latest installed Tomcat will be 5.5.33 (a bit old, right?), but again you can try tweaking the old version and install, let's say 6.x.x
A tutorial about this upgrade:
http://www.bestdesigns.co.in/blog/install-tomcat-6
The thing that help me a lot to understand the concepts that were envolved in solving this problem:
http://www.scribd.com/doc/6085698/Tomcat -- a training course about Tomcat and cPanel
An another thing to add: Install a local version of Tomcat on your machine, first deploy it on localhost. If there it works, it should be working online as well.
Those of you who work with Spring Roo, on Tomcat 5.5.33, if you already know, you cannot deploy your projects, becase of the too old Tomcat, so you have to upgrade your Tomcat immediately.
I hope this will help all of those who had difficulties like myself.

Categories

Resources