Java Wildfly 13和EJB2.1兼容性问题和RelativeContext类播问题

Java Wildfly 13和EJB2.1兼容性问题和RelativeContext类播问题,java,ejb-3.0,jboss6.x,ejb-2.x,wildfly-13,Java,Ejb 3.0,Jboss6.x,Ejb 2.x,Wildfly 13,任何人都可以帮助解决以下问题: 我正在尝试将我的应用服务器从JBoss6升级到Wildfly 12/13 我的应用程序是基于EJB的。当我使用JBoss6时,我使用的是JDK1.7 现在对于Wildfly,我使用的是JDK1.8 而且,在升级到Wildfly时,以前的jndi设置不起作用,所以我从更新了jndi配置 配置文件: INITIAL_CONTEXT_FACTORY = org.jnp.interfaces.NamingContextFactory PROVIDER_URL = jnp

任何人都可以帮助解决以下问题:

我正在尝试将我的应用服务器从JBoss6升级到Wildfly 12/13

我的应用程序是基于EJB的。当我使用JBoss6时,我使用的是JDK1.7

现在对于Wildfly,我使用的是
JDK1.8

而且,在升级到Wildfly时,以前的
jndi
设置不起作用,所以我从更新了
jndi配置

配置文件:

INITIAL_CONTEXT_FACTORY = org.jnp.interfaces.NamingContextFactory

PROVIDER_URL = jnp://localhost:1099

URL_PKG_PREFIXES = org.jboss.naming:org.jnp.interfaces

JNDI_VOOR_DS=java:/VOORSDB
致:

现在我得到的错误如下:

ERROR [com.aithent.voor.service.ServiceLocator] (ServerService ThreadPool -- 79) Exception whichle retrieving the home object for the EJB :UserServiceEJB 

ERROR [com.aithent.voor.service.ServiceLocator] (ServerService Thread Pool -- 79) org.wildfly.naming.client.store.RelativeContext cannot be cast to javax.ejb.EJBHome 

ERROR [com.aithent.voor.service.ServiceFactory] (ServerService Thread Pool -- 79) java.lang.ClassCastException: org.wildfly.naming.client.store.RelativeContext cannot be cast to javax.ejb.EJBHome
这是我的ServiceLocator类:

    private ServiceLocator() throws Exception{
        createContext();
    }

    public void createContext() throws Exception{
        Hashtable env = new Hashtable();
        cachedObject=new HashMap(10,0.8f);
        env.put(Context.INITIAL_CONTEXT_FACTORY, ConfigurationManager.getInstance().getPropertyValue(WebConstants.INITIAL_CONTEXT_FACTORY));
        System.out.println(ConfigurationManager.getInstance().getPropertyValue(WebConstants.INITIAL_CONTEXT_FACTORY));

        env.put(Context.PROVIDER_URL, ConfigurationManager.getInstance().getPropertyValue(WebConstants.PROVIDER_URL));
        env.put(Context.URL_PKG_PREFIXES, ConfigurationManager.getInstance().getPropertyValue(WebConstants.URL_PKG_PREFIXES));
        env.put("jboss.naming.client.ejb.context", true);
        context = new WildFlyInitialContext(env);
        System.out.println("context: "+context);
        log.debug("ServiceLocator createContext method ends ");

    }    

    public EJBHome getHome(String ejbName) throws Exception{
        EJBHome ejbHome = null;
        log.debug("ServiceLocator getHome() starts ");
        try{
            System.out.println("Context: "+context);
            if(context != null){
                Object home = context.lookup("ejb:/"+ejbName);
                System.out.println(home);
                ejbHome = (EJBHome) home;
                System.out.println(ejbHome);
            }
        }catch(Exception e){
            log.error("Exception whichle retrieving the home object for the EJB : " + ejbName);
            log.error(e.getMessage());
            throw new Exception(e);
        }
        log.debug("ServiceLocator getHome() ends ");
        return ejbHome;
    }
我甚至从wildfly-13-bin/client文件夹添加了jboss客户端。我在其他问答中几乎尝试了所有方法,但都没有效果

我不知道如何附加文件,如果有人指导我,我将附加server.log和standalone-full.xml以供审阅


提前谢谢你的帮助

我在EJB的一个基本HelloWorld项目中也面临同样的问题。 我正在使用wildfly 14.0.1

当我从JNDI字符串“ejb:ejbsample-1.0-SNAPSHOT/HelloWorld!com.ejbsample.HelloWorld”中删除“ejb:”时,它神奇地开始工作

如果有帮助,请检查和代码

    private ServiceLocator() throws Exception{
        createContext();
    }

    public void createContext() throws Exception{
        Hashtable env = new Hashtable();
        cachedObject=new HashMap(10,0.8f);
        env.put(Context.INITIAL_CONTEXT_FACTORY, ConfigurationManager.getInstance().getPropertyValue(WebConstants.INITIAL_CONTEXT_FACTORY));
        System.out.println(ConfigurationManager.getInstance().getPropertyValue(WebConstants.INITIAL_CONTEXT_FACTORY));

        env.put(Context.PROVIDER_URL, ConfigurationManager.getInstance().getPropertyValue(WebConstants.PROVIDER_URL));
        env.put(Context.URL_PKG_PREFIXES, ConfigurationManager.getInstance().getPropertyValue(WebConstants.URL_PKG_PREFIXES));
        env.put("jboss.naming.client.ejb.context", true);
        context = new WildFlyInitialContext(env);
        System.out.println("context: "+context);
        log.debug("ServiceLocator createContext method ends ");

    }    

    public EJBHome getHome(String ejbName) throws Exception{
        EJBHome ejbHome = null;
        log.debug("ServiceLocator getHome() starts ");
        try{
            System.out.println("Context: "+context);
            if(context != null){
                Object home = context.lookup("ejb:/"+ejbName);
                System.out.println(home);
                ejbHome = (EJBHome) home;
                System.out.println(ejbHome);
            }
        }catch(Exception e){
            log.error("Exception whichle retrieving the home object for the EJB : " + ejbName);
            log.error(e.getMessage());
            throw new Exception(e);
        }
        log.debug("ServiceLocator getHome() ends ");
        return ejbHome;
    }