Can anyone help to solve the below issue:
I am trying to upgrade my application server from JBOSS 6
to Wildfly 12/13
.
My Application is EJB
based. When i am using Jboss 6
, I was using Jdk 1.7
Now for Wildfly, I'm using jdk 1.8
.
And, while upgrading to Wildfly, previous jndi
settings wasn't working so I updated jndi configurations
from
configurations file:
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
to:
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
Now i am getting error as:
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
This is my ServiceLocator class:
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;
}
I even added jboss-client from wildfly-13 - bin/client folder. I tried almost everyway posted in other Q&A's but nothing worked.
I didn't understand how to attach files, if anyone guide me, i will attach server.log and standalone-full.xml for review.
Thanks for help in advance!