-
1. Re: Unwaring web app - leaves some files in the war
ebaggaley Sep 24, 2003 10:39 AM (in response to dsklyut)Hello,
I am having the same problem with files in a war not being extracted. My war resides in an ear so I cannot just expand the files into a directory. I never had this problem on Windows, but as soon as I moved to Red Hat Linux I started to experience this problem. Did you ever find a resolution for this problem? -
2. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 13, 2007 9:49 AM (in response to dsklyut)Hi Folks,
Im using the latest JBoss AS 5.0 beta2 and experiencing something similar to the above.
I have a war file that looks like this
myapp/conf/config.properties
myapp/WEB-INF/ etc etc
Ok now im a bit confused about what the "tmp" directory and the "work" directory do and their relationship if any, i havent see any docs on it and would appreciate any links if possible.(I do need to read up on this but ill ask anyways )
Now the problem Im having is this, the war is exploded fine under the tmp directory but in "work" directory the .properties file is not there.
i have a third party library which looks for the properties file under conf/config.properties, but if doesnt find it because there the class loader which loads the libs is loading the classes out of the "work" directory and not the tmp directory.
So Im confused, which one is the correct exploded directory?? tmp or work and if its "work" which it seems to be because the classloader url is coming from the work directory, why isnt the .properties file exploded in there also??
Cheers,
LL -
3. Re: Unwaring web app - leaves some files in the war
peterj Dec 13, 2007 11:22 AM (in response to dsklyut)The tmp directory is used to explode war/ear/sar/etc files. The work directory is used by Tomcat to compile JSPs.
If you are loading a properties file using a directory location (as opposed to getting it from the classpath), you are better off deploying an exploded directory. -
4. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 13, 2007 3:33 PM (in response to dsklyut)Its a third party lib that i use that loads the resource file so i cant change how this works.It does this by getting hold of the class and then class.getResourceAs().
As a work around for the moment i have copied the properties file into the "work directory" but this would not be an ideal solution for me.
The war file is also part of an ear file so deploying an already exploded directory is not an option!! -
5. Re: Unwaring web app - leaves some files in the war
peterj Dec 13, 2007 3:46 PM (in response to dsklyut)You could explode the existing ear and war files.
-
6. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 13, 2007 3:49 PM (in response to dsklyut)will try it tomorrow and will let you know how i get on!!
Cheers Peter,
LL -
7. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 14, 2007 7:37 AM (in response to dsklyut)Ok i exploded the war file as a directory in the deploy directory and still i get the same problem. Makes no difference, the classloader loads the classes from the libraries inside the work directory so when class.getResource() gets called it returns a URL as to where the class file is located and from here it works its way up the URL dir structure to find the properties file but it aint there because the URL points to the work directory and in this directory the properties file aint there!!
Is this a bug or known limitation?? -
8. Re: Unwaring web app - leaves some files in the war
peterj Dec 15, 2007 11:59 AM (in response to dsklyut)I am assuming that you also deleted the work and tmp directories, and restarted the server, when you exploded the war?
Looks like I will have to try this myself to see what is going on. Won't get to that until Monday, I'll post my results. -
9. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 17, 2007 3:57 AM (in response to dsklyut)I did delete the sub dir in the work but not in the tmp!! will delete them and get back to you!!
-
10. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 17, 2007 4:07 AM (in response to dsklyut)Ok I deleted the sub-dir for my war in both the tmp and work directories. I have my war file exploded in a directory in the deploy directory but still no joy.
-
11. Re: Unwaring web app - leaves some files in the war
peterj Dec 17, 2007 1:13 PM (in response to dsklyut)LL, I am trying to replicate the problem, but I have a few questions.
1) Originally, you stated that the your WAR contained:
myapp/conf/config.properties
myapp/WEB-INF/ etc etc
Did you really mean the the WAR is as follows:myapp.war + conf + config.properties + WEB-INF
In other words, within your WAR there is not a base directory named myapp and that instead both conf and WEB-INF are base directories.
2) You stated that the code "class.getResourceAs()" is used to access the properties file. My understanding of getResourceAsStream (which is what I think you meant) is that the file is loaded using the class loader, and therefore the properties file would have to be located at WEB-INF/classes/config.properties (or within a jar in WEB-INF/lib).
I assume that in the WAR file there is a conf base directory and the properties file is located in that directory. Could you post the exact code used to access the properties file, including the code that obtained the 'class' variable.
3) I noticed you are using 5.0 beta2. Have you tried your app in 4.2.x? Does it work there? The reason I ask is because the deployer in beta2 is broken in so many ways, in which case you might have been lucky enough to find another way that it is broken. -
12. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 18, 2007 4:15 AM (in response to dsklyut)
Did you really mean the the WAR is as follows:
First off I had everything packed in the war, then i did like you suggested and exploded the WAR in a directory so it looked likedeploy +myapp.war +conf +config.properties +WEB-INF
In other words, within your WAR there is not a base directory named myapp and that instead both conf and WEB-INF are base directories.
When you say this i assume that you think i exploded the war into the deploy directory without a base directory.(I assume thats what you mean).No it does have a base directory
deploy
+myapp.war (The dir is called myapp.war)
and inside myapp.war is the sub-directories.
Heres the code, sorry it uses Class.getResource and not class.getResourceASstatic { try { Class class1 = (new ProjectRootClass()).getClass(); URL url = class1.getResource("ProjectRootClass.class"); String s = url.toString(); System.out.println((new StringBuilder()).append("ProjectRootClass: Probe URL is ").append(s).toString()); theProjectRoot = s.substring(s.indexOf("file:") + 5, s.lastIndexOf("/WEB-INF/")); System.out.println((new StringBuilder()).append("ProjectRootClass: The project root was detected at ").append(theProjectRoot).toString()); } catch(Throwable throwable) { System.err.println("ProjectRootClass: Initialisation failed"); throwable.printStackTrace(); theProjectRoot = ""; } }
The code works out where the root directory of the war file is and from here uses the root to find the config.properties but because it loads the class from the work directory and not the tmp directory it wont find the properties file.
I noticed you are using 5.0 beta2. Have you tried your app in 4.2.x? Does it work there? The reason I ask is because the deployer in beta2 is broken in so many ways, in which case you might have been lucky enough to find another way that it is broken.
I will download 4.2.x and will post my findings later today. -
13. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 18, 2007 4:27 AM (in response to dsklyut)Ok using 4.2.2.GA
I see the difference now. In 5.0 version the whole lib directories are copied over into the work directory, this is not the case in 4.2.2GA,
My dir structure in the work directory looks like this
5.0 version
myapp
+org
+WEB-INF
+ lib
tldCache.ser
In the 4.2.2GA i have no WEB_INF dir, just the org directory
myapp
+org
tldCache.ser
So if going on how the 4.2.2GA works then i shouldnt have any WEB_INF directory in my work directory which i do!!! -
14. Re: Unwaring web app - leaves some files in the war
lovelyliatroim Dec 18, 2007 4:28 AM (in response to dsklyut)Sorry in that last post it might look a bit confusing, the indentation didnt come through but the lib directory is under the web-inf directory.
Just in case any confusion!! ;)