Search code examples
jakarta-eeglassfish-3ear

Read property file resides in /ear/war from ear/lib/*.jar


I’m migrating application from glassfish 2 to glassfish 3, following issue were encountered.

I have war file with property file and it reads from common property loading jar, which reads like PropUtil.class.getResourceAsStream(‘/my.properties’).

In glassfish 2 I was able to read the property file without any issues, however, when I migrated to glassfish 3 it can’t find the property file.

Did some debugging and found out that Glassfish 2 loads the property using EJBClassLoader while glassfish 3 loads using EarLibClassLoader.

Can I read a property file inside a war from a jar inside ear/lib in glassfish3/jee6?

Ear structure

enter image description here


Solution

  • You was relying on a bug in GlassFish2.

    Classes in EAR/lib and EJB are never supposed to be able to access resources in WAR. It's only allowed the other way round.

    Redesign your approach. Either move that common library into WAR/WEB-INF/lib. Or, move that properties file into EAR/lib.