Previous attempts were to have Netbeans deploy an EJB module,它建立作为JAR而非EAR,在其上Netbeans的访问GlassFish服务器。但是,通过CLI将该JAR部署到Glassfish,并使用asadmin
possibly runs into a bug。便携式JNDI查找语法为EJB在Glassfish
耳朵通过部署没有问题的CLI - 然而,EJB的JNDI名称似乎不工作。什么是差异?
32.4.1.1移植的JNDI语法
三JNDI名称空间用于便携式JNDI查找:java的:全球, 的java:模块,和java:应用程序。
化java:全局JNDI名称空间是找到使用JNDI查找远程 企业Bean的可移植的方式。 JNDI地址是 的形式如下:JAVA:全球[/应用程序名] /模块名称/企业 bean的名称[/接口名称]应用程序名称和模块名称默认 的应用程序和模块减去文件扩展名。 仅当应用程序在EAR中打包 时才需要应用程序名称。仅当企业 bean实现多个业务接口时才需要接口名称。
http://docs.oracle.com/javaee/7/tutorial/doc/ejb-intro004.htm
什么是正确的语法来查找这个bean?是java:global/HelloEAR/HelloEAR-ejb/greetings.GreetingsBeanRemote
?我已经尝试了不止一个变种,但没有成功。
部署应用程序:
[email protected]:~$
[email protected]:~$ glassfish-4.1/glassfish/bin/asadmin list-applications
HelloEAR <ear, ejb>
Command list-applications executed successfully.
[email protected]:~$
[email protected]:~$ glassfish-4.1/glassfish/bin/asadmin undeploy HelloEAR
Command undeploy executed successfully.
[email protected]:~$
[email protected]:~$ glassfish-4.1/glassfish/bin/asadmin list-applications
Nothing to list.
No applications are deployed to this target server.
Command list-applications executed successfully.
[email protected]:~$
[email protected]:~$ glassfish-4.1/glassfish/bin/asadmin deploy NetBeansProjects/HelloEAR/dist/HelloEAR.ear
Application deployed with name HelloEAR.
Command deploy executed successfully.
[email protected]:~$
下的server.log:
[email protected]:~$
[email protected]:~$ tail glassfish-4.1/glassfish/domains/domain1/logs/server.log -n 15
[2014-09-22T04:58:42.666-0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=650 _ThreadName=admin-listener(9)] [timeMillis: 1411387122666] [levelValue: 800] [[
Glassfish-specific (Non-portable) JNDI names for EJB GreetingsBean: [greetings.GreetingsBeanRemote#greetings.GreetingsBeanRemote, greetings.GreetingsBeanRemote]]]
[2014-09-22T04:58:43.619-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=650 _ThreadName=admin-listener(9)] [timeMillis: 1411387123619] [levelValue: 900] [[
WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.gf.cdi.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]
[2014-09-22T04:58:43.628-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=650 _ThreadName=admin-listener(9)] [timeMillis: 1411387123628] [levelValue: 900] [[
WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]
[2014-09-22T04:58:43.634-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=650 _ThreadName=admin-listener(9)] [timeMillis: 1411387123634] [levelValue: 900] [[
WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds.]]
[2014-09-22T04:58:44.757-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=650 _ThreadName=admin-listener(9)] [timeMillis: 1411387124757] [levelValue: 800] [[
HelloEAR was successfully deployed in 2,312 milliseconds.]]
[email protected]:~$
试图查找:
[email protected]:~$
[email protected]:~$ glassfish-4.1/glassfish/bin/appclient -client NetBeansProjects/RemoteJNDI/dist/RemoteJNDI.jar
javax.naming.NamingException: Lookup failed for '[greetings.GreetingsBeanRemote' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, Context.SECURITY_CREDENTIALS=pass123, org.omg.CORBA.ORBInitialHost=localhost, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, Context.SECURITY_PRINCIPAL=user1} [Root exception is javax.naming.NameNotFoundException: [greetings.GreetingsBeanRemote not found]
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:491)
at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:438)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at net.bounceme.dur.jndi.RemoteJNDI.main(RemoteJNDI.java:15)
Caused by: javax.naming.NameNotFoundException: [greetings.GreetingsBeanRemote not found
at com.sun.enterprise.naming.impl.TransientContext.doLookup(TransientContext.java:237)
at com.sun.enterprise.naming.impl.TransientContext.lookup(TransientContext.java:204)
at com.sun.enterprise.naming.impl.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:66)
at com.sun.enterprise.naming.impl.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie.dispatchToMethod(ReflectiveTie.java:143)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:173)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatchToServant(ServerRequestDispatcherImpl.java:528)
at com.sun.corba.ee.impl.protocol.ServerRequestDispatcherImpl.dispatch(ServerRequestDispatcherImpl.java:199)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequestRequest(MessageMediatorImpl.java:1549)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:1425)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleInput(MessageMediatorImpl.java:930)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:213)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.handleRequest(MessageMediatorImpl.java:694)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.dispatch(MessageMediatorImpl.java:496)
at com.sun.corba.ee.impl.protocol.MessageMediatorImpl.doWork(MessageMediatorImpl.java:2222)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.performWork(ThreadPoolImpl.java:497)
at com.sun.corba.ee.impl.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:540)
[email protected]:~$