远程业务接口的 ejb 引用解析错误 - Glassfish

ejb ref resolution error for remote business interface - Glassfish

我正在尝试实现 EJB 模块,但是当客户端应用程序尝试检索接口对象时出现错误。客户端应用程序具有与 EJB 模块相同的接口文件,但在其各自的本地包中。我认为错误出在服务器端。我从 this tutorial 复制了示例,但使用的是 glassfish 服务器;本教程中解释的简单 EJB 工作正常,但是当我尝试应用相同的理论来实现更复杂的 EJB 时,它不起作用。肯定是我做错了什么,但是关于这个错误的信息不多,我真的迷路了。

这是客户端应用程序的错误

    javax.naming.NamingException: Lookup failed for 'java:global/ManagementUtils/UsuarioService' in SerialContext[myEnv={org.omg.CORBA.ORBInitialPort=3700, java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory, 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} [Root exception is javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.management.persistence.interfaces.service.UsuarioServiceRemote [Root exception is java.lang.ClassNotFoundException: com.management.persistence.interfaces.service.UsuarioServiceRemote]]
        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.management.test.MainClass.main(MainClass.java:12)
    Caused by: javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.management.persistence.interfaces.service.UsuarioServiceRemote [Root exception is java.lang.ClassNotFoundException: com.management.persistence.interfaces.service.UsuarioServiceRemote]
        at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:433)
        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:527)
        at com.sun.enterprise.naming.impl.SerialContext.lookup(SerialContext.java:487)
        ... 3 more
    Caused by: java.lang.ClassNotFoundException: com.management.persistence.interfaces.service.UsuarioServiceRemote
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:685)
        at com.sun.ejb.EJBUtils.loadGeneratedRemoteBusinessClasses(EJBUtils.java:462)
        at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:413)
        ... 7 more

这是EJB模块中的EJBUsuarioService

package com.management.persistence.service;

import com.management.persistence.interfaces.service.UsuarioServiceRemote;
import com.management.persistence.dao.UsuarioDao;
import com.management.persistence.model.Usuario;
import com.management.persistence.facades.ServiceFacade;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import org.springframework.beans.factory.annotation.Autowired;


@Stateless
@Remote(UsuarioServiceRemote.class)
public class UsuarioService extends ServiceFacade implements UsuarioServiceRemote {

    @Autowired
    private UsuarioDao usuariosDao;

    public UsuarioService() {
    }

    public UsuarioService(UsuarioDao usuariosDao) {
        super(usuariosDao);
        this.usuariosDao = usuariosDao;
    }

    @Override
    public UsuarioDao getUsuariosDao() {
        return usuariosDao;
    }

    @Override
    public Usuario findByUsuarioAndContrasena(String login, String contrasena) {
        validateSession();
        Usuario usuario = usuariosDao.findByUsuarioAndContrasena(login, contrasena);
        closeCurrentSession();
        return usuario;
    }

}

这是 EJB 模块中的接口 UsuarioServiceRemote

package com.management.persistence.interfaces.service;

import com.management.persistence.interfaces.ServiceFacadeRemote;
import com.management.persistence.interfaces.dao.UsuarioDaoRemote;
import com.management.persistence.model.Usuario;


public interface UsuarioServiceRemote extends ServiceFacadeRemote {

    public UsuarioDaoRemote getUsuariosDao();

    public Usuario findByUsuarioAndContrasena(String login, String contrasena);

}

谢谢@SteveC 是的,实际上,我的错误是包名称,它在客户端应用程序中与在服务器中不同,所以在客户端应用程序中我重命名了业务接口的包,也是一样的对于实体 class,之后一切正常。