Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

output a webapps classpath

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to output (to stdout or logs) the classpath for a webapp?

thanks!
 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's back up a step: why would you want to do that?
 
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
David Sheltby
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears you spelled the name of that directory wrong. It should be "WEB-INF/classes", not "web-inf/classes".
 
Bear Bibeault
Sheriff
Posts: 67269
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 20842
125
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!