This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes J2EE Web App Deployment questions 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 » Java » EJB and other Java EE Technologies
Bookmark "J2EE Web App Deployment questions" Watch "J2EE Web App Deployment questions" New topic
Author

J2EE Web App Deployment questions

Jeff Gaer
Ranch Hand

Joined: Jun 04, 2001
Posts: 99
1) How are paths built to refer to other files packaged in the same .war file? For example
index.html in the root directory of the .war files has the following reference

with the war file unjarred, if index.html is directly accessed the logo file is correctly resolved to the gif file in the images directory. However when accessing it through the J2EE application server ( tomcat 3.2.1 ) the image reference is unresolved. Likewise, I need to specify some xsl files for use by a translation servlet I can do this successfully by using a complete url i.e. http://myHost:8080/examples/servlets/example.xsl but would like to do so using a relative expression so the hostname would not have to be known.
(2) is it possible to imbed some xml fragments into the web.xml file? I would like to be able to provide some table like configuration outside of a database.

<init-param>
<param-name>configXML</param-name>
<param-value>
<myXmlFrag>
<row attr1="a" attr2="b">key</row>
......
<myXmlFrag>
</param-value>
</init-param>

next question using jaxp with j2ee1.2.2
I am trying to deploy a servlet that relies on the jaxp1.1 extensions on the server provided with the j2sdk1.2.1. What is the appropriate way to resolve that issue. Should I just specifiy jaxp1.1 as a pre req and assume that anyone deploying the web component containing this servlet will have the jaxp1.1 classes in the servers path? or should I packace the jaxp1.1 jar files in the servlet component. If the latter how is that Accomplished? I tried adding all 3 jar files to the web coponent but still get the following error when I run check in the
deployment tool.
unexpected error in verifier, check for problems related to: [ java.lang.NoClassDefFoundError: javax/xml/transform/TransformerException ]

------------------
Thanks in advance for any help
Jeff Gaer


Sun Certified Java Programmer Java 2<P>Jeff Gaer
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

What I've done is to place my image directory at the same level as where the App Server unjars the web app. That way i can say "/images/logo.gif" in my < img src= > tags.

If you wanted to place the images directory within your webapp, I think it could be done, and then simply say "/< webapp dir name >/images/logo.gif"

About your second point, I've noticed the verifier is quite buggy (along with a bunch of other things about the j2sdk1.2.1).

I use the com.oreilly.servlet package, and I've had no trouble including this jar as a Library package (off of the application, not the web component). Have you tried adding it as a Library Component on the Application itself?

p.s. As you might see, you need to leave spaces between your < and >, otherwise UBB tries to turn it into HTML, and drops anything it doesn't like. (or embedd the whole thing in [ code ] blocks)
[This message has been edited by Mike Curwen (edited June 04, 2001).]
Jeff Gaer
Ranch Hand

Joined: Jun 04, 2001
Posts: 99
The jaxp stuff works fine if I add it as a jar to the application, but I was hoping to have a self contained application without external dependancies, I thought that was the point of web applications they would install and run on any j2ee compliant as long as they defined and contained all their resources. I'm beginning to feel like J2EE is not yet ready for primetime.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

I'm not sure how a library jar file is 'external'.

If you add the jar to the application, then it's not external. It gets put in the .ear file as well, and will be deployed when the .ear file is deployed.

Did you mean something else?

If.. (I'm thinking I see your point now...) you mean that Web Apps don't have a "add to library" button, then you're right .. that's annoying. One should be able to have a .war file contain additional jar's without needing to make it an .ear file.
Jeff Gaer
Ranch Hand

Joined: Jun 04, 2001
Posts: 99
what I mean is I added the jaxp jar files to the <webappl>/library directory, and still got a no classdef found exception when I ran check, or attempted to deploy the application. If I put those jar files in the system classpath, I don't have a problem. I was hoping I could avoid a complex installation process by embedding the requirements in the .war file in the library directory but that does not seem to work.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

One thing to consider..

The check and deploy tools are a bit faulty. My own experience with library jars (particularly if they contain classes that are used by Beans), is that the deploytool will not be able to include the library jars at deploytime when I do an 'update and redeploy'.

But I get a much better result when I undeploy the application, and redeploy it. It's a stupid bug, but the bottom line is, library jars work, if you have the patience to get past the bad tools.

Another path to the same result: Click "update and redploy", wait for the error, dismiss it, and click "update and redploy" again. It should work (if you are having the same problem I had).
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: J2EE Web App Deployment questions
 
Similar Threads
ServletConfig getInitParameter() ????
How can make .war file for IBM websphere configurable?
struts/jboss/tomcat application not working
advice regarding URL for a servlet
we can deploy a folder instead of jar or war what is the difference