Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the classpath default to the WEB-INF/classes/ instead of WEB-INF/ in JBoss 5.1?

I have a piece of code that get's the spring context using

context =  new ClassPathXmlApplicationContext("application-context.xml");

The file is located inside the WAR's "WEB-INF/application-context.xml" In JBoss 4.2.3, the above code works fine. In JBoss 5.1, after experimenting, it seems to expect the file to be in "WEB-INF/classes/application-context.xml". And after shifting the file there it works.

I also googled around saw lots of references to how the VFS messes with Spring's classpath or something..

like image 231
Rivendell Avatar asked Feb 26 '23 20:02

Rivendell


1 Answers

The WEB-INF directory itself is not supposed to be on the classpath. If that was working on JBoss 4.x, then it must've been specifically configured to do so.

WEB-INF/classes, on the other hand, is on the standard classpath. This is the correct place for the file to go.

JBoss 5.x doesn't mess around with Spring in the way that you're suggesting. It did, however, tighten up some loose behaviour present in JBoss 4.x, and this may be an example of this.

like image 83
skaffman Avatar answered Apr 27 '23 02:04

skaffman