• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

cannot retrieve stateless bean using JNDI

 
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to get the stateless bean using JNDI lookup. I use Netbeans 7.0.1 and Glassfish 3.1. I create the EJB module and then I deploy it. The log from glassfish:
INFO: Portable JNDI names for EJB NewSessionBean1 : [java:global/EJBModule2/NewSessionBean1!test.NewSessionBean1, java:global/EJBModule2/NewSessionBean1]
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: EJBModule2 was successfully deployed in 103 milliseconds.

My bean class:


Then, I create the client class in the same EJB module and I perform the lookup:


and I get the following exception:
Exception in thread "main" javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.rmi.MarshalException: CORBA BAD_PARAM 1398079494 Maybe; nested exception is:
java.io.NotSerializableException: ----------BEGIN server-side stack trace----------
org.omg.CORBA.BAD_PARAM: WARNING: IOP00100006: Class test.__EJB31_Generated__NewSessionBean1__Intf____Bean__ is not Serializable vmcid: SUN minor code: 6 completed: Maybe
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

In the book EJB3.1 by Rubinger and Burke there was no mention about that the Bean must be serializable.
Anyway, I change the class:


And this time I get the error:
Exception in thread "main" javax.naming.CommunicationException: Communication exception for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl} [Root exception is java.rmi.RemoteException: CORBA DATA_CONVERSION 1398079489 No; nested exception is:
org.omg.CORBA.DATA_CONVERSION: ----------BEGIN server-side stack trace----------
org.omg.CORBA.DATA_CONVERSION: WARNING: IOP02400001: Character does not map to negotiated transmission code set vmcid: SUN minor code: 1 completed: No
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

I hane no idea about this problem.
EJB is so weird!
 
Greenhorn
Posts: 10
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a feeling that bean annotation @LocalBean is a variation of a Local view (local interface).
But here a remote lookup is performed (client is outside a container). Maybe this is the cause of contradiction.

I have no experience with EJB 3.1, so I'm not sure ... is it possible to add a Remote interface for NewSessionBean1?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have overcome some exceptions, but I Have this one now:
SEVERE: IIOP1005: An exception has occured in the ejb security initialization.
org.jvnet.hk2.component.ComponentException: injection failed on org.glassfish.api.invocation.InvocationManagerImpl.invHandlers with class [Lorg.glassfish.api.invocation.ComponentInvocationHandler;
at org.jvnet.hk2.component.InjectionManager.error_injectionException(InjectionManager.java:277)
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:159)
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:126)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at org.jvnet.hk2.component.Habitat.getByContract(Habitat.java:1042)
at org.jvnet.hk2.component.Habitat.getComponent(Habitat.java:777)
at com.sun.enterprise.iiop.security.SecurityMechanismSelector.postConstruct(SecurityMechanismSelector.java:166)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:131)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at org.jvnet.hk2.component.Habitat.getBy(Habitat.java:1048)
at org.jvnet.hk2.component.Habitat.getByType(Habitat.java:1029)
at com.sun.hk2.component.InjectInjectionResolver.getComponentInjectValue(InjectInjectionResolver.java:159)
at com.sun.hk2.component.InjectInjectionResolver.getValue(InjectInjectionResolver.java:90)
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:141)
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.inject(AbstractCreatorImpl.java:126)
at com.sun.hk2.component.ConstructorCreator.initialize(ConstructorCreator.java:91)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:82)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at org.jvnet.hk2.component.Habitat.getBy(Habitat.java:1048)
at org.jvnet.hk2.component.Habitat.getByType(Habitat.java:1029)
at org.jvnet.hk2.component.Habitat.getComponent(Habitat.java:779)
at com.sun.enterprise.iiop.security.Lookups._getSecurityContextUtil(Lookups.java:97)
at com.sun.enterprise.iiop.security.Lookups.getSecurityContextUtil(Lookups.java:92)
at com.sun.enterprise.iiop.security.SecClientRequestInterceptor.<init>(SecClientRequestInterceptor.java:119)
at com.sun.enterprise.security.appclient.AppclientIIOPInterceptorFactory.getClientInterceptorInstance(AppclientIIOPInterceptorFactory.java:127)
at com.sun.enterprise.security.appclient.AppclientIIOPInterceptorFactory.createClientRequestInterceptor(AppclientIIOPInterceptorFactory.java:96)
at org.glassfish.enterprise.iiop.impl.GlassFishORBInitializer.post_init(GlassFishORBInitializer.java:132)
at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.postInitORBInitializers(PIHandlerImpl.java:915)
at com.sun.corba.ee.impl.interceptors.PIHandlerImpl.initialize(PIHandlerImpl.java:265)
at com.sun.corba.ee.impl.orb.ORBImpl.postInit(ORBImpl.java:643)
at com.sun.corba.ee.impl.orb.ORBImpl.set_parameters(ORBImpl.java:704)
at com.sun.corba.ee.impl.orb.ORBImpl.setParameters(ORBImpl.java:691)
at com.sun.corba.ee.spi.osgi.ORBFactory.initialize(ORBFactory.java:107)
at org.glassfish.enterprise.iiop.impl.GlassFishORBManager.initORB(GlassFishORBManager.java:581)
at org.glassfish.enterprise.iiop.impl.GlassFishORBManager.getORB(GlassFishORBManager.java:263)
at org.glassfish.enterprise.iiop.impl.GlassFishORBFactoryImpl.createORB(GlassFishORBFactoryImpl.java:93)
at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:120)
at com.sun.enterprise.naming.impl.SerialContext.getORB(SerialContext.java:365)
at com.sun.enterprise.naming.impl.SerialContext.getProviderCacheKey(SerialContext.java:372)
at com.sun.enterprise.naming.impl.SerialContext.getRemoteProvider(SerialContext.java:402)
at com.sun.enterprise.naming.impl.SerialContext.getProvider(SerialContext.java:347)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:504)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at javaapplication1.JavaApplication1.main(JavaApplication1.java:47)
Caused by: org.jvnet.hk2.component.ComponentException: Failed to create class com.sun.enterprise.resource.pool.PoolManagerImpl
at com.sun.hk2.component.ConstructorCreator.create(ConstructorCreator.java:71)
at com.sun.hk2.component.AbstractCreatorImpl.get(AbstractCreatorImpl.java:80)
at com.sun.hk2.component.SingletonInhabitant.get(SingletonInhabitant.java:67)
at com.sun.hk2.component.EventPublishingInhabitant.get(EventPublishingInhabitant.java:139)
at com.sun.hk2.component.AbstractInhabitantImpl.get(AbstractInhabitantImpl.java:76)
at org.jvnet.hk2.component.Habitat$5.get(Habitat.java:701)
at java.util.AbstractList$Itr.next(AbstractList.java:358)
at java.util.AbstractCollection.toArray(AbstractCollection.java:188)
at com.sun.hk2.component.InjectInjectionResolver.getArrayInjectValue(InjectInjectionResolver.java:113)
at com.sun.hk2.component.InjectInjectionResolver.getValue(InjectInjectionResolver.java:81)
at org.jvnet.hk2.component.InjectionManager.inject(InjectionManager.java:141)
... 55 more
Caused by: java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/resource/ResourceException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
at java.lang.Class.getConstructor0(Class.java:2714)
at java.lang.Class.newInstance0(Class.java:343)
at java.lang.Class.newInstance(Class.java:325)
at com.sun.hk2.component.ConstructorCreator.create(ConstructorCreator.java:65)
... 65 more

Exception in thread "main" java.lang.ClassFormatError: Absent Code attribute in method that is not native or abstract in class file javax/ejb/RemoveException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.privateGetPublicMethods(Class.java:2562)
at java.lang.Class.privateGetPublicMethods(Class.java:2572)
at java.lang.Class.privateGetPublicMethods(Class.java:2572)
at java.lang.Class.getMethods(Class.java:1427)
at com.sun.corba.ee.impl.presentation.rmi.IDLTypesUtil.validateRemoteInterface(IDLTypesUtil.java:96)
at com.sun.corba.ee.impl.presentation.rmi.IDLNameTranslatorImpl.<init>(IDLNameTranslatorImpl.java:226)
at com.sun.corba.ee.impl.presentation.rmi.IDLNameTranslatorImpl.<init>(IDLNameTranslatorImpl.java:65)
at com.sun.corba.ee.impl.presentation.rmi.IDLNameTranslatorImpl$2.run(IDLNameTranslatorImpl.java:169)
at com.sun.corba.ee.impl.presentation.rmi.IDLNameTranslatorImpl$2.run(IDLNameTranslatorImpl.java:167)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.corba.ee.impl.presentation.rmi.IDLNameTranslatorImpl.get(IDLNameTranslatorImpl.java:166)
at com.sun.corba.ee.impl.presentation.rmi.PresentationManagerImpl$ClassDataImpl.<init>(PresentationManagerImpl.java:153)
at com.sun.corba.ee.impl.presentation.rmi.PresentationManagerImpl$1.lookup(PresentationManagerImpl.java:103)
at com.sun.corba.ee.impl.presentation.rmi.PresentationManagerImpl$1.lookup(PresentationManagerImpl.java:100)
at com.sun.corba.ee.spi.orbutil.misc.WeakCache.get(WeakCache.java:114)
at com.sun.corba.ee.impl.presentation.rmi.PresentationManagerImpl.getClassData(PresentationManagerImpl.java:131)
at com.sun.corba.ee.impl.presentation.rmi.StubFactoryFactoryDynamicBase.createStubFactory(StubFactoryFactoryDynamicBase.java:91)
at com.sun.corba.ee.impl.util.Utility.loadStub(Utility.java:835)
at com.sun.corba.ee.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:252)
at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:153)
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:406)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:75)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:321)
at com.sun.enterprise.naming.impl.SerialContext.getObjectInstance(SerialContext.java:556)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:514)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:455)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at javaapplication1.JavaApplication1.main(JavaApplication1.java:47)

I fill the success is close. Can anyone help me?
 
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are trying to reach the no-interface view bean from another JVM (as I assume that the standalone client is an another JVM instance).
The local and no-interface view beans are to be accessed only within the same JVM and the same application.

Can you try creating a remote business interface and accessing it through the JNDI?

Cheers!
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Defining @Remote interface helped and everything works fine.

I have used JNDI lookup through context.lookup("....");

But I wonder what will be the lookup path when EJB container lives on the other host with different IP. How can I lookup such EJB?
 
Piotr Nowicki
Ranch Hand
Posts: 623
1
IntelliJ IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, that's the part of the JNDI context configuration.
Do you have any jndi.properties file in your classpath? In this file (or programmatically configuring the InitialContext) you can define such things and a lot of other properties. Two links just of the top of the google results:
http://download.oracle.com/javase/jndi/tutorial/beyond/env/source.html
http://publib.boulder.ibm.com/infocenter/radhelp/v8/index.jsp?topic=/com.ibm.servertools.doc/topics/rwtcprop.html

Glassfish doesn't require you to specify the jndi properties. Instead you should use the: http://glassfish.java.net/javaee5/ejb/EJB_FAQ.html#StandaloneRemoteEJB
(step 4).

Hope this helps,

Cheers!
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying.

I want to say the the problem had two bottoms.

The solution of:
CORBA DATA_CONVERSION 1398079489
is described here:
https://coderanch.com/t/554443/java/glassfish-netbeans-big-bug#2515594

The solution of the second exception is the use of @Remote.

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to to add that the exception:
SEVERE: IIOP1005: An exception has occured in the ejb security initialization.

was caused by...

wrong classpath order.

When you want to get EJB from Glassfish from a standalone client you have to have gf-client.jar in your client's class path. But there are more libraries: Java EE 6 API Library (javaee-api-6.0.jar). It is extremely important that gf-client.jar should be placed before javaee-api-6.0.jar. Otherwise you will end up with the exception SEVERE: IIOP1005: An exception has occured in the ejb security initialization during execution:


I hope that will help!
Cheers!
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic