my dog learned polymorphism*
The moose likes Ant, Maven and Other Build Tools and the fly likes Manually adding java class files to a WAR file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Manually adding java class files to a WAR file" Watch "Manually adding java class files to a WAR file" New topic

Manually adding java class files to a WAR file

Lawrence Gatson

Joined: Oct 25, 2010
Posts: 9
I've been doing core java for awhile. I'm kind of new to web environment...

To be more specific new to generating WAR files.

My development environment is Windows, Eclipse and Tomcat.
Target environment is Unix and WebLogic.

I've updated and successfully tested 3 java classes and 1 JSP in an existing web application. Now I'm ready to build the war file and deploy it on the test environment on Unix.

The [grumpy] systems administrator instructed me to build the WAR file as follows (he is unaware if a Build.XML file exists):
1. In Windows, use the 7zip application to "browse/explore" into the [existing] WAR file
2. Drag and drop the updated class files and jsp file from Tomcat into the WAR file

The WAR file deployed on Weblogic, and the web app did came up, but the [JSP] page that I updated is not rendering. The sys admin is blaming my code, but I don't think that is the problem.

My question is: Is this a valid way update a WAR file?

Thanks, I just need validation. If this is a valid way to update a WAR file then I'll continue down this path.

Peter Johnson

Joined: May 14, 2008
Posts: 5812

It's a valid mechanism only if you don't screw it up by placing the files in the wrong location. I would use a slight modification to this process: rename the xxx.war file to, unzip it into en empty directory, copy the files to the correct directories, and then zip it back up (making sure that you don't accidentally make xxx the base directory!), and rename the file to xxx.war. I have done this often with JAR files when I want to change a single class.

Warning: if you do this, make sure you use standard zip compression, Java cannot handle some of the compression mechanisms provided by 7Zip (avoid any mechanism that claims to provide better compression).

Of course, using a standard build script to rebuild from source is always the preferred method.

JBoss In Action
Lawrence Gatson

Joined: Oct 25, 2010
Posts: 9
Thank you for the response; I'll continue down this path with your suggestions...I agree, I wish I could get my hands on the build script. -llg
I agree. Here's the link:
subject: Manually adding java class files to a WAR file
Similar Threads
Eclipse not seeing updated JAR in tomcat\lib library at runtime
migrate codes generated in windows IDE to unix environment
Wanted Java J2EE Consultants in Dalton,Georgia
Eclipse 3.1 and jsp
deploying war file on weblogic 9.2