We help IT Professionals succeed at work.

.WAR File problem (weblogic)

somadude
somadude asked
on
Medium Priority
1,257 Views
Last Modified: 2008-01-09
ok this is *really* confusing and annoying!!! I have a .war file (servlet + jsps + descriptor) packaged up in the correct way, I have checked the docs like 100 times.. the problem is, I'm running win NT and when I create the war file I'm executing 'jar' on a directory structure..

WEB-INF/classes
WEB-INF/web.xml
*.jsp

But when I view the resulting .war file in winzip, I see this..

WEB-INF/classes/all classes.....
web-inf/web.xml

where on earth is this lowercase web-inf coming from ??
as a result when i deploy this war file, it deploys fine and the init() method of the servlet is called, however when i try to access the servlet via it's alias (specified in web.xml) it can't be found.

The exact same files work when used as an exploded directory (DefaultWebApp), and can be accessed via the alias.

The MS-DOS name of the directory is WEB-INF so I simply can't understand where the "extra" lower case directory web-inf is coming from........

Am I correct in assuming the lowercase web-inf is the problem ?? I'm not 100% sure cos the weblogic console can read & edit this xml file.

any thoughts/suggestions/solutions greatly appreciated,
thanks,
sd
Comment
Watch Question

Commented:
it's a windows/zip thing. if you unjar the exact same war on a unix box it would work perfectly.

what you can do is unjar the contents of the war into a directory. and then in your weblogic.properties file tell weblogic the complete path to that directory as opposed to just pointing to a filename.

Author

Commented:
No you see the problem is that I need it deployed as a war file, not as an exploded (un-jarred) directory (that works fine).

thanks anyway,
sd

Commented:
have you tried this:

open winzip in the classis mode (without opening a specific archive, just winzip alone; in the classic mode).

go to 'Options->Configuration'

on the 'View' tab, check 'Allow all upper case file names'

close winzip.

open winzip again. but now click the 'Open' icon (or 'File->Open Archive')

locate and open your .war file

what do you see? all of your directories should be upper case now.

try rebuilding the jar after you change the case configuration in winzip and see what happens.

logically, i don't see how that would fix your problem because i think that configuration only affects the winzip gui. but it might be worth a shot.

please let us all know how you get on.

Commented:
please can you post a snip of your web.xml where you have defined the servlet's alias (url mapping, etc)?

also, please can you post the exact url that you are using to call the servlet from your browser?

and the exception stacktrace that weblogic is spewing up could help shed some light if you can please.

Author

Commented:
cheers for the interest lads, ok what I'm doing now is I have a "hello world" servlet in a war file [how embarassing :) ] cos I can't get ANYTHING delpoyed via a war file!! (As I've mentioned, exploded directories work fine but I'm not allowed use them).

The web.xml file for the HW.war file is .......

<?xml version="1.0" ?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" "http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
 
  <!-- SERVLETS -->

     <!-- servlet definitions -->

     <servlet>
            <servlet-name>HWServlet</servlet-name>
            <servlet-class>HWServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
     </servlet>

     
     <!-- servlet mappings -->

     <servlet-mapping>
            <servlet-name>HWServlet</servlet-name>
            <url-pattern>HW</url-pattern>
     </servlet-mapping>
     
</web-app>

Now when I deploy this war, weblogic looks happy, here's what the stdout is (I have sdout set to "info" so there's alot of information..).

<Feb 13, 2002 10:45:59 AM GMT> <Info> <HTTP> <[HTTP myserver] Loading web app: HW>
<Feb 13, 2002 10:45:59 AM GMT> <Info> <HTTP> <[myserver] Loading HW from WAR file: D:\bea\wlserver6.1\.\config\mydomain\applications\.wlnotdelete\wl_comp65023.w
ar>
<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP> <[WebAppServletContext(2563153,HW,/HW)] extracting classfiles to D:\bea\wlserver6.1\config\mydomain\applications\.w
lnotdelete\WEB-INF\_tmp_war_myserver_myserver_HW:>
<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP> [WebAppServletContext(2563153,HW,/
HW)] extracted classfiles successfully...>
<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP Session> <Creating SessionContext of type: memory for webapp: /HW>
<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP> <[WebAppServletContext(2563153,HW,/
HW)] registering classpath servlet with initArgs 'null'>
<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP> <[WebAppServletContext(2563153,HW,/
HW)] registering getior servlet with initArgs 'null'>
<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP> <[WebAppServletContext(2563153,HW,/
HW)] registering tunneling servlets with initArgs 'wl-dispatch-policy=direct'>
<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP> <[WebAppServletContext(2563153,HW,/
HW)] registering JSPServlet with initArgs '[JspConfig: verbose=true,packagePrefi
x=jsp_servlet,-compiler=javac,compileFlags=,workingDir=D:\bea\wlserver6.1\config\mydomain\applications\.wlnotdelete\WEB-INF\_tmp_war_myserver_myserver_HW,pageCh
eckSeconds=1,superclass=null,keepgenerated=false,compilerSupportsEncoding=false,
encoding=null,defaultfilename=index.jsp,compilerclass=null,noTryBlocks=false]'>

<Feb 13, 2002 10:46:00 AM GMT> <Info> <HTTP> <Loading servlet HWServlet into WebAppServletContext(2563153,HW,/HW) context>
>>>>>>>>>>>>>>>
HWServlet::init()
>>>>>>>>>>>>>>>
<Feb 13, 2002 10:46:00 AM GMT> <Debug> <HTTP> <Registering ServletContext: "HW:/
HW">
<Feb 13, 2002 10:46:00 AM GMT> <Info> <J2EE>
<Deployed : HW>

just above there you can see the servlet's init() method being called (it's loaded on startup). My url-mapping for the servlet is "HW", and weblogic is running on port 7001.

But when I access this url
http://127.0.0.1:7001/HW
NOTHING happens! (besides error 404) weblogic doesn't even respond (i.e. nothing is printed to stdout).

this should be simple ??? does anyone have a clue why this isn't working or does anyone have their own simple war file that they are *positive* should deploy ok and be accessed by a url mapping ??

thanks alot,
SD
Commented:
i believe your problem is in your web.xml file's url-mapping element. you've got:

<url-pattern>HW</url-pattern>

i think what you want (for the url you're calling it with) is:

<url-pattern>/</url-pattern>


what deploying the war file has done is define a web application named HW. and within that web application's deployment descriptor (web.xml) you've mapped a servlet to the url HW. you're getting a 404 because your url is calling a servlet in the HW web app mapped to /. but there isn't a serlvet mapped to / in the HW web app.

or, if you don't want to change the web.xml you should be able to get at the HW servlet (that lives in the context of the HW web app) with:

http://127.0.0.1:7001/HW/HW

please tell me, have you ever been able to successfully deploy war files on your current setup?

Author

Commented:
ok - got it sorted - your explanation helped me understand how weblogic resolves those urls, cheers.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.