• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Get Root Context in Session Bean

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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,
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic