java.lang.RuntimeException: RESTEASY003325: Failed to construct public












0















Getting following exception when trying to



ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 542) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./rest: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./rest: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [java.base:]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at java.base/java.lang.Thread.run(Thread.java:834) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:162)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.spi.ResteasyProviderFactory.injectedInstance(ResteasyProviderFactory.java:2702)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.createInterceptor(JaxrsInterceptorRegistry.java:170)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.initialize(JaxrsInterceptorRegistry.java:188)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.checkInitialize(JaxrsInterceptorRegistry.java:203)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.getInterceptor(JaxrsInterceptorRegistry.java:214)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.postMatch(JaxrsInterceptorRegistry.java:151)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry.postMatch(JaxrsInterceptorRegistry.java:421)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.ContainerRequestFilterRegistry.postMatch(ContainerRequestFilterRegistry.java:57)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:115)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:345)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:272)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:223)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:195)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:181)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:158)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:77)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.processApplication(ServletContainerDispatcher.java:178)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:104)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:300) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:140) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:579) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:550) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:592) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
... 8 more


Caused by: WfaException{Message: No EJB was found matching field 'restApiLogger' of class class com.netapp.wfa.rs.RestApplicationMapper, Cause: null}
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:128)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:70)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:66)
at deployment.wfa-0.5.ear.rest-facade-0.5.war//com.netapp.wfa.rs.RestApplicationMapper.(RestApplicationMapper.java:21)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [java.base:]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [java.base:]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [java.base:]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) [java.base:]
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
... 45 more



Code that is causing the exception



public class SessionUtil {
public static final String CONTEXT_NAME = "java:global/" + EarUtils.getEarName();
private List<Object> deployedEjbList; //Note: this is lazy initialized
private Map<Class, Object> deployedEjbByInterface; //Note: this is (very) lazy initialized

private static SessionUtil instance = new SessionUtil();

public static <P> P injectDependencies(P pojo) {
return injectDependencies(pojo, null);
}

public static <P> P injectDependencies(P pojo, EntityManager entityManager) {
return instance.injectDependencies(pojo, entityManager, null, null);
}

protected <P> P injectDependencies(P pojo, EntityManager entityManager, SessionContext sessionContext, UserTransaction userTransaction) {
if (pojo == null) return null;

// Loop over the class hierarchy of the pojo
for (Class clazz = pojo.getClass(); !clazz.equals(Object.class); clazz = clazz.getSuperclass()) {

// For each class, iterate over its field and look for EJB annotations
for (Field field : clazz.getDeclaredFields()) {

// Lookup and inject to @EJB annotated member variables
if (field.isAnnotationPresent(EJB.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Get the EJB to be assigned to this field
Object ejb = getEjbForField(fieldClass);
if (ejb == null) {
throw new WfaException("No EJB was found matching field '" + field.getName() + "' of class " + clazz);
}

// Assign the EJB to the field
assignEjbToField(pojo, clazz, field, ejb);
}

// Inject an entityManager to @PersistenceContext annotated member variables
else if (field.isAnnotationPresent(PersistenceContext.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

if (!EntityManager.class.equals(fieldClass)) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " is annotated with PersistenceContext but isn't EntityManager");
}

// Assign the EntityManager to the field
assignEjbToField(pojo, clazz, field, entityManager);
}

// Inject a data-source to @Resource annotated member variables with the appropriate class
else if (field.isAnnotationPresent(Resource.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Assign the DataSource to the field
if (DataSource.class.equals(fieldClass)) {
String dataSourceName = field.getAnnotation(Resource.class).mappedName();
assignEjbToField(pojo, clazz, field, getDataSource(dataSourceName));
}

// Assign the SessionContext to the field
else if (SessionContext.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, sessionContext);
}
// Assign the SessionContext to the field
else if (UserTransaction.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, userTransaction);
}
}
}
}

return pojo;
}

public static Map<Class, Object> getDeployedEjbByInterface() {
if (instance.deployedEjbByInterface == null || instance.deployedEjbByInterface.isEmpty()) {
instance.initDeployedEjbByInterface();
}

return instance.deployedEjbByInterface;
}

protected synchronized List<Object> getDeployedEjbList() {
if (deployedEjbList == null) {
deployedEjbList = initDeployedEjbList();
}

return deployedEjbList;
}

private void initDeployedEjbByInterface() {
// Crate a map from EJB interfaces to EJB instances.
deployedEjbByInterface = new HashMap<>();
for (Object ejb : getDeployedEjbList()) {
for (Class anInterface : ejb.getClass().getInterfaces()) {

// Register only interfaces annotated as "remote" or "local"
if (anInterface.getAnnotation(Remote.class) != null || anInterface.getAnnotation(Local.class) != null) {
deployedEjbByInterface.put(anInterface, ejb);
}
}
}
}

private List<Object> initDeployedEjbList() {
InitialContext context = null;
NamingEnumeration<NameClassPair> allWfaEjbNameAndClass = null;
NamingEnumeration<NameClassPair> internalNamingEnumeration = null;
try {
/**
* Enumerate the names bound in the named context
*/
context = new InitialContext();

allWfaEjbNameAndClass = context.list(CONTEXT_NAME);

/**
* Iterate the entries in the WFA EAR looking for EJBs with remote/local interfaces
*/
deployedEjbList = new LinkedList<>();
while (allWfaEjbNameAndClass.hasMore()) {
NameClassPair jarNameAndClass = allWfaEjbNameAndClass.next();

internalNamingEnumeration = context.list(CONTEXT_NAME + "/" + jarNameAndClass.getName());

while (internalNamingEnumeration.hasMore()) {
NameClassPair ejbNameAndClass = internalNamingEnumeration.next();
// Skip EJB names with "!" in it as they are duplicate
if (ejbNameAndClass.getName().indexOf('!') >= 0) continue;

Object ejb = silentLookup(context, CONTEXT_NAME + "/" + jarNameAndClass.getName() + "/" + ejbNameAndClass.getName());
if (ejb != null) {
deployedEjbList.add(ejb);
}
}
}

return deployedEjbList;

} catch (NamingException e) {
throw new WfaException("Failed to list EJBs in :" + CONTEXT_NAME, e);
} finally {

silentClose(allWfaEjbNameAndClass);
silentClose(internalNamingEnumeration);
silentClose(context);
}
}

private Object silentLookup(Context context, String name) {
try {

return context.lookup(name);

} catch (NamingException e) {
return null;
}
}

private static void silentClose(NamingEnumeration<NameClassPair> namingEnumeration) {
if (namingEnumeration != null) {
try {
namingEnumeration.close();
} catch (NamingException e) {
LOGGER.error("Failed to close NamingEnumeration", e);
}
}
}

protected Object getEjbForField(Class<?> fieldClass) {
Object obj = getDeployedEjbByInterface().get(fieldClass);

// If no EJB was found, flush the cache and try again before giving up
if (obj == null) {
reset();
obj = getDeployedEjbByInterface().get(fieldClass);
}

return obj;
}

public static synchronized void reset() {
instance.deployedEjbList = null;
instance.deployedEjbByInterface = null;
}

private Class<?> getFieldInterface(Class clazz, Field field) {
Class<?> fieldClass = field.getType();
if (!fieldClass.isInterface()) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " isn't an interface");
}
return fieldClass;
}

private <P> void assignEjbToField(P pojo, Class clazz, Field field, Object ejb) {
boolean fieldAccessible = field.isAccessible();
field.setAccessible(true);
try {
field.set(pojo, ejb);
} catch (Exception e) {
throw new WfaException("Failed to inject EJB to member '" + field.getName() + "' of class: " + clazz, e);
} finally {
field.setAccessible(fieldAccessible);
}
}
}


My Application is running on Wildfly 12 and Java 8. Now I want to upgrade to Java 11, then I got this issue. Can anyone pls help me solve this?










share|improve this question




















  • 1





    Hi and welcome to SO. Please add the code that is leading to this exception - otherwise it is hard for us to see what exactly was done in order to get this exception.

    – quant
    Nov 16 '18 at 7:05











  • And also please use code formatting. makes it easier to read! Welcome

    – Clomez
    Nov 16 '18 at 7:10











  • Hi quant, Thanks for the suggestion. I have added the code that is causing the exception.

    – user3301924
    Nov 19 '18 at 6:40
















0















Getting following exception when trying to



ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 542) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./rest: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./rest: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [java.base:]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at java.base/java.lang.Thread.run(Thread.java:834) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:162)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.spi.ResteasyProviderFactory.injectedInstance(ResteasyProviderFactory.java:2702)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.createInterceptor(JaxrsInterceptorRegistry.java:170)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.initialize(JaxrsInterceptorRegistry.java:188)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.checkInitialize(JaxrsInterceptorRegistry.java:203)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.getInterceptor(JaxrsInterceptorRegistry.java:214)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.postMatch(JaxrsInterceptorRegistry.java:151)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry.postMatch(JaxrsInterceptorRegistry.java:421)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.ContainerRequestFilterRegistry.postMatch(ContainerRequestFilterRegistry.java:57)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:115)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:345)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:272)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:223)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:195)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:181)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:158)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:77)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.processApplication(ServletContainerDispatcher.java:178)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:104)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:300) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:140) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:579) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:550) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:592) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
... 8 more


Caused by: WfaException{Message: No EJB was found matching field 'restApiLogger' of class class com.netapp.wfa.rs.RestApplicationMapper, Cause: null}
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:128)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:70)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:66)
at deployment.wfa-0.5.ear.rest-facade-0.5.war//com.netapp.wfa.rs.RestApplicationMapper.(RestApplicationMapper.java:21)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [java.base:]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [java.base:]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [java.base:]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) [java.base:]
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
... 45 more



Code that is causing the exception



public class SessionUtil {
public static final String CONTEXT_NAME = "java:global/" + EarUtils.getEarName();
private List<Object> deployedEjbList; //Note: this is lazy initialized
private Map<Class, Object> deployedEjbByInterface; //Note: this is (very) lazy initialized

private static SessionUtil instance = new SessionUtil();

public static <P> P injectDependencies(P pojo) {
return injectDependencies(pojo, null);
}

public static <P> P injectDependencies(P pojo, EntityManager entityManager) {
return instance.injectDependencies(pojo, entityManager, null, null);
}

protected <P> P injectDependencies(P pojo, EntityManager entityManager, SessionContext sessionContext, UserTransaction userTransaction) {
if (pojo == null) return null;

// Loop over the class hierarchy of the pojo
for (Class clazz = pojo.getClass(); !clazz.equals(Object.class); clazz = clazz.getSuperclass()) {

// For each class, iterate over its field and look for EJB annotations
for (Field field : clazz.getDeclaredFields()) {

// Lookup and inject to @EJB annotated member variables
if (field.isAnnotationPresent(EJB.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Get the EJB to be assigned to this field
Object ejb = getEjbForField(fieldClass);
if (ejb == null) {
throw new WfaException("No EJB was found matching field '" + field.getName() + "' of class " + clazz);
}

// Assign the EJB to the field
assignEjbToField(pojo, clazz, field, ejb);
}

// Inject an entityManager to @PersistenceContext annotated member variables
else if (field.isAnnotationPresent(PersistenceContext.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

if (!EntityManager.class.equals(fieldClass)) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " is annotated with PersistenceContext but isn't EntityManager");
}

// Assign the EntityManager to the field
assignEjbToField(pojo, clazz, field, entityManager);
}

// Inject a data-source to @Resource annotated member variables with the appropriate class
else if (field.isAnnotationPresent(Resource.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Assign the DataSource to the field
if (DataSource.class.equals(fieldClass)) {
String dataSourceName = field.getAnnotation(Resource.class).mappedName();
assignEjbToField(pojo, clazz, field, getDataSource(dataSourceName));
}

// Assign the SessionContext to the field
else if (SessionContext.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, sessionContext);
}
// Assign the SessionContext to the field
else if (UserTransaction.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, userTransaction);
}
}
}
}

return pojo;
}

public static Map<Class, Object> getDeployedEjbByInterface() {
if (instance.deployedEjbByInterface == null || instance.deployedEjbByInterface.isEmpty()) {
instance.initDeployedEjbByInterface();
}

return instance.deployedEjbByInterface;
}

protected synchronized List<Object> getDeployedEjbList() {
if (deployedEjbList == null) {
deployedEjbList = initDeployedEjbList();
}

return deployedEjbList;
}

private void initDeployedEjbByInterface() {
// Crate a map from EJB interfaces to EJB instances.
deployedEjbByInterface = new HashMap<>();
for (Object ejb : getDeployedEjbList()) {
for (Class anInterface : ejb.getClass().getInterfaces()) {

// Register only interfaces annotated as "remote" or "local"
if (anInterface.getAnnotation(Remote.class) != null || anInterface.getAnnotation(Local.class) != null) {
deployedEjbByInterface.put(anInterface, ejb);
}
}
}
}

private List<Object> initDeployedEjbList() {
InitialContext context = null;
NamingEnumeration<NameClassPair> allWfaEjbNameAndClass = null;
NamingEnumeration<NameClassPair> internalNamingEnumeration = null;
try {
/**
* Enumerate the names bound in the named context
*/
context = new InitialContext();

allWfaEjbNameAndClass = context.list(CONTEXT_NAME);

/**
* Iterate the entries in the WFA EAR looking for EJBs with remote/local interfaces
*/
deployedEjbList = new LinkedList<>();
while (allWfaEjbNameAndClass.hasMore()) {
NameClassPair jarNameAndClass = allWfaEjbNameAndClass.next();

internalNamingEnumeration = context.list(CONTEXT_NAME + "/" + jarNameAndClass.getName());

while (internalNamingEnumeration.hasMore()) {
NameClassPair ejbNameAndClass = internalNamingEnumeration.next();
// Skip EJB names with "!" in it as they are duplicate
if (ejbNameAndClass.getName().indexOf('!') >= 0) continue;

Object ejb = silentLookup(context, CONTEXT_NAME + "/" + jarNameAndClass.getName() + "/" + ejbNameAndClass.getName());
if (ejb != null) {
deployedEjbList.add(ejb);
}
}
}

return deployedEjbList;

} catch (NamingException e) {
throw new WfaException("Failed to list EJBs in :" + CONTEXT_NAME, e);
} finally {

silentClose(allWfaEjbNameAndClass);
silentClose(internalNamingEnumeration);
silentClose(context);
}
}

private Object silentLookup(Context context, String name) {
try {

return context.lookup(name);

} catch (NamingException e) {
return null;
}
}

private static void silentClose(NamingEnumeration<NameClassPair> namingEnumeration) {
if (namingEnumeration != null) {
try {
namingEnumeration.close();
} catch (NamingException e) {
LOGGER.error("Failed to close NamingEnumeration", e);
}
}
}

protected Object getEjbForField(Class<?> fieldClass) {
Object obj = getDeployedEjbByInterface().get(fieldClass);

// If no EJB was found, flush the cache and try again before giving up
if (obj == null) {
reset();
obj = getDeployedEjbByInterface().get(fieldClass);
}

return obj;
}

public static synchronized void reset() {
instance.deployedEjbList = null;
instance.deployedEjbByInterface = null;
}

private Class<?> getFieldInterface(Class clazz, Field field) {
Class<?> fieldClass = field.getType();
if (!fieldClass.isInterface()) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " isn't an interface");
}
return fieldClass;
}

private <P> void assignEjbToField(P pojo, Class clazz, Field field, Object ejb) {
boolean fieldAccessible = field.isAccessible();
field.setAccessible(true);
try {
field.set(pojo, ejb);
} catch (Exception e) {
throw new WfaException("Failed to inject EJB to member '" + field.getName() + "' of class: " + clazz, e);
} finally {
field.setAccessible(fieldAccessible);
}
}
}


My Application is running on Wildfly 12 and Java 8. Now I want to upgrade to Java 11, then I got this issue. Can anyone pls help me solve this?










share|improve this question




















  • 1





    Hi and welcome to SO. Please add the code that is leading to this exception - otherwise it is hard for us to see what exactly was done in order to get this exception.

    – quant
    Nov 16 '18 at 7:05











  • And also please use code formatting. makes it easier to read! Welcome

    – Clomez
    Nov 16 '18 at 7:10











  • Hi quant, Thanks for the suggestion. I have added the code that is causing the exception.

    – user3301924
    Nov 19 '18 at 6:40














0












0








0








Getting following exception when trying to



ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 542) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./rest: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./rest: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [java.base:]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at java.base/java.lang.Thread.run(Thread.java:834) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:162)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.spi.ResteasyProviderFactory.injectedInstance(ResteasyProviderFactory.java:2702)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.createInterceptor(JaxrsInterceptorRegistry.java:170)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.initialize(JaxrsInterceptorRegistry.java:188)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.checkInitialize(JaxrsInterceptorRegistry.java:203)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.getInterceptor(JaxrsInterceptorRegistry.java:214)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.postMatch(JaxrsInterceptorRegistry.java:151)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry.postMatch(JaxrsInterceptorRegistry.java:421)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.ContainerRequestFilterRegistry.postMatch(ContainerRequestFilterRegistry.java:57)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:115)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:345)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:272)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:223)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:195)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:181)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:158)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:77)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.processApplication(ServletContainerDispatcher.java:178)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:104)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:300) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:140) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:579) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:550) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:592) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
... 8 more


Caused by: WfaException{Message: No EJB was found matching field 'restApiLogger' of class class com.netapp.wfa.rs.RestApplicationMapper, Cause: null}
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:128)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:70)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:66)
at deployment.wfa-0.5.ear.rest-facade-0.5.war//com.netapp.wfa.rs.RestApplicationMapper.(RestApplicationMapper.java:21)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [java.base:]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [java.base:]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [java.base:]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) [java.base:]
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
... 45 more



Code that is causing the exception



public class SessionUtil {
public static final String CONTEXT_NAME = "java:global/" + EarUtils.getEarName();
private List<Object> deployedEjbList; //Note: this is lazy initialized
private Map<Class, Object> deployedEjbByInterface; //Note: this is (very) lazy initialized

private static SessionUtil instance = new SessionUtil();

public static <P> P injectDependencies(P pojo) {
return injectDependencies(pojo, null);
}

public static <P> P injectDependencies(P pojo, EntityManager entityManager) {
return instance.injectDependencies(pojo, entityManager, null, null);
}

protected <P> P injectDependencies(P pojo, EntityManager entityManager, SessionContext sessionContext, UserTransaction userTransaction) {
if (pojo == null) return null;

// Loop over the class hierarchy of the pojo
for (Class clazz = pojo.getClass(); !clazz.equals(Object.class); clazz = clazz.getSuperclass()) {

// For each class, iterate over its field and look for EJB annotations
for (Field field : clazz.getDeclaredFields()) {

// Lookup and inject to @EJB annotated member variables
if (field.isAnnotationPresent(EJB.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Get the EJB to be assigned to this field
Object ejb = getEjbForField(fieldClass);
if (ejb == null) {
throw new WfaException("No EJB was found matching field '" + field.getName() + "' of class " + clazz);
}

// Assign the EJB to the field
assignEjbToField(pojo, clazz, field, ejb);
}

// Inject an entityManager to @PersistenceContext annotated member variables
else if (field.isAnnotationPresent(PersistenceContext.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

if (!EntityManager.class.equals(fieldClass)) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " is annotated with PersistenceContext but isn't EntityManager");
}

// Assign the EntityManager to the field
assignEjbToField(pojo, clazz, field, entityManager);
}

// Inject a data-source to @Resource annotated member variables with the appropriate class
else if (field.isAnnotationPresent(Resource.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Assign the DataSource to the field
if (DataSource.class.equals(fieldClass)) {
String dataSourceName = field.getAnnotation(Resource.class).mappedName();
assignEjbToField(pojo, clazz, field, getDataSource(dataSourceName));
}

// Assign the SessionContext to the field
else if (SessionContext.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, sessionContext);
}
// Assign the SessionContext to the field
else if (UserTransaction.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, userTransaction);
}
}
}
}

return pojo;
}

public static Map<Class, Object> getDeployedEjbByInterface() {
if (instance.deployedEjbByInterface == null || instance.deployedEjbByInterface.isEmpty()) {
instance.initDeployedEjbByInterface();
}

return instance.deployedEjbByInterface;
}

protected synchronized List<Object> getDeployedEjbList() {
if (deployedEjbList == null) {
deployedEjbList = initDeployedEjbList();
}

return deployedEjbList;
}

private void initDeployedEjbByInterface() {
// Crate a map from EJB interfaces to EJB instances.
deployedEjbByInterface = new HashMap<>();
for (Object ejb : getDeployedEjbList()) {
for (Class anInterface : ejb.getClass().getInterfaces()) {

// Register only interfaces annotated as "remote" or "local"
if (anInterface.getAnnotation(Remote.class) != null || anInterface.getAnnotation(Local.class) != null) {
deployedEjbByInterface.put(anInterface, ejb);
}
}
}
}

private List<Object> initDeployedEjbList() {
InitialContext context = null;
NamingEnumeration<NameClassPair> allWfaEjbNameAndClass = null;
NamingEnumeration<NameClassPair> internalNamingEnumeration = null;
try {
/**
* Enumerate the names bound in the named context
*/
context = new InitialContext();

allWfaEjbNameAndClass = context.list(CONTEXT_NAME);

/**
* Iterate the entries in the WFA EAR looking for EJBs with remote/local interfaces
*/
deployedEjbList = new LinkedList<>();
while (allWfaEjbNameAndClass.hasMore()) {
NameClassPair jarNameAndClass = allWfaEjbNameAndClass.next();

internalNamingEnumeration = context.list(CONTEXT_NAME + "/" + jarNameAndClass.getName());

while (internalNamingEnumeration.hasMore()) {
NameClassPair ejbNameAndClass = internalNamingEnumeration.next();
// Skip EJB names with "!" in it as they are duplicate
if (ejbNameAndClass.getName().indexOf('!') >= 0) continue;

Object ejb = silentLookup(context, CONTEXT_NAME + "/" + jarNameAndClass.getName() + "/" + ejbNameAndClass.getName());
if (ejb != null) {
deployedEjbList.add(ejb);
}
}
}

return deployedEjbList;

} catch (NamingException e) {
throw new WfaException("Failed to list EJBs in :" + CONTEXT_NAME, e);
} finally {

silentClose(allWfaEjbNameAndClass);
silentClose(internalNamingEnumeration);
silentClose(context);
}
}

private Object silentLookup(Context context, String name) {
try {

return context.lookup(name);

} catch (NamingException e) {
return null;
}
}

private static void silentClose(NamingEnumeration<NameClassPair> namingEnumeration) {
if (namingEnumeration != null) {
try {
namingEnumeration.close();
} catch (NamingException e) {
LOGGER.error("Failed to close NamingEnumeration", e);
}
}
}

protected Object getEjbForField(Class<?> fieldClass) {
Object obj = getDeployedEjbByInterface().get(fieldClass);

// If no EJB was found, flush the cache and try again before giving up
if (obj == null) {
reset();
obj = getDeployedEjbByInterface().get(fieldClass);
}

return obj;
}

public static synchronized void reset() {
instance.deployedEjbList = null;
instance.deployedEjbByInterface = null;
}

private Class<?> getFieldInterface(Class clazz, Field field) {
Class<?> fieldClass = field.getType();
if (!fieldClass.isInterface()) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " isn't an interface");
}
return fieldClass;
}

private <P> void assignEjbToField(P pojo, Class clazz, Field field, Object ejb) {
boolean fieldAccessible = field.isAccessible();
field.setAccessible(true);
try {
field.set(pojo, ejb);
} catch (Exception e) {
throw new WfaException("Failed to inject EJB to member '" + field.getName() + "' of class: " + clazz, e);
} finally {
field.setAccessible(fieldAccessible);
}
}
}


My Application is running on Wildfly 12 and Java 8. Now I want to upgrade to Java 11, then I got this issue. Can anyone pls help me solve this?










share|improve this question
















Getting following exception when trying to



ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 542) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./rest: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./rest: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:81) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [java.base:]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
at java.base/java.lang.Thread.run(Thread.java:834) [java.base:]
at org.jboss.threads@2.3.1.Final//org.jboss.threads.JBossThread.run(JBossThread.java:485) [jboss-threads-2.3.1.Final.jar:2.3.1.Final]
Caused by: java.lang.RuntimeException: RESTEASY003325: Failed to construct public com.us.demo.rs.RestApplicationMapper()
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:162)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.spi.ResteasyProviderFactory.injectedInstance(ResteasyProviderFactory.java:2702)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.createInterceptor(JaxrsInterceptorRegistry.java:170)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.initialize(JaxrsInterceptorRegistry.java:188)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.checkInitialize(JaxrsInterceptorRegistry.java:203)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$OnDemandInterceptorFactory.getInterceptor(JaxrsInterceptorRegistry.java:214)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry$AbstractInterceptorFactory.postMatch(JaxrsInterceptorRegistry.java:151)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.JaxrsInterceptorRegistry.postMatch(JaxrsInterceptorRegistry.java:421)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.interception.ContainerRequestFilterRegistry.postMatch(ContainerRequestFilterRegistry.java:57)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodInvoker.<init>(ResourceMethodInvoker.java:115)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.processMethod(ResourceMethodRegistry.java:345)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.register(ResourceMethodRegistry.java:272)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:223)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:195)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:181)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addResourceFactory(ResourceMethodRegistry.java:158)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ResourceMethodRegistry.addPerRequestResource(ResourceMethodRegistry.java:77)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.processApplication(ServletContainerDispatcher.java:178)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:104)
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36)
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:117) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.RunAsLifecycleInterceptor.init(RunAsLifecycleInterceptor.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.LifecyleInterceptorInvocation.proceed(LifecyleInterceptorInvocation.java:103) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet$DefaultInstanceStrategy.start(ManagedServlet.java:300) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ManagedServlet.createServlet(ManagedServlet.java:140) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:579) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl$2.call(DeploymentManagerImpl.java:550) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:42) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at io.undertow.servlet//io.undertow.servlet.core.DeploymentManagerImpl.start(DeploymentManagerImpl.java:592) [undertow-servlet-2.0.0.Final.jar:2.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:97) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
at org.wildfly.extension.undertow//org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.run(UndertowDeploymentService.java:78) [wildfly-undertow-12.0.0.Final.jar:12.0.0.Final]
... 8 more


Caused by: WfaException{Message: No EJB was found matching field 'restApiLogger' of class class com.netapp.wfa.rs.RestApplicationMapper, Cause: null}
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:128)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:70)
at deployment.wfa-0.5.ear.common-0.5.jar//com.netapp.wfa.common.SessionUtil.injectDependencies(SessionUtil.java:66)
at deployment.wfa-0.5.ear.rest-facade-0.5.war//com.netapp.wfa.rs.RestApplicationMapper.(RestApplicationMapper.java:21)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [java.base:]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [java.base:]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [java.base:]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) [java.base:]
at org.jboss.resteasy.resteasy-jaxrs//org.jboss.resteasy.core.ConstructorInjectorImpl.construct(ConstructorInjectorImpl.java:150)
... 45 more



Code that is causing the exception



public class SessionUtil {
public static final String CONTEXT_NAME = "java:global/" + EarUtils.getEarName();
private List<Object> deployedEjbList; //Note: this is lazy initialized
private Map<Class, Object> deployedEjbByInterface; //Note: this is (very) lazy initialized

private static SessionUtil instance = new SessionUtil();

public static <P> P injectDependencies(P pojo) {
return injectDependencies(pojo, null);
}

public static <P> P injectDependencies(P pojo, EntityManager entityManager) {
return instance.injectDependencies(pojo, entityManager, null, null);
}

protected <P> P injectDependencies(P pojo, EntityManager entityManager, SessionContext sessionContext, UserTransaction userTransaction) {
if (pojo == null) return null;

// Loop over the class hierarchy of the pojo
for (Class clazz = pojo.getClass(); !clazz.equals(Object.class); clazz = clazz.getSuperclass()) {

// For each class, iterate over its field and look for EJB annotations
for (Field field : clazz.getDeclaredFields()) {

// Lookup and inject to @EJB annotated member variables
if (field.isAnnotationPresent(EJB.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Get the EJB to be assigned to this field
Object ejb = getEjbForField(fieldClass);
if (ejb == null) {
throw new WfaException("No EJB was found matching field '" + field.getName() + "' of class " + clazz);
}

// Assign the EJB to the field
assignEjbToField(pojo, clazz, field, ejb);
}

// Inject an entityManager to @PersistenceContext annotated member variables
else if (field.isAnnotationPresent(PersistenceContext.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

if (!EntityManager.class.equals(fieldClass)) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " is annotated with PersistenceContext but isn't EntityManager");
}

// Assign the EntityManager to the field
assignEjbToField(pojo, clazz, field, entityManager);
}

// Inject a data-source to @Resource annotated member variables with the appropriate class
else if (field.isAnnotationPresent(Resource.class)) {

// Get field class and make sure the field is an interface
Class<?> fieldClass = getFieldInterface(clazz, field);

// Assign the DataSource to the field
if (DataSource.class.equals(fieldClass)) {
String dataSourceName = field.getAnnotation(Resource.class).mappedName();
assignEjbToField(pojo, clazz, field, getDataSource(dataSourceName));
}

// Assign the SessionContext to the field
else if (SessionContext.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, sessionContext);
}
// Assign the SessionContext to the field
else if (UserTransaction.class.equals(fieldClass)) {
assignEjbToField(pojo, clazz, field, userTransaction);
}
}
}
}

return pojo;
}

public static Map<Class, Object> getDeployedEjbByInterface() {
if (instance.deployedEjbByInterface == null || instance.deployedEjbByInterface.isEmpty()) {
instance.initDeployedEjbByInterface();
}

return instance.deployedEjbByInterface;
}

protected synchronized List<Object> getDeployedEjbList() {
if (deployedEjbList == null) {
deployedEjbList = initDeployedEjbList();
}

return deployedEjbList;
}

private void initDeployedEjbByInterface() {
// Crate a map from EJB interfaces to EJB instances.
deployedEjbByInterface = new HashMap<>();
for (Object ejb : getDeployedEjbList()) {
for (Class anInterface : ejb.getClass().getInterfaces()) {

// Register only interfaces annotated as "remote" or "local"
if (anInterface.getAnnotation(Remote.class) != null || anInterface.getAnnotation(Local.class) != null) {
deployedEjbByInterface.put(anInterface, ejb);
}
}
}
}

private List<Object> initDeployedEjbList() {
InitialContext context = null;
NamingEnumeration<NameClassPair> allWfaEjbNameAndClass = null;
NamingEnumeration<NameClassPair> internalNamingEnumeration = null;
try {
/**
* Enumerate the names bound in the named context
*/
context = new InitialContext();

allWfaEjbNameAndClass = context.list(CONTEXT_NAME);

/**
* Iterate the entries in the WFA EAR looking for EJBs with remote/local interfaces
*/
deployedEjbList = new LinkedList<>();
while (allWfaEjbNameAndClass.hasMore()) {
NameClassPair jarNameAndClass = allWfaEjbNameAndClass.next();

internalNamingEnumeration = context.list(CONTEXT_NAME + "/" + jarNameAndClass.getName());

while (internalNamingEnumeration.hasMore()) {
NameClassPair ejbNameAndClass = internalNamingEnumeration.next();
// Skip EJB names with "!" in it as they are duplicate
if (ejbNameAndClass.getName().indexOf('!') >= 0) continue;

Object ejb = silentLookup(context, CONTEXT_NAME + "/" + jarNameAndClass.getName() + "/" + ejbNameAndClass.getName());
if (ejb != null) {
deployedEjbList.add(ejb);
}
}
}

return deployedEjbList;

} catch (NamingException e) {
throw new WfaException("Failed to list EJBs in :" + CONTEXT_NAME, e);
} finally {

silentClose(allWfaEjbNameAndClass);
silentClose(internalNamingEnumeration);
silentClose(context);
}
}

private Object silentLookup(Context context, String name) {
try {

return context.lookup(name);

} catch (NamingException e) {
return null;
}
}

private static void silentClose(NamingEnumeration<NameClassPair> namingEnumeration) {
if (namingEnumeration != null) {
try {
namingEnumeration.close();
} catch (NamingException e) {
LOGGER.error("Failed to close NamingEnumeration", e);
}
}
}

protected Object getEjbForField(Class<?> fieldClass) {
Object obj = getDeployedEjbByInterface().get(fieldClass);

// If no EJB was found, flush the cache and try again before giving up
if (obj == null) {
reset();
obj = getDeployedEjbByInterface().get(fieldClass);
}

return obj;
}

public static synchronized void reset() {
instance.deployedEjbList = null;
instance.deployedEjbByInterface = null;
}

private Class<?> getFieldInterface(Class clazz, Field field) {
Class<?> fieldClass = field.getType();
if (!fieldClass.isInterface()) {
throw new WfaException("Field '" + field.getName() + "' of class " + clazz + " isn't an interface");
}
return fieldClass;
}

private <P> void assignEjbToField(P pojo, Class clazz, Field field, Object ejb) {
boolean fieldAccessible = field.isAccessible();
field.setAccessible(true);
try {
field.set(pojo, ejb);
} catch (Exception e) {
throw new WfaException("Failed to inject EJB to member '" + field.getName() + "' of class: " + clazz, e);
} finally {
field.setAccessible(fieldAccessible);
}
}
}


My Application is running on Wildfly 12 and Java 8. Now I want to upgrade to Java 11, then I got this issue. Can anyone pls help me solve this?







java wildfly jndi






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 6:34







user3301924

















asked Nov 16 '18 at 7:02









user3301924user3301924

11




11








  • 1





    Hi and welcome to SO. Please add the code that is leading to this exception - otherwise it is hard for us to see what exactly was done in order to get this exception.

    – quant
    Nov 16 '18 at 7:05











  • And also please use code formatting. makes it easier to read! Welcome

    – Clomez
    Nov 16 '18 at 7:10











  • Hi quant, Thanks for the suggestion. I have added the code that is causing the exception.

    – user3301924
    Nov 19 '18 at 6:40














  • 1





    Hi and welcome to SO. Please add the code that is leading to this exception - otherwise it is hard for us to see what exactly was done in order to get this exception.

    – quant
    Nov 16 '18 at 7:05











  • And also please use code formatting. makes it easier to read! Welcome

    – Clomez
    Nov 16 '18 at 7:10











  • Hi quant, Thanks for the suggestion. I have added the code that is causing the exception.

    – user3301924
    Nov 19 '18 at 6:40








1




1





Hi and welcome to SO. Please add the code that is leading to this exception - otherwise it is hard for us to see what exactly was done in order to get this exception.

– quant
Nov 16 '18 at 7:05





Hi and welcome to SO. Please add the code that is leading to this exception - otherwise it is hard for us to see what exactly was done in order to get this exception.

– quant
Nov 16 '18 at 7:05













And also please use code formatting. makes it easier to read! Welcome

– Clomez
Nov 16 '18 at 7:10





And also please use code formatting. makes it easier to read! Welcome

– Clomez
Nov 16 '18 at 7:10













Hi quant, Thanks for the suggestion. I have added the code that is causing the exception.

– user3301924
Nov 19 '18 at 6:40





Hi quant, Thanks for the suggestion. I have added the code that is causing the exception.

– user3301924
Nov 19 '18 at 6:40












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332942%2fjava-lang-runtimeexception-resteasy003325-failed-to-construct-public%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53332942%2fjava-lang-runtimeexception-resteasy003325-failed-to-construct-public%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Xamarin.iOS Cant Deploy on Iphone

Glorious Revolution

Dulmage-Mendelsohn matrix decomposition in Python