Skip to main content

Sun GlassFish Enterprise Server v2.1 (9.1.1)- No object bound to name java:comp/env problem

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
sajara
Offline
Joined: 2011-04-15

Hi

Lately I was trying to use remote ejb component which is part of .ear application in my .ear application. The exception I get is "No object bound to name java:comp/env/ejb/omNotifierDao" (stacktrace below the post).

When I look into JNDI for context ejbs i get the following:

glfish@japet:~$ asadmin list-jndi-entries --context ejb japet-cluster-3-instance-2
Jndi Entries for japet-cluster-3-instance-2 within ejb context:
omNotifierDao__3_x_Internal_RemoteBusinessHome__: javax.naming.Reference
omNotifierDao#pl.centertel.isep.omnotifier.ejb.DaoRemote: javax.naming.Reference
omNotifierDao: javax.naming.Reference
mgmt: com.sun.enterprise.naming.TransientContext
Command list-jndi-entries executed successfully.

So the conclusion from this is that ejb is visible as remote ejb and its name is omNotifierDao. Moreover in JNDI tree browser on the cluster-3 I see it is avaliable and its JNDI name is ejb/omNotifierDao (in the ejb implementation mapped name is set to ejb/omNotifierDao).

When I try to use it in my ejb using lookup the problem arisies. Some code sample:

@Remote
@Stateless(mappedName = "ejb/myApp/Service")

public class Service implements MyService {

InitialContext ic;....

try {
Object omNotifier;

omNotifier = getResource("ejb/omNotifierDao");

}......

private Object getResource(String name) throws NamingException {

if (this.ic == null) {
this.ic = new InitialContext();
}

return ic.lookup("java:comp/env/" + name);

}

When I try lookup from standalone client everything is ok, for example:

public static void main (String args[]) throws NamingException, SQLException, DaoException{

Object o = lookup("ejb/omNotifierDao");
((DaoRemote)o).putNotification();

private static Object lookup(String name) throws NamingException {
System.setProperty("com.sun.appserv.iiop.endpoints", "126.10.105.1:3705,126.10.105.1:3706" );
System.setProperty("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
System.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
System.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
ctx = new InitialContext();
if (ctx == null)
ctx = new InitialContext();
return ctx.lookup(name);

}

And the remote component is collected sucessfully.

I tried to use annotations and configurating remote ejb in ejb-jar.xml. Everytime there is "No object bound to name java:comp/env/ejb/omNotifierDao exception".

Anyone has the idea what can be wrong or how to eliminate this? Maybe some glassfish v2.1 patch?

Thanx in advance for help or advice.

The stacktrace below:

[#|2011-07-12T14:41:48.804+0200|INFO|sun-appserver2.1|javax.enterprise.system.container.ejb|_ThreadID=84;_ThreadName=p: thread-pool-1; w: 24;|
javax.ejb.EJBException: No object bound to name java:comp/env/ejb/omNotifierDao
at pl.centertel.vas.isep.services.myApp.ejb.Service.notifyOM(Service.java:922)
at pl.centertel.vas.isep.services.myApp.ejb.Service.deactivate(Service.java:384)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2920)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4011)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:77)
at $Proxy384.deactivate(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cf126330
Offline
Joined: 2005-03-29

In order to use "java:comp/env/ejb/omNotifierDao" for lookup, you will need to define a ejb-ref with with @EJB injection , or xml element <ejb-ref>.

@EJB(name="ejb/omNotifierDao")

<ejb-ref>

&lt;ejb-ref-name&gt;ejb/omNotifierDao&lt;/ejb-ref-name&gt;