Skip to main content

problem startup singleton deployed in webapp can't load resource in WEB-INF/classes

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
mattcoarr
Offline
Joined: 2003-06-13
Points: 0

Hello,

I'm having trouble where I have a webapp that I am deploying to glassfish 3.1.

I've added a startup singleton to do some initialization and keep configuration values.

This startup singleton ejb class attempts to load a resource via (this is called in the method annotated with @PostConstruct)

this.getClass().getClassLoader().getResourceAsStream("myfile.xml")

However, this always returns null. The file myfile.xml is located in WEB-INF/classes/myfile.xml.

Any ideas?

Thanks!
Matt

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mvatkina
Offline
Joined: 2005-04-04
Points: 0

The bean class is loaded by the container class loader. Try using
context CL.

-marina

On 5/16/13 3:52 PM, Coarr, Matt wrote:
> Hello,
>
> I'm having trouble where I have a webapp that I am deploying to
> glassfish 3.1.
>
> I've added a startup singleton to do some initialization and keep
> configuration values.
>
> This startup singleton ejb class attempts to load a resource via (this
> is called in the method annotated with @PostConstruct)
>
>
> this.getClass().getClassLoader().getResourceAsStream("myfile.xml")
>
> However, this always returns null. The file myfile.xml is located in
> WEB-INF/classes/myfile.xml.
>
> Any ideas?
>
> Thanks!
> Matt