• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to Get Root Context in Session Bean  RSS feed

 
sridhar vu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I'm trying to get the Root context in a Stateless Session Bean. I need to pass an XML file located in the root dir (SampleEjb.jar/axis2.xml). My test code..

@Stateless
public class TestBean implements TestBeanRemote {
public static final String RemoteJNDIName = TestBean.class.getSimpleName() + "/remote";

public void test() {
System.out.println("Hello World !");
sampleMethod("C:\\axis2\\conf\\axis2.xml");
}
}

currently it works fine with the absolute path. "C:\\axis2\\conf\\axis2.xml"

I'm running EJB3 on JBoss4.0.4.GA

Any help in this regard is appreciated.

Thanks,
Sridhar.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Add a name: value (confURL=C: \axis2\conf\) pair in your ear.properties file, if you have one. Otherwise you can add it to the properties file you have.

2. In you application utility class, add method which will read property file give you a value, if you pass the name.

3. Call this method in your Bean class, were ever you need this value.


HTH,
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to pass an XML file located in the root dir (SampleEjb.jar/axis2.xml)


How about:

 
sridhar vu
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks JaiKiran and Prabhu for your responses.
getResource() method did help me to get the files but getting a null pointer exception while creating a ConfigurationContext in Axis2. so, I think I'll go with creating a properties file, take out the config file from the EJB Jar and put it some where on the File System and read it.

Thanks,
Sridhar.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!