Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-17 Thread Ivan Novick



Oh i get it, the servlet can call the session bean 
to get the value from the resource.  
 
Thanks, Ivan

  - Original Message - 
  From: 
  Lorenzo 
  Resta 
  To: [EMAIL PROTECTED] 
  
  Sent: Tuesday, July 17, 2001 8:21 
AM
  Subject: Re: [JBoss-user] Setting & 
  Accessing Resource Files in JBoss
  Ivan,I have tried to do that, but since i don't know 
  how to get to the EAR's classloader, i didn't succeed with loading the 
  resource from the EAR. I finally decided toload it exlusively from the 
  bean and provide a method like loadResource() and storeResource(...) in 
  that bean, so that i can have access to the same resources from wherever i 
  want.Hope that helps ...CheersLorenzoIvan 
  Novick wrote:
  000a01c10ecb$a39c1630$62a637d8@novick" type="cite">

I see.  Is there any way to set 
up one resource that can be accessed both by an EJB and a web 
application?  For example can you locate the resource in the EAR file 
and load it from both places?
 
Thank you for your help,
Ivan

  - 
  Original Message - 
  From: 
  Lorenzo Resta
  To: 
  [EMAIL PROTECTED]
  Sent: 
  Tuesday, July 17, 2001 12:41 AM
  Subject: 
  Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
  Hi Ivan,A resource can be anything from a config 
  file to a class. You can access a property file as well as a resource. 
  Resources don't have a specificstructure. 
  CheersLorenzoIvan Novick wrote:
  002e01c10e2a$01be0450$62a637d8@novick" 
type="cite">


Is a resource preferred to a property 
file, or are they the same thing?
 
Ivan

  - 
  Original Message - 
  From: 
  Lorenzo Resta
  To: 
  [EMAIL PROTECTED]
  Sent: 
      Monday, July 16, 2001 2:12 AM
      Subject: 
  Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
  Hi Burkard,As far as i know you should not 
  access files directly through file IO operations, or make assumptions 
  on an existing filesystemat all in EJB's. The "/" in a 
  resource name is relatively seen, the package root from the class that 
  calls the getClass().getResourceAsStream() method. This way you 
  canpackage resources with the jar and don't have to create and 
  manage external directorier (on different operating systems). The "/" 
  used in resources works for all operating systems. 
  CheersLorenzoSurfKitchen, IncBurkhard 
  Vogel wrote:
  073c01c10d43$820f8670$[EMAIL PROTECTED]" 
  type="cite">Hi,just guessing but wouln't you lookup the file from the root-dir if you use/config/ConfigFile.xml??? you are getting the string correctly, right?so the two alternatives would be using something like config/ConfigFile.xml,but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your/config to match someplace in your file structure, i.e.../conf/tomcat/ConfigFile.xml.Burkhard- Original Message -From: <[EMAIL PROTECTED]>To: <[EMAIL PROTECTED]>Sent: Saturday, July 14, 2001 1:35 AMSubject: Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
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 filefrom the source code you send me. I got the correct name and location of thefile with
theResourceName = (String)theInitialContext.lookup("java:comp/env/" +anEvironmentName);
here I can see the exact valu I gave in the deployment descriptor(/config/ConfigFile.xml), I also deployedthe file same name and in the same directory in the .jar file.
But withjava.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 haveany clue?
Jorge SuarezCommexnet Co.Medellin, Colombia
  De: Lorenzo Resta <[EMAIL PROTECTED]>Fecha: 13-Jul-2001 07:09Para: [EMAIL PROTECTED]Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBossHi,You can do something like this:First create an environment entry in your ejb-jar.xml file like:  ConfigFile  java.lang.String  /config/ConfigFile.xml   private String getResourceNameFromEnvironment(StringanEnvResourceName) throws NamingException{

   String theResourceName; InitialContext theInitialContext = new InitialContext(); theResourceName = (String)theInitialContext.lookup("java:comp/env/

Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-17 Thread jorisumu

Thaks a lot to all of you for your help! I finally made it!

I was just missing the initial '/' in the path for the resource file in the deployment 
descriptor... after correcting that detail everythin worked perfectly.

Just for the record, if anybody can use the strategy I used on this: I needed to 
access not to a single one resource file from a bean, but to several! So I defined the 
resource for this Stateless Session bean like a Properties file. Each element of the 
list in there is a pair of the form ([RESOURCE-NAME]=[PATH]) so now I can load every 
single file from that list accessing first to the .properties file, get the path I 
need at one moment, and load it. That way I don´t need to define every single file as 
an !!

Thanks again!
Bye!

Jorge Suarez
Commexnet Co.
Medellin, Colombia


> 
> De: Lorenzo Resta <[EMAIL PROTECTED]>
> Fecha: 17-Jul-2001 11:21
> Para: [EMAIL PROTECTED]
> Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
> 
> Ivan,
> 
> I have tried to do that, but since i don't know how to get to the EAR's 
> classloader, i didn't succeed with loading the resource from the EAR. I 
> finally decided to
> load it exlusively from the bean and provide a method like 
> loadResource() and storeResource(...) in that bean, so that i can 
> have access to the same resources from wherever i want.
> 
> Hope that helps ...
> 
> Cheers
> 
> Lorenzo
> 
> Ivan Novick wrote:
> 
> > I see.  Is there any way to set up one resource that can be accessed 
> > both by an EJB and a web application?  For example can you locate the 
> > resource in the EAR file and load it from both places?
> >
> >  
> >
> > Thank you for your help,
> >
> > Ivan
> >
> > - Original Message -
> >
> > From: Lorenzo Resta <mailto:[EMAIL PROTECTED]>
> >
> > To: [EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>
> >
> > Sent: Tuesday, July 17, 2001 12:41 AM
> >
> > Subject: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
> >
> >
> > Hi Ivan,
> >
> > A resource can be anything from a config file to a class. You can
> > access a property file as well as a resource. Resources don't have
> > a specific
> > structure.
> >
> > Cheers
> >
> > Lorenzo
> >
> > Ivan Novick wrote:
> >
> >> Is a resource preferred to a property file, or are they the same
> >>     thing?
> >>
> >>  
> >>
> >> Ivan
> >>
> >> - Original Message -
> >>
> >> From: Lorenzo Resta <mailto:[EMAIL PROTECTED]>
> >>
> >> To: [EMAIL PROTECTED]
> >> <mailto:[EMAIL PROTECTED]>
> >>
> >> Sent: Monday, July 16, 2001 2:12 AM
> >>
> >> Subject: Re: [JBoss-user] Setting & Accessing Resource Files
> >> in JBoss
> >>
> >>
> >> Hi Burkard,
> >>
> >> As far as i know you should not access files directly through
> >> file IO operations, or make assumptions on an existing filesystem
> >> at all in EJB's.
> >> The "/" in a resource name is relatively seen, the package
> >> root from the class that calls the
> >> getClass().getResourceAsStream() method. This way you can
> >> package resources with the jar and don't have to create and
> >> manage external directorier (on different operating systems).
> >> The "/" used in resources works for all operating systems.
> >>
> >> Cheers
> >>
> >> Lorenzo
> >>
> >>     SurfKitchen, Inc
> >>
> >>         Burkhard Vogel wrote:
> >>
> >>>Hi,
> >>>just guessing but wouln't you lookup the file from the root-dir if you use
> >>>/config/ConfigFile.xml??? you are getting the string correctly, right?
> >>>so the two alternatives would be using something like config/ConfigFile.xml,
> >>>but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your
> >>>/config to match someplace in your file structure, i.e.
> >>>../conf/tomcat/ConfigFile.xml.
> >>>Burkhard
> >>>- Original Message -
> >>>From: <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]>
> >>>To: <[EMAIL PROTECTED]> <mail

Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-17 Thread Lorenzo Resta



Ivan,

I have tried to do that, but since i don't know how to get to the EAR's classloader,
i didn't succeed with loading the resource from the EAR. I finally decided
to
load it exlusively from the bean and provide a method like loadResource()
and storeResource(...) in that bean, so that i can have access to the
same resources from wherever i want.

Hope that helps ...

Cheers

Lorenzo

Ivan Novick wrote:
000a01c10ecb$a39c1630$62a637d8@novick">
  
  I see.  Is there any way to set up one
 resource that can be accessed both by an EJB and a web application?  For
 example can you locate the resource in the EAR file and load it from both
 places?
   
  Thank you for your help,
  Ivan
  

- Original Message - 

From:
LorenzoResta

To:
[EMAIL PROTECTED]

Sent: Tuesday, July 17, 2001 12:41    AM
    
Subject: Re: [JBoss-user] Setting &    Accessing Resource Files in
JBoss


Hi Ivan,

A resource can be anything from a config fileto a class. You can access
a property file as well as a resource. Resourcesdon't have a specific
structure. 

Cheers

Lorenzo

IvanNovick wrote:
002e01c10e2a$01be0450$62a637d8@novick" type="cite">
  
  
  Is a resource preferred to a property
 file, or are they the same thing?
   
  Ivan
  

-Original Message - 

From:
Lorenzo Resta

To:
[EMAIL PROTECTED]

Sent:Monday, July 16, 2001 2:12 AM
    
Subject:    Re: [JBoss-user] Setting & Accessing Resource Files
in JBoss


Hi Burkard,

As far as i know you should not accessfiles directly through file
IO operations, or make assumptions on anexisting filesystem
at all in EJB's. 
The "/" in a resource name isrelatively seen, the package root from
the class that calls thegetClass().getResourceAsStream() method.
This way you can
packageresources with the jar and don't have to create and manage
externaldirectorier (on different operating systems). The "/" used
in resourcesworks for all operating systems.

Cheers

Lorenzo

SurfKitchen, Inc

BurkhardVogel wrote:
073c01c10d43$820f8670$[EMAIL PROTECTED]" type="cite">Hi,just guessing but wouln't you lookup the file from the root-dir if you use/config/ConfigFile.xml??? you are getting the string correctly, right?so the two alternatives would be using something like config/ConfigFile.xml,but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your/config to match someplace in your file structure, i.e.../conf/tomcat/ConfigFile.xml.Burkhard- Original Message -From: <[EMAIL PROTECTED]>To: <[EMAIL PROTECTED]>Sent: Saturday, July 14, 2001 1:35 AMSubject: Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
  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 thefile with
theResourceName = (String)theInitialContext.lookup("java:comp/env/" +
  
  anEvironmentName);
  here I can see the exact valu I gave in the deployment descriptor

(/config/ConfigFile.xml), I also deployedthe file same name and in the same directory in the .jar file.
But withjava.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 SuarezCommexnet Co.Medellin, Colombia
De: Lorenzo Resta <[EMAIL PROTECTED]>Fecha: 13-Jul-2001 07:09Para: [EMAIL PROTECTED]Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBossHi,You can do something like this:First create an environment entry in your ejb-jar.xml file like:  ConfigFile  java.lang.String  /config/ConfigFile.xml   private String getResourceNameFromEnvironment(String
  
  
  anEnvResourceName) throws NamingException{
  
 String theResourceName; InitialContext theInitialContext = new InitialContext(); theResourceName = (String)theInitialContext.lookup("java:comp/env/"
  
   

Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-17 Thread Ivan Novick



I see.  Is there any way to set up one 
resource that can be accessed both by an EJB and a web application?  For 
example can you locate the resource in the EAR file and load it from both 
places?
 
Thank you for your help,
Ivan

  - Original Message - 
  From: 
  Lorenzo 
  Resta 
  To: [EMAIL PROTECTED] 
  
  Sent: Tuesday, July 17, 2001 12:41 
  AM
  Subject: Re: [JBoss-user] Setting & 
  Accessing Resource Files in JBoss
  Hi Ivan,A resource can be anything from a config file 
  to a class. You can access a property file as well as a resource. Resources 
  don't have a specificstructure. CheersLorenzoIvan 
  Novick wrote:
  002e01c10e2a$01be0450$62a637d8@novick" type="cite">



Is a resource preferred to a property 
file, or are they the same thing?
 
Ivan

  - 
  Original Message - 
  From: 
  Lorenzo Resta
  To: 
  [EMAIL PROTECTED]
  Sent: 
  Monday, July 16, 2001 2:12 AM
  Subject: 
      Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
  Hi Burkard,As far as i know you should not access 
  files directly through file IO operations, or make assumptions on an 
  existing filesystemat all in EJB's. The "/" in a resource name is 
  relatively seen, the package root from the class that calls the 
  getClass().getResourceAsStream() method. This way you canpackage 
  resources with the jar and don't have to create and manage external 
  directorier (on different operating systems). The "/" used in resources 
  works for all operating systems. 
  CheersLorenzoSurfKitchen, IncBurkhard 
  Vogel wrote:
  073c01c10d43$820f8670$[EMAIL PROTECTED]" 
  type="cite">Hi,just guessing but wouln't you lookup the file from the root-dir if you use/config/ConfigFile.xml??? you are getting the string correctly, right?so the two alternatives would be using something like config/ConfigFile.xml,but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your/config to match someplace in your file structure, i.e.../conf/tomcat/ConfigFile.xml.Burkhard- Original Message -From: <[EMAIL PROTECTED]>To: <[EMAIL PROTECTED]>Sent: Saturday, July 14, 2001 1:35 AMSubject: Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
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 filefrom the source code you send me. I got the correct name and location of thefile with
theResourceName = (String)theInitialContext.lookup("java:comp/env/" +anEvironmentName);
here I can see the exact valu I gave in the deployment descriptor(/config/ConfigFile.xml), I also deployedthe file same name and in the same directory in the .jar file.
But withjava.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 haveany clue?
Jorge SuarezCommexnet Co.Medellin, Colombia
  De: Lorenzo Resta <[EMAIL PROTECTED]>Fecha: 13-Jul-2001 07:09Para: [EMAIL PROTECTED]Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBossHi,You can do something like this:First create an environment entry in your ejb-jar.xml file like:  ConfigFile  java.lang.String  /config/ConfigFile.xml   private String getResourceNameFromEnvironment(StringanEnvResourceName) 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);

 }CheersLorenzoSurfKitchen Inc.[EMAIL PROTECTED] wrote:
Hi to all!I´m almost a newbye to JBoss (and even to J2EE development). I havesome issues to be covered in the project we are developing, many of them aimto 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 accessregular files from a EJB according to the J2EE specs, I need to know if it´spossible to deploy a kind of "resource" file wich can hold my data andaccess it trought the context or something like that.

  
If this is possible What´s the how 

Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-17 Thread Lorenzo Resta



Hi Ivan,

A resource can be anything from a config file to a class. You can access
a property file as well as a resource. Resources don't have a specific
structure. 

Cheers

Lorenzo

Ivan Novick wrote:
002e01c10e2a$01be0450$62a637d8@novick">
  
  
  Is a resource preferred to a property
file, or  are they the same thing?
   
  Ivan
  

- Original Message - 

From:
LorenzoResta

To:
[EMAIL PROTECTED]

Sent: Monday, July 16, 2001 2:12 AM
    
Subject: Re: [JBoss-user] Setting &Accessing Resource Files in
JBoss


Hi Burkard,

As far as i know you should not access filesdirectly through file IO
operations, or make assumptions on an existingfilesystem
at all in EJB's. 
The "/" in a resource name is relativelyseen, the package root from the
class that calls thegetClass().getResourceAsStream() method. This way
you can
package resourceswith the jar and don't have to create and manage external
directorier (ondifferent operating systems). The "/" used in resources
works for alloperating systems. 

Cheers

Lorenzo

SurfKitchen,Inc

Burkhard Vogel wrote:
073c01c10d43$820f8670$[EMAIL PROTECTED]" type="cite">Hi,just guessing but wouln't you lookup the file from the root-dir if you use/config/ConfigFile.xml??? you are getting the string correctly, right?so the two alternatives would be using something like config/ConfigFile.xml,but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your/config to match someplace in your file structure, i.e.../conf/tomcat/ConfigFile.xml.Burkhard- Original Message -From: <[EMAIL PROTECTED]>To: <[EMAIL PROTECTED]>Sent: Saturday, July 14, 2001 1:35 AMSubject: Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
  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 thefile with
theResourceName = (String)theInitialContext.lookup("java:comp/env/" +
  
  anEvironmentName);
  here I can see the exact valu I gave in the deployment descriptor

(/config/ConfigFile.xml), I also deployedthe file same name and in the same directory in the .jar file.
But withjava.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 SuarezCommexnet Co.Medellin, Colombia
De: Lorenzo Resta <[EMAIL PROTECTED]>Fecha: 13-Jul-2001 07:09Para: [EMAIL PROTECTED]Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBossHi,You can do something like this:First create an environment entry in your ejb-jar.xml file like:  ConfigFile  java.lang.String  /config/ConfigFile.xml   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);
  
   }CheersLorenzoSurfKitchen 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 aimto be solved with having access to a repository and "read" data from there.

   

Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-16 Thread Ivan Novick



Is a resource preferred to a property file, or 
are they the same thing?
 
Ivan

  - Original Message - 
  From: 
  Lorenzo 
  Resta 
  To: [EMAIL PROTECTED] 
  
  Sent: Monday, July 16, 2001 2:12 AM
  Subject: Re: [JBoss-user] Setting & 
  Accessing Resource Files in JBoss
  Hi Burkard,As far as i know you should not access files 
  directly through file IO operations, or make assumptions on an existing 
  filesystemat all in EJB's. The "/" in a resource name is relatively 
  seen, the package root from the class that calls the 
  getClass().getResourceAsStream() method. This way you canpackage resources 
  with the jar and don't have to create and manage external directorier (on 
  different operating systems). The "/" used in resources works for all 
  operating systems. CheersLorenzoSurfKitchen, 
  IncBurkhard Vogel wrote:
  073c01c10d43$820f8670$[EMAIL PROTECTED]" 
  type="cite">Hi,just guessing but wouln't you lookup the file from the root-dir if you use/config/ConfigFile.xml??? you are getting the string correctly, right?so the two alternatives would be using something like config/ConfigFile.xml,but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your/config to match someplace in your file structure, i.e.../conf/tomcat/ConfigFile.xml.Burkhard- Original Message -From: <[EMAIL PROTECTED]>To: <[EMAIL PROTECTED]>Sent: Saturday, July 14, 2001 1:35 AMSubject: Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
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 filefrom the source code you send me. I got the correct name and location of thefile with
theResourceName = (String)theInitialContext.lookup("java:comp/env/" +anEvironmentName);
here I can see the exact valu I gave in the deployment descriptor(/config/ConfigFile.xml), I also deployedthe file same name and in the same directory in the .jar file.
But withjava.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 haveany clue?
Jorge SuarezCommexnet Co.Medellin, Colombia
  De: Lorenzo Resta <[EMAIL PROTECTED]>Fecha: 13-Jul-2001 07:09Para: [EMAIL PROTECTED]Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBossHi,You can do something like this:First create an environment entry in your ejb-jar.xml file like:  ConfigFile  java.lang.String  /config/ConfigFile.xml   private String getResourceNameFromEnvironment(StringanEnvResourceName) 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);

 }CheersLorenzoSurfKitchen Inc.[EMAIL PROTECTED] wrote:
Hi to all!I´m almost a newbye to JBoss (and even to J2EE development). I havesome issues to be covered in the project we are developing, many of them aimto 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 accessregular files from a EJB according to the J2EE specs, I need to know if it´spossible to deploy a kind of "resource" file wich can hold my data andaccess it trought the context or something like that.

  
If this is possible What´s the how to? Where can I finddocumentation about it? Any alternative?

  
Thanks a lot!!Jorge SuarezCommexnet 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--
  

Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-16 Thread Burkhard Vogel

Yup, thanks for correction. Burkhard
- Original Message - 
From: "Lorenzo Resta" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 16, 2001 11:12 AM
Subject: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss


Hi Burkard,

As far as i know you should not access files directly through file IO 
operations, or make assumptions on an existing filesystem
at all in EJB's.
The "/" in a resource name is relatively seen, the package root from the 
class that calls the getClass().getResourceAsStream() method. This way 
you can
package resources with the jar and don't have to create and manage 
external directorier (on different operating systems). The "/" used in 
resources works for all operating systems.

Cheers

Lorenzo

SurfKitchen, Inc



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



Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-16 Thread Lorenzo Resta



Hi Burkard,

As far as i know you should not access files directly through file IO operations,
or make assumptions on an existing filesystem
at all in EJB's. 
The "/" in a resource name is relatively seen, the package root from the
class that calls the getClass().getResourceAsStream() method. This way you
can
package resources with the jar and don't have to create and manage external
directorier (on different operating systems). The "/" used in resources works
for all operating systems. 

Cheers

Lorenzo

SurfKitchen, Inc

Burkhard Vogel wrote:
073c01c10d43$820f8670$[EMAIL PROTECTED]">Hi,just guessing but wouln't you lookup the file from the root-dir if you use/config/ConfigFile.xml??? you are getting the string correctly, right?so the two alternatives would be using something like config/ConfigFile.xml,but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your/config to match someplace in your file structure, i.e.../conf/tomcat/ConfigFile.xml.Burkhard- Original Message -From: <[EMAIL PROTECTED]>To: <[EMAIL PROTECTED]>Sent: Saturday, July 14, 2001 1:35 AMSubject: Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss
  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 thefile with
theResourceName = (String)theInitialContext.lookup("java:comp/env/" +
  
  anEvironmentName);
  here I can see the exact valu I gave in the deployment descriptor

(/config/ConfigFile.xml), I also deployedthe file same name and in the same directory in the .jar file.
But withjava.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 SuarezCommexnet Co.Medellin, Colombia
De: Lorenzo Resta <[EMAIL PROTECTED]>Fecha: 13-Jul-2001 07:09Para: [EMAIL PROTECTED]Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBossHi,You can do something like this:First create an environment entry in your ejb-jar.xml file like:  ConfigFile  java.lang.String  /config/ConfigFile.xml   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);
  
   }CheersLorenzoSurfKitchen 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 aimto 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´spossible to deploy a kind of "resource" file wich can hold my data andaccess it trought the context or something like that.
  

  If this is possible What´s the how to? Where can I find


   

Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-16 Thread Lorenzo Resta



Hi Jorge,

Your class is probably not finding the resource. The directory "/config"
has also to exist in the jar.

It really depends from which class you call the getClass().getResourceAsStream()
method. 
The classloader tries to load relative or absolute (depending if you add
a "/" or not in front of the resource path)  from the package location of
the class that calls
the getClass().getResourceAsStream() method. For example : if you make the
getClass().getResourceAsStream() call from your EJB class, then the classloader
tries to
load the resource from the jar that contains the beans. 

If you call the getClass().getResourceAsStream() within a servlet/servlet,
you have to deploy the resource within the Web Archiv.

In my case for example i have following deployment structure:

application.ear
 --META-INF
     --application.xml
 --application.jar <-- This is the jar that contains the ejb-classes
     --META-INF
         --ejb-jar.xml
         --jboss.xml
     --config  <-- This is the directory that contains the resource
         - config.xml <-- this is the resource itself
     --com 
         -- The rest of my ejb-classes
 --application.war


In my stateless session bean i do following:

  private String getConfigurationFilename() throws NamingException{
    String theSearchConfigurationFilename;
    InitialContext theInitialContext = new InitialContext();

    theSearchConfigurationFilename = (String)theInitialContext.lookup("java:comp/env/ConfigFile");

    return theSearchConfigurationFilename;
  }

  private void configure() throws ConfigurationException, RemoteException{
 try{
    myConfigurationResourceName = getConfigurationFilename(); 
    log("configure() : trying to load configuration from " + getClass().getResource(myConfigurationResourceName).getFile());
    java.io.InputStream aConfigStream = getClass().getResourceAsStream(myConfigurationResourceName);
        .
        .
 }catch(Exception anException){
   throw new EJBException(anException);
 }
  }

I hope, that this helps you solving the problem

Cheers

Lorenzo

[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED]">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 withtheResourceName = (String)theInitialContext.lookup("java:comp/env/" + anEvironmentName);here I can see the exact valu I gave in the deployment descriptor (/config/ConfigFile.xml), I also deployed the file same name and in the same directory in the .jar file.But withjava.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 SuarezCommexnet Co.Medellin, Colombia 
  De: Lorenzo Resta <[EMAIL PROTECTED]>Fecha: 13-Jul-2001 07:09Para: [EMAIL PROTECTED]Asunto: Re: [JBoss-user] Setting & Accessing Resource Files in JBossHi,You can do something like this:First create an environment entry in your ejb-jar.xml file like:  ConfigFile  java.lang.String  /config/ConfigFile.xml   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);   }CheersLorenzoSurfKitchen 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 SuarezCommexnet 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
  
  _

Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-15 Thread Burkhard Vogel

Hi,
just guessing but wouln't you lookup the file from the root-dir if you use
/config/ConfigFile.xml??? you are getting the string correctly, right?
so the two alternatives would be using something like config/ConfigFile.xml,
but I think that will be JBOSS_HOME/bin/config/ConfigFile.xml of suit your
/config to match someplace in your file structure, i.e.
../conf/tomcat/ConfigFile.xml.
Burkhard
- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, July 14, 2001 1:35 AM
Subject: Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss


> 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
(/config/ConfigFile.xml), 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:
> >
> > 
> >   ConfigFile
> >   java.lang.String
> >   /config/ConfigFile.xml
> > 
> >
> >
> >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


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



Re: Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-13 Thread jorisumu

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 
(/config/ConfigFile.xml), 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:
> 
> 
>   ConfigFile
>   java.lang.String
>   /config/ConfigFile.xml
> 
> 
> 
>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



Re: [JBoss-user] Setting & Accessing Resource Files in JBoss

2001-07-13 Thread Lorenzo Resta

Hi,

You can do something like this:

First create an environment entry in your ejb-jar.xml file like:


  ConfigFile
  java.lang.String
  /config/ConfigFile.xml



   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