Wow, Thanks a lot Lorenzo... Now I have better hopes!

I still have some Issues with this:

I made it to code and deploy a Session bean that access to a resource file from the 
source code you send me. I got the correct name and location of the file with

theResourceName = (String)theInitialContext.lookup("java:comp/env/" + 
anEvironmentName);

here I can see the exact valu I gave in the deployment descriptor 
(<env-entry-value>/config/ConfigFile.xml</env-entry-value>), I also deployed the file 
same name and in the same directory in the .jar file.

But with

java.io.InputStream theInputStream = getClass().getResourceAsStream(theResourceName);

I allways get null!! :( (of course I can�t read the Stream afterwards, then I get the 
NullPointerException)

I�ve been working around with this, but nothing helped. Do you guys have any clue?

Jorge Suarez
Commexnet Co.
Medellin, Colombia 

> 
> De: Lorenzo Resta <[EMAIL PROTECTED]>
> Fecha: 13-Jul-2001 07:09
> Para: [EMAIL PROTECTED]
> Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
> 
> Hi,
> 
> You can do something like this:
> 
> First create an environment entry in your ejb-jar.xml file like:
> 
> <env-entry>
>   <env-entry-name>ConfigFile</env-entry-name>
>   <env-entry-type>java.lang.String</env-entry-type>
>   <env-entry-value>/config/ConfigFile.xml</env-entry-value>
> </env-entry>
> 
> 
>    private String getResourceNameFromEnvironment(String anEnvResourceName) throws 
>NamingException{
>      String theResourceName;
>      InitialContext theInitialContext = new InitialContext();
> 
>      theResourceName = (String)theInitialContext.lookup("java:comp/env/" + 
>anEvironmentName);
> 
>      return theResourceName;
>    }
> 
>    private void loadResource(String aEnvResourceName){
>      String theResourceName = getResourceNameFromEnvironment(aEnvResourceName);
>      java.io.InputStream theInputStream = 
>getClass().getResourceAsStream(theResourceName);
>    }
> 
> Cheers
> 
> 
> Lorenzo
> 
> SurfKitchen Inc.
> 
> 
> [EMAIL PROTECTED] wrote:
> 
> > Hi to all!
> > I�m almost a newbye to JBoss (and even to J2EE development). I have some issues to 
>be covered in the project we are developing, many of them aim to be solved with 
>having access to a repository and "read" data from there.
> > 
> > Since we don�t want to use the database for that and we cannot access regular 
>files from a EJB according to the J2EE specs, I need to know if it�s possible to 
>deploy a kind of "resource" file wich can hold my data and access it trought the 
>context or something like that.
> > 
> > If this is possible.... What�s the how to? Where can I find documentation about 
>it? Any alternative?
> > 
> > Thanks a lot!!
> > Jorge Suarez
> > Commexnet Co.
> > Medellin, Colombia 
> > 
> > ------------------------------------------------------------------------------
> > 
> > Obt�n gratis tu cuenta de correo en StarMedia Email.
> > �Reg�strate hoy mismo!. http://www.starmedia.com/email
> > 
> > ------------------------------------------------------------------------------
> > 
> > 
> > 
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > http://lists.sourceforge.net/lists/listinfo/jboss-user
> > 
> 
> 
> 
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
> 

------------------------------------------------------------------------------

Obt�n gratis tu cuenta de correo en StarMedia Email.
�Reg�strate hoy mismo!. http://www.starmedia.com/email

------------------------------------------------------------------------------



_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to