Monday, November 1, 2010

JBoss 5 getResourceAsStream

Recently I was testing JSPX on JBoss 5.1.0. The first thing we encountered is the failure of getting Resource Bundles or Message Bundles.

To get to that deeply, we need to know that JSPX is accessing resource files within the WAR/EAR file. The best example on that, the jspx HTML pages themselves.

The other need to access resources when loading resource Bundle. Embedded resources inside JSPX like javascript files and images are also accessed as resources.


When we moved to JBoss 5.1.0, we discovered that JSPX pages are opened normally however the resource bundles are not.


After check the source we found out that they are using different techniques:

  1. 1. Loading the JSPX Pages located in the WebContent. They are loaded using the Servlet Context context.getResourceAsStream(resourceName);
  2. The embedded resources and bundles are loaded by
    asResourceUtility.class.getResourceAsStream(resourceName);



And this used to work on JBoss 4.2.2 but now it is no on JBoss 5.1.0. we simply tried to use the servlet context to load everything, but it did not work for jspx embedded reources as they are inside the jspx jar.


It seems that JBoss separates the classpath of the loaded jars and web app. so using context to load embedded resources did not work. so it had to stay as it is. and the resource bundles to be loaded by servlet context.





7 comments: