2014-09-22 1 views
0

Previous attempts were to have Netbeans deploy an EJB module, qui se construit en JAR plutôt qu'en EAR, sur le serveur Glassfish auquel Netbeans a accès. Cependant, déployer ce fichier JAR à Glassfish via l'interface CLI avec asadminpossibly runs into a bug. Le fichier EAR est déployé via l'interface de ligne de commande sans problème, mais les noms JNDI de l'EJB ne semblent pas fonctionner. Quelle est la différence?Recherche de syntaxe JNDI portable pour EJB sur Glassfish

32.4.1.1 JNDI Portable Syntaxe

Trois espaces de noms JNDI sont utilisés pour portables JNDI lookups: java: global, java: module, et java: app. L'espace de noms java: global JNDI est le moyen portable de rechercher des beans d'entreprise distants en utilisant les recherches JNDI. Les adresses JNDI sont du suivant: java: global [/ nom de l'application]/nom du module/entreprise nom du bean [/ nom de l'interface] Nom de l'application et nom du module par défaut au nom de l'application et du module moins l'extension du fichier. Les noms d'application sont requis uniquement si l'application est empaquetée dans un fichier EAR. Le nom de l'interface est requis uniquement si le bean d'entreprise implémente plusieurs interfaces métier.

http://docs.oracle.com/javaee/7/tutorial/doc/ejb-intro004.htm

Quelle est la syntaxe correcte pour rechercher ce haricot? Est-ce java:global/HelloEAR/HelloEAR-ejb/greetings.GreetingsBeanRemote? J'ai essayé plus de quelques variantes de cela sans succès.

déployer l'application:

[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]:~$  

essayant la recherche:

[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]:~$ 

Répondre

1

Pourquoi est l'invocation de la fève sans « java : "ou quelque chose comme ça?

succès:

[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]:~$ 
[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/appclient -client NetBeansProjects/RemoteJNDI/dist/RemoteJNDI.jar 
hello world 
[email protected]:~$ 
[email protected]:~$ 

code client:

package net.bounceme.dur.jndi; 

import greetings.GreetingsBeanRemote; 
import java.util.logging.Logger; 
import javax.naming.InitialContext; 
import javax.naming.NamingException; 

public class RemoteJNDI { 

    private static final Logger log = Logger.getLogger(RemoteJNDI.class.getName()); 

    public static void main(String... args) { 
     try { 
      InitialContext ctx = new InitialContext(); 
//   Object obj = ctx.lookup("java:global/HelloEAR/HelloEAR-ejb/greetings.GreetingsBeanRemote"); 
      Object obj = ctx.lookup("greetings.GreetingsBeanRemote"); 
      GreetingsBeanRemote gbr = (GreetingsBeanRemote) obj; 
      System.out.println(gbr.hi()); 
     } catch (NamingException ex) { 
      ex.printStackTrace(); 
     } 
    } 

} 

ejb:

package greetings; 

import javax.ejb.Stateless; 

@Stateless 
public class GreetingsBean implements GreetingsBeanRemote { 

    @Override 
    public String hi() { 
     return "hello world"; 
    } 

    @Override 
    public String bye() { 
     return "bye"; 
    } 

} 

Interface:

package greetings; 

import javax.ejb.Remote; 

@Remote 
public interface GreetingsBeanRemote { 

    public String hi(); 

    public String bye(); 
} 

journal du serveur:

[2014-09-22T17:55:56.091-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411433756091] [levelValue: 800] [[ 
    visiting unvisited references]] 

[2014-09-22T17:55:56.233-0700] [glassfish 4.1] [INFO] [AS-EJB-00054] [javax.enterprise.ejb.container] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411433756233] [levelValue: 800] [[ 
    Portable JNDI names for EJB GreetingsBean: [java:global/HelloEAR/HelloEAR-ejb/GreetingsBean!greetings.GreetingsBeanRemote, java:global/HelloEAR/HelloEAR-ejb/GreetingsBean]]] 

[2014-09-22T17:55:56.235-0700] [glassfish 4.1] [INFO] [AS-EJB-00055] [javax.enterprise.ejb.container] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411433756235] [levelValue: 800] [[ 
    Glassfish-specific (Non-portable) JNDI names for EJB GreetingsBean: [greetings.GreetingsBeanRemote#greetings.GreetingsBeanRemote, greetings.GreetingsBeanRemote]]] 

[2014-09-22T17:55:56.321-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411433756321] [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-22T17:55:56.341-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411433756341] [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-22T17:55:56.349-0700] [glassfish 4.1] [WARN] [] [org.jboss.weld.Event] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411433756349] [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-22T17:55:56.819-0700] [glassfish 4.1] [INFO] [] [javax.enterprise.system.core] [tid: _ThreadID=40 _ThreadName=admin-listener(3)] [timeMillis: 1411433756819] [levelValue: 800] [[ 
    HelloEAR was successfully deployed in 842 milliseconds.]] 

[email protected]:~$ 
Questions connexes