jsfwelddeltaspikeclassloading

WELD Classloading issue after adding deltaspike to an existing primefaces maven project


I am new to primefaces and deltaspike, we initially tried with CDI conversations but had to fall back to deltaspike. I added the jars as mentioned in the https://deltaspike.apache.org/documentation/configure.html#config-maven-indep But I am getting a classloading issue with FacesMessages. I am not sure how to resolve this. Below are the logs and pom files.

11:05:14,056 WARN  [org.jboss.modules] (Weld Thread Pool -- 1) Failed to define class javax.faces.application.FacesMessage in Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base)): java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
at org.jboss.modules.Module.loadModuleClass(Module.java:605)
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.jboss.weld.annotated.slim.backed.SecurityActions.getDeclaredMethods(SecurityActions.java:41)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:194)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.computeValue(BackedAnnotatedType.java:188)
at org.jboss.weld.util.LazyValueHolder.get(LazyValueHolder.java:35)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$EagerlyInitializedLazyValueHolder.<init>(BackedAnnotatedType.java:156)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:188)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType$BackedAnnotatedMethods.<init>(BackedAnnotatedType.java:188)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.<init>(BackedAnnotatedType.java:63)
at org.jboss.weld.annotated.slim.backed.BackedAnnotatedType.of(BackedAnnotatedType.java:44)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:83)
at org.jboss.weld.resources.ClassTransformer$TransformClassToBackedAnnotatedType.load(ClassTransformer.java:80)
at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCacheValue(LoadingCacheUtils.java:49)
at org.jboss.weld.util.cache.LoadingCacheUtils.getCastCacheValue(LoadingCacheUtils.java:74)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:175)
at org.jboss.weld.resources.ClassTransformer.getBackedAnnotatedType(ClassTransformer.java:194)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:113)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.createContext(FastAnnotatedTypeLoader.java:102)
at org.jboss.weld.bootstrap.FastAnnotatedTypeLoader.loadAnnotatedType(FastAnnotatedTypeLoader.java:81)
at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:97)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:65)
at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$1.doWork(ConcurrentBeanDeployer.java:62)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jboss.threads.JBossThread.run(JBossThread.java:320)

11:05:14,065 INFO [org.jboss.weld.Bootstrap] (Weld Thread Pool -- 1) WELD-000119: Not generating any bean definitions from org.apache.deltaspike.jsf.impl.listener.request.DeltaSpikeFacesContextWrapper because of underlying class loading error: Type [unknown] not found. If this is unexpected, enable DEBUG logging to see the full error.

11:05:15,468 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-6) MSC000001: Failed to start service jboss.deployment.unit."paris-ear.ear".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."paris-ear.ear".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

Caused by:

org.jboss.weld.exceptions.DeploymentException: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
    at org.jboss.weld.executor.AbstractExecutorServices.checkForExceptions(AbstractExecutorServices.java:66)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:43)
    at org.jboss.weld.executor.AbstractExecutorServices.invokeAllAndCheckForExceptions(AbstractExecutorServices.java:51)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer.createProducersAndObservers(ConcurrentBeanDeployer.java:103)
    at org.jboss.weld.bootstrap.WeldStartup.deployBeans(WeldStartup.java:401)
    at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:83)
    at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:95)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
    ... 3 more

Caused by:

java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:446)
    at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:274)
    at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:78)
    at org.jboss.modules.Module.loadModuleClass(Module.java:605)
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363)
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351)
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93)
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
    at java.lang.Class.getDeclaredMethods(Class.java:1975)
    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:30)
    at org.jboss.weld.security.GetDeclaredMethodsAction.run(GetDeclaredMethodsAction.java:22)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.weld.util.reflection.Reflections.getNonPrivateNonStaticFinalMethod(Reflections.java:177)
    at org.jboss.weld.util.Proxies.getUnproxyableClassException(Proxies.java:218)
    at org.jboss.weld.util.Proxies.getUnproxyableTypeException(Proxies.java:180)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesExceptionInt(Proxies.java:192)
    at org.jboss.weld.util.Proxies.getUnproxyableTypesException(Proxies.java:174)
    at org.jboss.weld.util.Proxies.isTypesProxyable(Proxies.java:162)
    at org.jboss.weld.bean.ProducerMethod.<init>(ProducerMethod.java:76)
    at org.jboss.weld.bean.ProducerMethod.of(ProducerMethod.java:60)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethod(AbstractBeanDeployer.java:214)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createProducerMethods(AbstractBeanDeployer.java:199)
    at org.jboss.weld.bootstrap.AbstractBeanDeployer.createObserversProducersDisposers(AbstractBeanDeployer.java:176)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$4.doWork(ConcurrentBeanDeployer.java:106)
    at org.jboss.weld.bootstrap.ConcurrentBeanDeployer$4.doWork(ConcurrentBeanDeployer.java:103)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:63)
    at org.jboss.weld.executor.IterativeWorkerTaskFactory$1.call(IterativeWorkerTaskFactory.java:56)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at org.jboss.threads.JBossThread.run(JBossThread.java:320)

I understand that this is the root cause
java.lang.LinkageError: Failed to link javax/faces/application/FacesMessage (Module "javax.faces.api:main" from local module loader @66133adc (finder: local module finder @7bfcd12c (roots: C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules,C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base))): loader constraint violation: loader (instance of org/jboss/modules/ModuleClassLoader) previously initiated loading for a different type with name "javax/faces/application/FacesMessage"
This is the content of my modules.xml under C:\Users\amoram\jbossstudio10\runtimes\jboss-eap\modules\system\layers\base\javax\faces\api\main and it also have my jboss-jsf-api_2.2_spec-2.2.12.redhat-1.jar

<module xmlns="urn:jboss:module:1.3" name="javax.faces.api">
  <dependencies>
    <module name="com.sun.jsf-impl" />
    <module name="javax.enterprise.api" export="true" />
    <module name="javax.servlet.api" export="true" />
    <module name="javax.servlet.jsp.api" export="true" />
    <module name="javax.servlet.jstl.api" export="true" />
    <module name="javax.validation.api" export="true" />
    <module name="org.glassfish.javax.el" export="true" />
    <module name="javax.api" />
  </dependencies>

  <resources>
    <resource-root path="jboss-jsf-api_2.2_spec-2.2.12.redhat-1.jar" />
  </resources>
</module>


This is the snippet from my ejb module pom.xml

<dependency>
  <groupId>org.apache.deltaspike.core</groupId>
  <artifactId>deltaspike-core-api</artifactId>
  <version>${deltaspike.version}</version>
  <scope>compile</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.core</groupId>
  <artifactId>deltaspike-core-impl</artifactId>
  <version>${deltaspike.version}</version>
  <scope>runtime</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.modules</groupId>
  <artifactId>deltaspike-jsf-module-api</artifactId>
  <version>${deltaspike.version}</version>
  <scope>compile</scope>
</dependency>

<dependency>
  <groupId>org.apache.deltaspike.modules</groupId>
  <artifactId>deltaspike-jsf-module-impl</artifactId>
  <version>${deltaspike.version}</version>
  <scope>runtime</scope>
</dependency>

<dependency>
  <groupId>org.primefaces</groupId>
  <artifactId>primefaces</artifactId>
</dependency>

Below is the snippet from Parent pom

<properties>
  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  <!-- java ee/servlet/cdi/ejb dependencies -->
  <version.javaee7.web.spec>7.0</version.javaee7.web.spec>
  <version.jboss-servlet-api_3.1_spec>1.0.0.Final</version.jboss-servlet-api_3.1_spec>
  <version.cdi-api>1.2</version.cdi-api>
  <version.jboss-ejb-api>1.0.0.Final</version.jboss-ejb-api>

  <version.jsf>2.2.12</version.jsf>
  <version.javax.inject>1</version.javax.inject>
  <version.el-api>2.2.1</version.el-api>
  <version.validation>1.1.0.Final</version.validation>
  <version.primefaces>6.0</version.primefaces>
  <version.primefaces.extensions>6.0.0</version.primefaces.extensions>
  <version.themes>1.0.10</version.themes>

  <!-- 		<version.hibernate-c3p0>4.3.2.Final</version.hibernate-c3p0> -->
  <version.hibernate-entitymanager>5.0.9.Final</version.hibernate-entitymanager>
  <version.hibernate-core>5.0.9.Final</version.hibernate-core>
  <version.hibernate.validator>5.2.4.Final</version.hibernate.validator>
  <version.hibernate-jpa>1.0.0.Final</version.hibernate-jpa>
  <version.hibernate-annotation>3.5.6-Final</version.hibernate-annotation>
  <version.hibernate-commons-annotation>4.0.5.Final</version.hibernate-commons-annotation>
  <!-- <version.google.generic.dao>1.2.0</version.google.generic.dao> -->

  <version.commons-collections>3.2.2</version.commons-collections>
  <version.commons-lang>2.6</version.commons-lang>
  <version.commons-lang3>3.3</version.commons-lang3>
  <!--TODO required? -->
  <version.commons-config>1.10</version.commons-config>
  <version.common-beanutils>1.9.2</version.common-beanutils>
  <version.common-email>1.4</version.common-email>
  <version.common-exec>1.3</version.common-exec>

  <version.commons-fileupload>1.3</version.commons-fileupload>
  <!--TODO required? -->
  <version.commons-codec>1.10</version.commons-codec>
  <!--TODO required? -->
  <version.poi>3.12</version.poi>

  <version.joda-time>2.8.1</version.joda-time>
  <version.ojdbc6>12.1.0.2</version.ojdbc6>
  <version.dom4j>1.6.1</version.dom4j>
  <version.jxl>2.6.12</version.jxl>
  <version.xerces>2.11.0</version.xerces>

  <version.javaassist>3.15.0-GA</version.javaassist>
  <version.picketbox>4.0.7.Final</version.picketbox>
  <resteasy.version>2.3.5.Final</resteasy.version>
  <version.jgroups>3.6.4.Final</version.jgroups>
  <version.jbosscache>3.2.11.GA</version.jbosscache>
  <!-- <version.weldcore>2.3.3</version.weldcore> -->
  <version.weldcore>3.0.0.Alpha6</version.weldcore>
  <version.common-jxpath>1.3-redhat-3</version.common-jxpath>

  <version.javamail>1.5.4</version.javamail>

  <!-- Logging -->

  <version.logback>1.1.5</version.logback>
  <version.slf4j>1.7.16</version.slf4j>

  <!-- Unit testing -->
  <version.junit>4.12</version.junit>
  <version.easymock>3.1</version.easymock>

  <!-- pluggins -->

  <version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>

  <!-- DeltaSpike -->
  <deltaspike.version>1.7.2</deltaspike.version>
</properties>

<dependencyManagement>
  <dependencies>
    ...
    <dependency>
      <groupId>org.jboss.spec.javax.faces</groupId>
      <artifactId>jboss-jsf-api_2.2_spec</artifactId>
      <version>${version.jsf}</version>
    </dependency>

  </dependencies>
</dependencyManagement>
<!--  I did not have any delta spike dependency tags in parent pom, I mentioned them only in my ejb pom which is above this snippet -->

I wanted to attach my complete pom.xml files but didn't know how to do it, they are too big to add them like the modules.xml I did above. Can someone guide me please?


Solution

  • After I commented out the javax.faces.application.FacesMessage and all its occurrences from my controllers and service classes, the error disappeared. It looks like we cannot use deltaspike and jsf-api FacesMessage together as they create ambiguity?