任何人都可以帮助解决以下问题:
我正在尝试将我的应用程序服务器JBOSS 6
从Wildfly 12/13
.
我的应用程序是EJB
基于。当我使用时Jboss 6
,我正在使用Jdk 1.7
现在对于 Wildfly,我正在使用jdk 1.8
.
而且,在升级到 Wildfly 时,以前的jndi
设置不起作用,所以我jndi configurations
从
配置文件:
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
至:
INITIAL_CONTEXT_FACTORY = org.wildfly.naming.client.WildFlyInitialContextFactory
PROVIDER_URL = remote+http://localhost:8080
URL_PKG_PREFIXES = org.jboss.ejb.client.naming
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-client。我几乎尝试了在其他问答中发布的所有方法,但没有任何效果。
我不明白如何附加文件,如果有人指导我,我将附加 server.log 和standalone-full.xml 以供审查。
提前感谢您的帮助!