• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Path to the deployed war class folder

 
Ryan Raina
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI everyone
I want to know how can I get the path to the classes folder inside a war using java...
path I want to get is should be C:\jboss-5.1.0.GA\jboss-5.1.0.GA\server\default\deploy\abc.war\WEB-INF\classes
is this one approach..String tempPath = getClass().getResource("/").getPath();
Thanks in advance.............
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far this is where you will find your .class files. C:\jboss-5.1.0.GA\jboss-5.1.0.GA\server\default\deploy\abc.war\WEB-INF\classes

Is there any problem? Or do you want to know how to get this path by java commands?
 
Tim Holloway
Saloon Keeper
Posts: 18302
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot do that without violating the J2EE standard.

According to the spec, a WAR is a JAR-format archive file. Note the word "file", not "directory", not "files". In a WAR file, the WEB-INF/classes "directory" is just a path within the WAR and cannot be accessed natively by the host OS filesystems.

Within a WAR, you can obtain access by using the HttpServletRequest getResource() and getResourceAsStream() methods. They don't return filesystem paths, but they do return objects that the webapp can use to read WAR resources such as property files.

Some webapp servers support the concept of optionally "exploding" a WAR. In that case, the WAR is unzipped, and there will be a physical WEB-INF/classes directory on the filesystem. However, exploded WARs are not part of the J2EE standard and any webapp that depends on a WAR having been exploded will not be standards-compliant.

Under absolutely NO circumstances should you ever WRITE to a location within a WAR. Even if the server permits it, you WILL experience pain.
 
Ryan Raina
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks all for replies..
I am doing is a url deployment...My app server is Jboss5.1.0 ga...I have edited profile.xml and i have given the url to the deployed artifact.....war is generated by the installer while installing the product on the customer side......It's already in exploded form ......That's the reason I wanted to know about this....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic