aspose file tools*
The moose likes Tomcat and the fly likes output a webapps classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "output a webapps classpath" Watch "output a webapps classpath" New topic
Author

output a webapps classpath

David Sheltby
Ranch Hand

Joined: Oct 19, 2011
Posts: 34
Is it possible to output (to stdout or logs) the classpath for a webapp?

thanks!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

Let's back up a step: why would you want to do that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

There really isn't a class path -- at least not in the same sense as the command line. What are you actually trying to accomplish?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
David Sheltby
Ranch Hand

Joined: Oct 19, 2011
Posts: 34
I'm getting a ClassNotFoundException for a class which is in the web-inf/classes directory. I wanted to confirm that its actually loaded.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18911
    
    8

It appears you spelled the name of that directory wrong. It should be "WEB-INF/classes", not "web-inf/classes".
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61662
    
  67

Anything that's in WEB-INF/classes will be loaded (and yes, case counts!). You don't need any further affirmation on that.

If you are having problems with a class, the problem is with the class or your package structure, not with the container.
David Sheltby
Ranch Hand

Joined: Oct 19, 2011
Posts: 34
It is WEB-INF/classes. Thats not the problem. I will have to look into the class more. The package structure appears to be correct. Even decompiling the class to verify the package confirms this.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

Bear Bibeault wrote:There really isn't a class path -- at least not in the same sense as the command line. What are you actually trying to accomplish?


Well, actually, there is. And, as a matter of fact I have found it necessary to dump the classpath of a webapp once or twice. It's not that hard if you chase down the proper JavaDocs.

There isn't a single classpath in a J2EE system. Depending on context, the classpath varies, and in particular, each webapp has its own unique classpath - which includes the WEB-INF/classes and contents of the WEB-INF/lib directories of that app's WAR. And, since a WAR in the strict sense is a ZIP file, that should immediately ring the alarm that not all webapp classpath entries may be discrete filesystem paths. But, like I said, there is a classpath and I've had the questionable good fortune to have had to dissect it once or twice.

As a quick solution, I recommend invoking Class.forName on the "missing" class. You can set a debugger breakpoint there and chase into the whole sordid process.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: output a webapps classpath