aspose file tools*
The moose likes BEA/Weblogic and the fly likes Hot Deploy with Weblogic 8.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Products » BEA/Weblogic
Bookmark "Hot Deploy with Weblogic 8.1" Watch "Hot Deploy with Weblogic 8.1" New topic
Author

Hot Deploy with Weblogic 8.1

Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
Hello,

In order to use the hot deploy (re-deploy the app without restarting server), I'm using the server in development mode and using the following directory structure for my enterprise application.

domains/my_domain/applications/myapp
|
|-APP-INF
|-APP-INF/classes
|-APP-INF/lib
|-META-INF
|-META-INF/application.xml
|-META-INF/REDEPLOY
|-myejbs.jar
|-mywebapp.war

The jar file contains all the EJB classes and deployment descriptor; the war file contains the JSPs, servlet classes and web.xml; and the APP-INF/classes folder contains all the common classes.

Now to test this after deploying first time with this structure, I changed one of the JSPs, and copied the modified war file and then changed the timestamp of the REDEPLOY file (by touching it). And it refreshed the changes, so logically it is redeploying the files without restarting the server.

Now, the problem is that there are some classes which are being instantiated dynamically (using Class.forName()). And when it tries to load the first class through Class.forName, it fails by giving "java.lang.NoClassDefFoundError".

I tried following alternatives to get rid of this error, but no luck so far:
- Tried adding the common classes directory explicitly in classpath
- Deploy the application as a bundled EAR file instead of exploded structure
- Tried adding the required classes in the jar and/or war files.

Any clues at this point?
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
It's been a while since I've done these things, but one thing I do remember is that it's a good idea to create the EAR file which contains all the files for your application (as this reduces the chance of running into classloader problems).

Also, consider deploying using the wldeploy Ant Task or the weblogic.Deployer utility.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
I tried deploying the EAR file as well, but there also I'm getting few errors.

I also tried the weblogic.Deployer, but it's asking me for password of "installadministrator" which I doesn't know. Tried some standard passwords here but none works.

By the way, in my ear file, there are some set of classes which are common, means they are being used in both the servlets as well as EJBs. Where in the structure of EAR file should I copy these classes?
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
I am somehow getting a feeling that the structure in which I'm packaging the EAR is having problem.

In the EJB jar file, I've included all EJB classes, DD and all the other helper classes used by EJBs.

In war file, I've included all the jsps, servlets, DD and helper classes being used by jsps and servlets.

Now, in the EAR file, if I just keep the jar, war and META-INF/application.xml, it throws exception for BasicConfigurator.class which is part of log4j.jar. This is inspite of the fact that log4j.jar file is already present in WEB-INF\lib.

If I include this log4j.jar file in APP-INF\lib directory, then it is able to find that class and then it gives me an exception that not able to find one of the .propertis file.

Now, if I copy this properties file under APP-INF\classes folder, it is able to find the properties file but then gives me NoClassDefFoundError for that class which is being loaded through Class.forName. ((
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
Try doing this instead.

Package your common classes in a common.jar file.

In the WAR file, create a manifest file which references the common.jar file.


The manifest file should be located in the archive at META-INF/MANIFEST.MF.

You will need to place the common.jar file next to the WAR file:

/<directory>/MyClient.war
/<directory>/common.jar

Now, do something similar with your EJB JAR file.

Hopefully, this will solve your problem.
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
I tried what you suggested above, but it still doesn't work.

I deployed the EAR with following structure: (MANIFEST.MF in the war > WEB-INF/META-INF and jar > META-INF contains Class-Path as you suggested):

EAR
+ META-INF
- MANIFEST.MF
- application.xml
- myejb.jar
- myweb.war
- mycommon.jar

Now while deploying it is throwing NoClassDefFoundError for one of the classes in mycommon.jar file. Note, here that this class is being loaded normally, not through Class.forName().
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
Surprisingly, I am able to re-create exact same problem on a different machine as well.
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
Another interesting thing to note here.

The reason I'm trying to get the Hot Deployment in place is, during development we change lot of things frequently and need to keep redeploying the application frequently and manual redeployment is taking quite long time.

Now, if I take the ear file which I'm deploying manually (which works perfectly fine) and copy this in the domains/applications folder it gets deployed, but at the runtime it is not able to find third party library files (even if I have added that jar in "Class-Path" in META-INF/MANIFEST.MF file under war).

This looks very strange to me
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
How about deploying as an exploded directory rather than as an EAR file. This will enable you to do partial updates to a deployed application without redeploying the entire application.
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
When I deploy under the domains/mydomain/applications/ directory, either as EAR or exploded, the behavior is more or less same.

The difference is when I deploy it manually, that time everything works perfectly fine.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
What are you doing to manually deploy the application?
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
Originally posted by Roger Chung-Wee:
What are you doing to manually deploy the application?


Go to console (http://server_ip:8001/console), login with the system user, go to Deployments > Applications. Delete existing application, Deploy new application, then restart the corresponding managed server.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hot Deploy with Weblogic 8.1