• Post Reply Bookmark Topic Watch Topic
  • New Topic

File Not found Exception in EJB

 
Ravi Verma
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,
I have Ejb application(not war and ear) which deployed into weblogic 7.0. I acces a properties file in the Bean class and i packaged it in the ejb jar file but when i run it complains the properties file not found.
All the ejb-jar.xml,weblogic-ejb-jar.xml are fine.
Any suggestions why the file is not found by Bean?
Thanks in advance
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you posted the piece of code you're using to read the properties file...
 
Ravi Verma
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Here it is...
File file = new File( filename );
Reader rdr = new FileReader( file );
long sz = file.length();
// can only read in things of MAXINT length
char[] ch = new char[(int)sz];
rdr.read(ch);
rdr.close();
String s = new String(ch);

Thanks
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. What are you providing as 'filename' if your .properties file is inside the .jar file?
The way to access the .property file within the .jar file is the following:where 'propertyFile' is the path to the .properties file relative to the .jar file's root.
 
Ravi Verma
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the bean am loading is a XML SCHEMA(MODEL.XSD) file and i bundled it in the root of jar.
So what i am trying to do is read this schema file in the bean and do some xml work.. but as u know i am getting the exception of file not found. I am not sure the properties will work for this.
Any alternative?
Thanks
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I assumed you needed to read a .properties file because that's what you were talking about in the original post. Anyway, the type of the file doesn't matter--you can still read it with the getResourceAsStream() method.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!