Reputation: 1403
Trying to get an EJB to notify my XHTML JSF page when a document (row) has been inserted into a MongoDB collection.
Got JSF 2.3 working thanks to the answer to my earlier question:
However after adding the serverside code to my EJB and trying to deploy my EAR to WildFly 12.0.0.Final I get a java.lang.ClassNotFoundException for PushContext:
Caused by: java.lang.RuntimeException: WFLYSRV0177: Error getting reflective information for class com.notifywell.ejb.FoodsCosmeticsMedicinesEJB with ClassLoader ModuleClassLoader for Module "deployment.NOTiFYwell.ear.NOTiFYwellJAR.jar" from Service Module Loader
at java.lang.Class.getDeclaredFields0(Native Method)
at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
at java.lang.Class.getDeclaredFields(Class.java:1916)
at org.jboss.as.server.deployment.reflect.ClassReflectionIndex.<init>(ClassReflectionIndex.java:72)
at org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex.getClassIndex(DeploymentReflectionIndex.java:70)
... 13 more
Caused by: java.lang.ClassNotFoundException: javax.faces.push.PushContext from [Module "deployment.NOTiFYwell.ear.NOTiFYwellJAR.jar" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:199)
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:412)
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:400)
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:116)
... 18 more
used in EJB:
@Inject
@Push
private PushContext push;
contained in:
jboss-jsf-api_2.3_spec-2.3.3.SP1.jar
This occurs when I add the @Inject
to the @Push
.
Any issues with CDI in WildFly 12 and/or JSF 2.3?
Upvotes: 2
Views: 1512
Reputation: 1108852
used in EJB:
@Inject @Push
You should never use frontend-targeted libraries in EJBs. This way your EJBs become tight coupled to the JSF frontend and totally unreusable for other frontends such as JAX-RS, JSP/Servlet, etc.
The @Push
documentation even explicitly mentions to inject it in WAR side only.
add the 'jboss-jsf-api_2.3_spec-2.3.3.SP1.jar' to my deployed EAR/JAR:
You should never add duplicate classes to the runtime classpath. It will only confuse the class loaders. The particular library is already provided by the target runtime (WildFly) itself. You do not need to provide it from the deployment on.
Any issues with CDI in WildFly 12 and/or JSF 2.3?
Not for me. The OmniFaces showcase currently runs WildFly 12 with JSF 2.3 and the OmniFaces counterpart of @Push
works just fine.
You only need to keep in mind to explicitly instruct WildFly 12 to use standalone-ee8.xml
when you intend to use JSF 2.3 on it. Also when used in the IDE. In Eclipse, when creating the server, you can specify it in the Configuration file entry of New Server wizard, which defaults to standalone.xml
.
If you're still facing class loading trouble, then it can only mean that you have messed up the runtime classpath in other way. This can have more causes which are not visible in the information provided so far. For a starter like you who doesn't immediately mention the classpath configuration in a question about classpath trouble (and thus indicates ignorance about it), it's best to not mess around with the runtime classpath (or the "Build Path" and "Libraries" as called in the average IDE) until you grok it. Java EE provides by default already everything out the box, there's absolutely no need to adjust libraries in the project.
Leave everything as default, inject @Push
in WAR instead of EJB and tell WildFly to run in EE8 mode and everything should go well.
Upvotes: 8