users@glassfish.java.net

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

From: Sahoo <sanjeeb.sahoo_at_oracle.com>
Date: Fri, 17 May 2013 06:54:11 +0530

I would expect the original code to work.

Sahoo

Sent from my Android phone, please excuse me for its brevity.

-----Original Message-----
From: Marina Vatkina [marina.vatkina_at_oracle.com]
Received: Friday, 17 May 2013, 4:48
To: users_at_glassfish.java.net [users_at_glassfish.java.net]
CC: Coarr, Matt [mcoarr_at_mitre.org]
Subject: Re: problem startup singleton deployed in webapp can't load resource in WEB-INF/classes

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