Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do you read a resource from the root of an exploded webapp?

 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a localhost JBoss 6 setup with JBoss Tools and Eclipse doing the hot deploy of an exploded webapp. I used to launch my webapp via shell using main class with an explicit classpath (exploded and JAR) and deploy normally via WAR file. My resource loader used to work perfectly, but now since the webapp is on JBoss in an exploded directory structure with an "unknown" classpath, text file resources like "/db/jpql/whatever.jpql" aren't found (null is returned, leading to an NPE).

The question is:

How do you load resources from the root (or outside of the WEB-INF dir) of an exploded webapp (in JBoss)? I checked the classpath which is nothing but C:\dev\jboss\bin\run.jar...

Karsten
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The WEB-INF/classes directory, and the JARs in WEB-INF/lib, are in the classpath. If you want to access things within the WAR outside of that, use ServletContext.getRealPath()
 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate MySQL Database Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There was a coding error in my sources. The resource strings weren't prefixed with a slash - doh! It's working now.

Karsten
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The resource strings weren't prefixed with a slash

That one always bites me too - I can never seem to remember when I need a slash and when I shouldn't use one. Glad you got it working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic