JavaEE应用程序客户端远程注入问题

时间:2015-09-28 01:34:29

标签: java java-ee ejb java-ee-7 initial-context

每次部署ejb后我都会随机部署客户端应用程序时会出现@EJB注入错误,有时它会出现ShipFacade,有时会出现其他问题,无论是在此之前还是之后注入,它都是似乎或多或少是随意的 在不更改任何代码的情况下连续部署会产生这种行为 堆栈跟踪只是我决定发布之前的最新内容。

非常感谢任何帮助。
注意: 这是我第一次使用企业客户端应用程序模块,因此非常感谢任何有用的建议。

的SessionBean:

@Stateless(mappedName = "ShipFacadeRemote")
@PermitAll
public class ShipFacade extends AbstractFacade<Ship> implements ShipFacadeLocal, ShipFacadeRemote {
    @PersistenceContext(unitName = "Port-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ShipFacade() {
        super(Ship.class);
    }
}

远程接口:

@Remote
public interface ShipFacadeRemote {

    void create(Ship stock);

    void edit(Ship stock);

    void remove(Ship stock);

    Ship find(Object id);

    List<Ship> findAll();

    List<Ship> findRange(int[] range);

    int count();
}

本地界面:

@Local
public interface ShipFacadeLocal {

    void create(Ship stock);

    void edit(Ship stock);

    void remove(Ship stock);

    Ship find(Object id);

    List<Ship> findAll();

    List<Ship> findRange(int[] range);

    int count();
}

企业客户端应用程序:

public class Main {
    .
    .
    .
    @EJB(mappedName = "ShipFacadeRemote")
    private static ShipFacadeRemote shipFacade;
    .
    .
    .

    public static void main(String[] args) {
    }

}

堆栈跟踪:

com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=portclient.Main/shipFacade,Remote 3.x interface =beans.ShipFacadeRemote,ejb-link=null,lookup=,mappedName=ShipFacadeRemote,jndi-name=ShipFacadeRemote,refType=Session into class portclient.Main: Lookup failed for 'java:comp/env/portclient.Main/shipFacade' in 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}
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:740)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:507)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:235)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:227)
    at org.glassfish.appclient.client.acc.AppClientContainer$ClientMainClassSetting.getClientMainClass(AppClientContainer.java:636)
    at org.glassfish.appclient.client.acc.AppClientContainer.getMainMethod(AppClientContainer.java:525)
    at org.glassfish.appclient.client.acc.AppClientContainer.completePreparation(AppClientContainer.java:419)
    at org.glassfish.appclient.client.acc.AppClientContainer.prepare(AppClientContainer.java:320)
    at org.glassfish.appclient.client.AppClientFacade.prepareACC(AppClientFacade.java:279)
    at org.glassfish.appclient.client.acc.agent.AppClientContainerAgent.premain(AppClientContainerAgent.java:83)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: javax.naming.NamingException: Lookup failed for 'java:comp/env/portclient.Main/shipFacade' in 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 javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=portclient.Main/shipFacade,Remote 3.x interface =beans.ShipFacadeRemote,ejb-link=null,lookup=,mappedName=ShipFacadeRemote,jndi-name=ShipFacadeRemote,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'ShipFacadeRemote#beans.ShipFacadeRemote' [Root exception is javax.naming.NamingException: Lookup failed for 'ShipFacadeRemote#beans.ShipFacadeRemote' in 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 javax.naming.NameNotFoundException: ShipFacadeRemote#beans.ShipFacadeRemote 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:417)
    at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:636)
    ... 15 more
Caused by: javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=portclient.Main/shipFacade,Remote 3.x interface =beans.ShipFacadeRemote,ejb-link=null,lookup=,mappedName=ShipFacadeRemote,jndi-name=ShipFacadeRemote,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'ShipFacadeRemote#beans.ShipFacadeRemote' [Root exception is javax.naming.NamingException: Lookup failed for 'ShipFacadeRemote#beans.ShipFacadeRemote' in 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 javax.naming.NameNotFoundException: ShipFacadeRemote#beans.ShipFacadeRemote not found]]
    at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:188)
    at com.sun.enterprise.container.common.impl.ComponentEnvManagerImpl$EjbReferenceProxy.create(ComponentEnvManagerImpl.java:1015)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:745)
    at com.sun.enterprise.naming.impl.GlassfishNamingManagerImpl.lookup(GlassfishNamingManagerImpl.java:715)
    at com.sun.enterprise.naming.impl.JavaURLContext.lookup(JavaURLContext.java:159)
    at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:471)
    ... 18 more
Caused by: javax.naming.NamingException: Lookup failed for 'ShipFacadeRemote#beans.ShipFacadeRemote' in 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 javax.naming.NameNotFoundException: ShipFacadeRemote#beans.ShipFacadeRemote 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:417)
    at com.sun.ejb.EjbNamingReferenceManagerImpl.resolveEjbReference(EjbNamingReferenceManagerImpl.java:183)
    ... 23 more
Caused by: javax.naming.NameNotFoundException: ShipFacadeRemote#beans.ShipFacadeRemote 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:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    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)
Java Result: 1

0 个答案:

没有答案