Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within JBoss/WildFly
Search Coderanch
Advance search
Google search
Register / Login
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
Forum:
JBoss/WildFly
jndi for ejb on jboss
Suma Rangaraj
Ranch Hand
Posts: 50
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all,
Please let me know how to give a jndi name for
jboss
4.0.1. I am trying to access teh
ejb
by its context name but it returns a null pointer exception. Thank you !
Below is the code -
try { Context ic = new InitialContext(); Object obj = ic.lookup("myjndi"); home = (EJBHome) PortableRemoteObject.narrow(obj, EJBHome.class); }catch(Exception ex){ ex.printStackTrace(); }
Anuja Piplapure
Greenhorn
Posts: 7
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
To access or look up any EJB, one would have to use the jndi-name mentioned in the jboss.xml file.
<?xml version="1.0" encoding="UTF-8"?> <jboss> <enterprise-beans> <entity> <ejb-name>MyEJB</ejb-name> <jndi-name>MyEJBjndi</jndi-name> <local-jndi-name>MyEJBlocaljndi</local-jndi-name> </entity> <secure>false</secure> </enterprise-beans> </jboss>
Use the jndi-name or local-jndi-name given in the jboss.xml file to look up ur bean.
InitialContext ctx = getInitialContext(); // Object ref = ctx.lookup("MyEJBjndi"); MyEJBHome hm = (MyEJBHome) PortableRemoteObject.narrow(ref,MyEJBHome.class);
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Problem in JNDI lookup
Getting NullPointerException while accessing Local EJB
EJB access issue
InitialContext.lookup and narrow malfunctioning
problem in acessing session bean using jndi
More...