Announcement Announcement Module
Collapse
No announcement yet.
ClassPathResource - JUnit\Servlet Usage\Eclipse Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ClassPathResource - JUnit\Servlet Usage\Eclipse

    I am confused by how the ClassPathResource should work. I am new to Java\Spring so I supposed I shouldn't be surprised .

    When I am in Eclipse and I run a JUnit test, I can get to an app.properties files somewhere in the classpath.

    Code:
    // in Exclipse\JUnit
    Resource res = new ClassPathResource("app.properties")
    // Will find file somewhere in classpath (its not in the root)

    When I am in Eclipse and I use auto-deploy a servlet to a configured server (glassfish), I use the same code and it doesn't find the file.

    In the servlet context I actually put the app.properties, in WEB-INF/classes/config just to ensure that I KNOW it is in the classpath. If I explicity say new ClassPathResource("/config/app.properties"). It finds the file.

    So, in the JUnit type context, it appears the ClassPathResource probes the classpath context, in the eclipse, servlet context it does not appear to probe the classpath, it just looks at the root (if I just give it a name).

    1) Is the eclipse servlet context just a pseudo servlet thing that doesn't reflect reality and noboby really uses?
    2) Could this be a eclipse\glassfish thing?
    3) Am I properly understanding that the ClassPathResource probes the ClassPath looking for the file?

    Thanks,
    jeff
    Last edited by jjarrel; Sep 2nd, 2007, 02:41 PM. Reason: wasn't finished

  • #2
    Never mind. I figured it out. I was not understanding how the use of the ClassPathResource.

    I am SOooo lame.

    jeff

    Comment

    Working...
    X