Skip to main content

javax.naming.NamingException

7 replies [Last post]
trouby
Offline
Joined: 2006-02-27

Hello,

I am getting a 'javax.naming.NamingException',
Can anyone point me what's wrong? this code was worked already,

This is the line that throws the exception:
TargetSystemManager tsmLocal = (TargetSystemManager) ic.lookup(TargetSystemManager.class.getName());

----------

[#|2006-05-12T21:05:04.866+0300|WARNING|sun-appserver-pe9.1|javax.enterprise.system.stream.err|_ThreadID=15;_ThreadName=p: thread-pool-1; w: 2;_RequestID=274e55b9-37ae-4c7d-84f1-945a7525492d;|
javax.naming.NamingException: ejb ref resolution error for remote business interfaceejbs.interfaces.TargetSystemManager [Root exception is java.lang.IllegalArgumentException: object is not an instance of declaring class]
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:313)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:61)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:314)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at reconcilidation.ReconcileAccounts.(ReconcileAccounts.java:57)
at ejbs.impl.ReconcileBean.reconcileAccountsByTargetSystem(ReconcileBean.java:14)
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:585)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1050)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2766)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3847)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:190)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:110)
at $Proxy52.reconcileAccountsByTargetSystem(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:585)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
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:585)
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:305)
... 32 more
|#]

---------

Thanks a lot

Reply viewing options

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

Any particular reason why you are using ic.lookup() instead of using injection:
[code]
@EJB private TargetSystemManager tsmLocal;
[/code]
assuming TargetSystemManager is the business interface of your session bean.

trouby
Offline
Joined: 2006-02-27

Hey,

Well, according to spec, it is not possible to inject an EJB into helper classes, so through helper classes I use JNDI lookup.

Thanks for answering,

Asaf.

ss141213
Offline
Joined: 2005-03-30

OK, got it. Yet I ask not to use global JNDI names directly in code. You may find a recent posting regarding this useful:
http://forums.java.net/jive/thread.jspa?messageID=113981&#113981

trouby
Offline
Joined: 2006-02-27

Hey,

I will try to avoid global JNDI names directly,

Aren't there any ways to use logical names by annotations without implemnenting descriptors?, I'm kinda trying to avoid all those DD files...

Thanks.

ss141213
Offline
Joined: 2005-03-30

>
> Aren't there any ways to use logical names by
> annotations without implemnenting descriptors?, I'm
> kinda trying to avoid all those DD files...

Yes, it's possible. You can use @EJB at the class level (e.g.):
[code]@EJB("ejb/LogicalName", beanName="MyBean", beanInterface=MyBeanInterface.class) class MyServlet ... {
...
}[/code]

This is equivalent to using in XML descriptors.

Now, you can use JNDI to lookup using logical name. Actually, you should be able to look up in helper class even though you annotated the servlet. Let me know, how it goes.

@EJB also has an attribute called [b]mappedName[/b], which you can take advantage of to bind to EJBs defined outsise your ear file. More details can be found in javadocs of @EJB.

trouby
Offline
Joined: 2006-02-27

Hi,

Thanks for answering,

I got a little confused regarding the @EJB annotation here, where it goes to? I dont have any servlets in use, only EJBs and helper classes.... so where should I use the @EJB annotation in order to declare the local name?

Asaf.

ss141213
Offline
Joined: 2005-03-30

Use @EJB in any of the client EJBs.