sjhamb
asked on
javax.naming.NameNotFoundException: ejb not bound. URGENT PLEASE!!!
Hi,
I have a problem locating the home interface of an stateless session bean. The application server is JBoss. The beans seem to
deploy without errors on the app server. I have been fighting with problem for 2 days now.
Following is the code i am using
try {
Context context = new InitialContext();
Object ref = context.lookup("ejb/Lego") ;
home = (LegoHome)PortableRemoteOb ject.narro w(ref,Lego Home.class );
} catch (NamingException e) {
e.printStackTrace();
}
I have also tried using
Object ref = context.lookup("java:comp/ env/ejb/Le go");
to lookup the EJB.
The Output from server on deployment is:
[EjbModule] Deploying Lego
[StatelessSessionInstanceP ool] Started jboss.j2ee:jndiName=ejb/Le go,plugin= pool,servi ce=EJB
[StatelessSessionContainer ] Started jboss.j2ee:jndiName=ejb/Le go,service =EJB
[EjbModule] Started jboss.j2ee:module=LegoEJB. jar,servic e=EjbModul e
Contents of my jndi.properties file:
[EjbModule] Deploying Lego
[StatelessSessionInstanceP ool] Started jboss.j2ee:jndiName=ejb/Le go,plugin= pool,servi ce=EJB
[StatelessSessionContainer ] Started jboss.j2ee:jndiName=ejb/Le go,service =EJB
[EjbModule] Started jboss.j2ee:module=LegoEJB. jar,servic e=EjbModul e
Contents of application.xml are:
<application>
<display-name>My Test Application</display-name>
<module>
<ejb>LegoEJB.jar</ejb>
</module>
<module id="WarModule_1">
<web>
<web-uri>LegoWeb.war</web- uri>
<context-root>/test</conte xt-root>
</web>
</module>
<module id="EjbModule_1">
<ejb>LegoEJB.jar</ejb>
</module>
</application>
When I try to access it from Servlet I get Following Error on JBOSS Console:
javax.naming.NameNotFoundE xception: ejb not bound
at org.jnp.server.NamingServe r.getBindi ng(NamingS erver.java :495)
at org.jnp.server.NamingServe r.getBindi ng(NamingS erver.java :503)
It Seems I am messing up with some configuration problem somewhere. Please Help Urgent
Please Let me know what all do i have to configure to get this running.
I have a problem locating the home interface of an stateless session bean. The application server is JBoss. The beans seem to
deploy without errors on the app server. I have been fighting with problem for 2 days now.
Following is the code i am using
try {
Context context = new InitialContext();
Object ref = context.lookup("ejb/Lego")
home = (LegoHome)PortableRemoteOb
} catch (NamingException e) {
e.printStackTrace();
}
I have also tried using
Object ref = context.lookup("java:comp/
to lookup the EJB.
The Output from server on deployment is:
[EjbModule] Deploying Lego
[StatelessSessionInstanceP
[StatelessSessionContainer
[EjbModule] Started jboss.j2ee:module=LegoEJB.
Contents of my jndi.properties file:
[EjbModule] Deploying Lego
[StatelessSessionInstanceP
[StatelessSessionContainer
[EjbModule] Started jboss.j2ee:module=LegoEJB.
Contents of application.xml are:
<application>
<display-name>My Test Application</display-name>
<module>
<ejb>LegoEJB.jar</ejb>
</module>
<module id="WarModule_1">
<web>
<web-uri>LegoWeb.war</web-
<context-root>/test</conte
</web>
</module>
<module id="EjbModule_1">
<ejb>LegoEJB.jar</ejb>
</module>
</application>
When I try to access it from Servlet I get Following Error on JBOSS Console:
javax.naming.NameNotFoundE
at org.jnp.server.NamingServe
at org.jnp.server.NamingServe
It Seems I am messing up with some configuration problem somewhere. Please Help Urgent
Please Let me know what all do i have to configure to get this running.
Please post your ejb-jar.xml and jboss.xml files in here.
ASKER
contents of jboss.xml
<session>
<ejb-name>Lego</ejb-name>
<jndi-name>ejb/Lego</jndi- name>
</session>
Contents of ejb-jar.xml
<session>
<description><![CDATA[1st Stateless Session Bean]]></description>
<display-name>First_Statel ess_Bean</ display-na me>
<ejb-name>Lego</ejb-name>
<home>test.interfaces.Lego Home</home >
<remote>test.interfaces.Le go</remote >
<ejb-class>test.ejb.LegoBe an</ejb-cl ass>
<session-type>Stateless</s ession-typ e>
<transaction-type>Containe r</transac tion-type>
</session>
<session>
<ejb-name>Lego</ejb-name>
<jndi-name>ejb/Lego</jndi-
</session>
Contents of ejb-jar.xml
<session>
<description><![CDATA[1st Stateless Session Bean]]></description>
<display-name>First_Statel
<ejb-name>Lego</ejb-name>
<home>test.interfaces.Lego
<remote>test.interfaces.Le
<ejb-class>test.ejb.LegoBe
<session-type>Stateless</s
<transaction-type>Containe
</session>
Open your jmx console (http://localhost:8080/jmx-console) and check the JNDI service.
Run the list method of the service, to see the JNDI tree of your server. Does the Lego EJB appears there?
Run the list method of the service, to see the JNDI tree of your server. Does the Lego EJB appears there?
ASKER
I don't see anything like "list method" there ....
I can see following enteries in jmx-console under jboss.j2ee head:
jndiName=ejb/Lego,plugin=p ool,servic e=EJB
jndiName=ejb/Lego,service= EJB
module=LegoEJB.jar,service =EjbModule
and have tried using Invoke against start/ cerate etc... it works fine but still am facing this problem.
I can see following enteries in jmx-console under jboss.j2ee head:
jndiName=ejb/Lego,plugin=p
jndiName=ejb/Lego,service=
module=LegoEJB.jar,service
and have tried using Invoke against start/ cerate etc... it works fine but still am facing this problem.
It means your EJB is succesfully deployed.
Can you try:
Object ref = context.lookup("ejb/Lego") ;
Instead of your own lookup line?
Can you try:
Object ref = context.lookup("ejb/Lego")
Instead of your own lookup line?
ASKER
Have tried that ... doesn't work...
ASKER
Anyone Else ... ??
Are you using ejb-references?
Which JBoss version is that?
Which JBoss version is that?
ASKER
JBOSS Version 3.2.3
I did not get your first question though
I did not get your first question though
Are you using ejb-ref in your web.xml?
Can you access other ejbs/remote objects from your servlet? Can you access a data source for example?
I try to narrow down your problem, since the EJB is deployed, it is not clear why the name not found exception
Can you access other ejbs/remote objects from your servlet? Can you access a data source for example?
I try to narrow down your problem, since the EJB is deployed, it is not clear why the name not found exception
ASKER
No, I am not using that....i tried using that but then i get errors while deployment...
org.jboss.deployment.Deplo ymentExcep tion: Error during deploy; - nested throwable: (javax.naming.NamingExcept ion: ejb-ref: ejb/Lego, no ejb-link in web.xml and no jndi-name in jboss-web.xml)
org.jboss.deployment.Deplo
OK. Let's try another thing.
The context has a list() method. Can you print it to the screen (system.out.println, or to the output html page) and then we'll see what is defined in your context?
It returns a NamingEnumeration object, it should be easy to print.
The context has a list() method. Can you print it to the screen (system.out.println, or to the output html page) and then we'll see what is defined in your context?
It returns a NamingEnumeration object, it should be easy to print.
ASKER
I get javax.naming.NotContextExc eption at line 2
I have written following code to check what you suggested:
Context context = new InitialContext();
NamingEnumeration nE = context.list("ejb/Lego");
while(nE.hasMoreElements() ){
System.out.println(nE.toSt ring());
nE.nextElement();
}
I have written following code to check what you suggested:
Context context = new InitialContext();
NamingEnumeration nE = context.list("ejb/Lego");
while(nE.hasMoreElements()
System.out.println(nE.toSt
nE.nextElement();
}
Just context.list() without the ejb/Lego as a parameter
ASKER
list method requires a parameter.
I tried calling it like:
NamingEnumeration nE = context.list("");
Result:
[STDOUT] org.jnp.interfaces.NamingE numeration Impl@1c37b 8f
21 times on console
I tried calling it like:
NamingEnumeration nE = context.list("");
Result:
[STDOUT] org.jnp.interfaces.NamingE
21 times on console
You need to iterate the items in the enumeration.
Try this code piece, it prints the entire JNDI tree.
void printTree(Context c,Context subContext, String contextName, JspWriter out, String prefix) throws NamingException, IOException {
System.out.println(context Name);
NamingEnumeration ne = c.listBindings(contextName );
while (ne.hasMore()) {
Binding b = (Binding)ne.next();
if (b.getObject() instanceof Context) {
out.println(prefix + "<b>" + b.getName() + "<b><BR>");
printTree(subContext,(Cont ext)b.getO bject(),b. getName(), out,"--\\" + prefix);
} else {
out.println(prefix + b.getName() + "<BR>");
}
}
}
main() {
InitialContext ic = new InitialContext();
printTree(ic,ic,"",out, "");
}
Where out is an outputstream.
Try this code piece, it prints the entire JNDI tree.
void printTree(Context c,Context subContext, String contextName, JspWriter out, String prefix) throws NamingException, IOException {
System.out.println(context
NamingEnumeration ne = c.listBindings(contextName
while (ne.hasMore()) {
Binding b = (Binding)ne.next();
if (b.getObject() instanceof Context) {
out.println(prefix + "<b>" + b.getName() + "<b><BR>");
printTree(subContext,(Cont
} else {
out.println(prefix + b.getName() + "<BR>");
}
}
}
main() {
InitialContext ic = new InitialContext();
printTree(ic,ic,"",out, "");
}
Where out is an outputstream.
ASKER
I ran the code you had sent and "Lego" was there in the output.
ASKER
What Next? Any Clues?
Just lookup Lego instead of ejb/Lego, it looks like it should work.
ASKER
javax.naming.NameNotFoundE xception: Lego not bound
Can you post the entire output of the method?
ASKER
Sure, Here it is:
jmx
jmx
invoker
invoker
RMIAdaptor
rmi
rmi
RMIAdaptor
OIL2XAConnectionFactory
HTTPXAConnectionFactory
ConnectionFactory
UserTransactionSessionFact ory
HTTPConnectionFactory
XAConnectionFactory
invokers
invokers
0.0.0.0
0.0.0.0
pooled
wks_05
wks_05
jrmp
http
UserTransaction
RMIXAConnectionFactory
UILXAConnectionFactory
UIL2XAConnectionFactory
queue
queue
A
testQueue
ex
DLQ
D
C
B
topic
topic
testDurableTopic
testTopic
securedTopic
console
console
PluginManager
UIL2ConnectionFactory
UILConnectionFactory
RMIConnectionFactory
ejb
ejb
Lego
OIL2ConnectionFactory
UUIDKeyGeneratorFactory
jmx
jmx
invoker
invoker
RMIAdaptor
rmi
rmi
RMIAdaptor
OIL2XAConnectionFactory
HTTPXAConnectionFactory
ConnectionFactory
UserTransactionSessionFact
HTTPConnectionFactory
XAConnectionFactory
invokers
invokers
0.0.0.0
0.0.0.0
pooled
wks_05
wks_05
jrmp
http
UserTransaction
RMIXAConnectionFactory
UILXAConnectionFactory
UIL2XAConnectionFactory
queue
queue
A
testQueue
ex
DLQ
D
C
B
topic
topic
testDurableTopic
testTopic
securedTopic
console
console
PluginManager
UIL2ConnectionFactory
UILConnectionFactory
RMIConnectionFactory
ejb
ejb
Lego
OIL2ConnectionFactory
UUIDKeyGeneratorFactory
ASKER
It started working on its own...
I don't know what ....
It Just Worked ... All of a sudden
I don't know what ....
It Just Worked ... All of a sudden
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nope... Thanks for your patience and support ...
could you please send me what you did to run the bean