how to add jsf com.sun.faces in websphere 9 - java

I want to start my app using com.sun.faces jsf and primefaces dependency in websphere 9.
The part of pox.xml:
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.13</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.13</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.2</version>
</dependency>
I added jsf-impl-2.2.8-30.jar and jsf-api-2.2.8-30.jar to shared libs in WebSphere (Enterprise Applications > app_name > Shared library references, for application and for module) and got exception in log:
Could not invoke an operation on object: WebSphere:name=ApplicationManager,process=server1,platform=proxy,node=OPOLSKYNode01,version=9.0.0.9,type=ApplicationManager,mbeanIdentifier=ApplicationManager,cell=OPOLSKYNode01Cell,spec=1.0 because of an mbean exception: com.ibm.ws.exception.RuntimeError: java.lang.RuntimeException: com.ibm.ws.cdi.CDIRuntimeException: com.ibm.ws.cdi.CDIDeploymentRuntimeException: org.jboss.weld.exceptions.DefinitionException: Exception List with 1 exceptions:
Exception 0 :
javax.enterprise.event.ObserverException
at java.lang.J9VMInternals.newInstanceImpl(Native Method)
....
Caused by: java.util.ServiceConfigurationError: com.sun.faces.util.cdi11.CDIUtil: Provider com.sun.faces.util.cdi11.CDIUtilImpl not a subtype
...
Later I found that there was a warning written in websphere (Enterprise Applications > app_name > JSP and JSF options):
Version 9.0 and later nodes use the MyFaces JSF implementation, even if SunRI is selected in a mixed-cell environment. For more configuration information, read about JavaServer Faces in the product documentation.
And I tried to add a shared libraries with mojarra-jsf-impl-2.0.0-b04.jar and mojarra-jsf-api-2.0.0-b04.jar
but got:
com.ibm.ws.classloader.CompoundClassLoader#bce1c60f[war:isclite/isclite.war]
Local ClassPath: C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\isclite.war\WEB-INF\classes;C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\isclite.war\WEB-INF\lib\abdera.client.0.2.2-incubating.jar;C:\Program
...
00000093 annotations W ScannerContextImpl getInputDataForClass Class loader [
com.ibm.ws.classloader.CompoundClassLoader#2d433080[app:isclite]
Local ClassPath: C:\Program Files\IBM\WebSphere\AppServer\systemApps\isclite.ear\lib\batik-all.jar;C:\Program
...
Help me please!
Is it possible to start app with jsf dependency in websphere ?

Related

I'm using JakartaEE and making a "hello world" kind of restfulAPI, can't get a return string by visiting URL

Providing every step I took with this short video:
https://youtu.be/hbSr8sRYuOk
Project code here: https://github.com/LJonn/restapiHelloWorld
Running everything on a local server on tomcat.
I'm having this issue for quite some time and ran out of ideas where the problem might be...
I tried URL's such as these: "http://localhost:8080/api/hello" and "http://localhost:8080/helloworld/api/hello" and expected one of these to work.
Running http://localhost:8080/manager/text/list shows that helloworld.war is deployed fine and working:
OK - Listed applications for virtual host [localhost]
/:running:0:ROOT
/helloworld:running:0:helloworld
/examples:running:0:examples
/host-manager:running:0:host-manager
/manager:running:0:manager
/docs:running:0:docs
So why I still get a HTTP Status 404 page? What could I try to do to find the issue?
These are my project's Maven dependencies:
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-web-api</artifactId>
<version>9.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
Thanks to Nikos Paraskevopoulos comment it looks like changing from Tomcat to TomEE might fix the issue, but now I'm running into a problem where the .war file can't be deployed/started, probably some sort of versions compatibility issue, tomcat manager GUI gives this error when trying to start the .war file:
FAIL - Application at context path [/helloworld] could not be started
FAIL - Encountered exception [org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/helloworld]]]
Looking to manager logs It looks like it has something to do with annotations and Java 16 maybe?:
...
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 60
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:195)
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:176)
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:162)
at org.apache.xbean.asm7.ClassReader.<init>(ClassReader.java:283)
at org.apache.xbean.finder.AnnotationFinder.readClassDef(AnnotationFinder.java:1176)
... 52 more
01-Sep-2021 15:25:02.185 INFO [http-nio-8080-exec-3] org.apache.catalina.core.ApplicationContext.log HTMLManager: list: Listing contexts for virtual host 'localhost'
I've tried to check JRE version on Eclipse and it's 16.0.2 and it looks to me that the same version is running on tomcat.
Tomcat 10.0 and 10.1 are not full Jakarta EE 9.1 application servers: you shouldn't use the jakarta.jakartaee-web-api artifact, which would imply that the runtime supports all Jakarta EE 9.1 Web Profile technologies.
Tomcat does not implement all the specs required in Web Profile. At least four other products do. See this list for Jakarta Web Profile 9.1:
Apache TomEE
Eclipse Glassfish
IBM Open Liberty
Red Hat WildFly
You can find the list of supported technologies on Tomcat's web site and for Tomcat 10 they translate to this list shown as a Maven POM snippet.
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>5.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp</groupId>
<artifactId>jakarta.servlet.jsp-api</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.el</groupId>
<artifactId>jakarta.el-api</artifactId>
<version>4.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
<version>2.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.security.auth.message</groupId>
<artifactId>jakarta.security.auth.message-api</artifactId>
<version>2.0.0-RC1</version>
<scope>provided</scope>
</dependency>
Since Servlet 3.0, additional Jakarta EE specifications can be added using the servlet pluggability mechanism. To use JAX-RS you need to add:
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.inject</groupId>
<artifactId>jersey-hk2</artifactId>
<version>3.0.2</version>
</dependency>
or an equivalent configuration using other JAX-RS implementations.

Tomcat7 websocket libs clash with JHipster's

I have built backend application with JHipster 4.14.1 which uses websockets.
I need to deploy this app to the Tomcat7x.
Application deploys successfully, but when I try to connect to it's websocket endpoint I get:
Caused by: java.lang.ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server.ServerContainer
For what I found as solutions I have tried to add
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
but that didn't help.
Help appreciated.

EJB ETL NoClassDefFoundError: org.apache.poi.util.SAXHelper during runtime

Root pom has the following dependencies,
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>3.16</version>
</dependency>
But during runtime, during etl process following error occurs,
EJB threw an unexpected (non-declared) exception during invocation of method "****" on bean "BeanId(***-ear#***-ejb.jar#***ServiceImpl, null)". Exception data: java.lang.NoClassDefFoundError: org.apache.poi.util.SAXHelper
Root cause is NoClassDefFoundError in the following code snippet,
XMLReader parser = SAXHelper.newXMLReader();
Environment used,
JDK 1.6.0_35
Websphere Application Server v8.0
Eclipse Juno Service Release 2
Full stack trace can be found here
Caused by: java.lang.ClassNotFoundException: org.apache.poi.util.SAXHelper
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:230)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:703)
at java.lang.ClassLoader.loadClass(ClassLoader.java:682)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:123)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:566)
at java.lang.ClassLoader.loadClass(ClassLoader.java:665)
... 87 more
note: I have opened the ear archive and found the respective jars available. Checked Eclipse java build path also. Everything seems to be fine.
Thanks.
SAXHelper is in poi-ooxml-3.16.jar. I suspect that one of the static initializers in this class is failing.
https://github.com/apache/poi/blob/trunk/src/ooxml/java/org/apache/poi/util/SAXHelper.java

"Unknow type constant pool at position X" in tomcat logs since java 8

I have a Java JSF2 web based application deployed on a Tomcat server, and since we moved to Java 8 / Tomcat 8 this error appears a lot in the tomcat output:
déc. 05, 2016 10:51:07 AM com.sun.faces.config.JavaClassScanningAnnotationScanner$ConstantPoolInfo containsAnnotation
GRAVE: Unknow type constant pool 0 at position 178
I tried different stuff to fix this warning but it always comes back.
Is this log a symptom of any issue ? Is it just a normal output? Is there a way to fix this?
I was presenting the same problem
Today I updated my pom.xml file to jsf version: 2.2.15 and that ERROR log was gone.
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>${jsf.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>${jsf.version}</version>
<scope>provided</scope>
</dependency>
From my research it appears that this was a bug in JSF implementation and was fixed in JSF version 2.3.0-m02
Reported Bugs:
http://github.com/javaserverfaces/mojarra/issues/3736
https://github.com/javaserverfaces/mojarra/issues/3780
Where to obtain fixed versions of the JSF implementation
http://repo1.maven.org/maven2/javax/faces/javax.faces-api/2.2/
http://repo1.maven.org/maven2/org/glassfish/javax.faces/2.3.0-m02/
Or update maven POM dependency with (2.3.0-m02 or higher):
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.3.0-m02</version>
I had the same same problem. I solved after updating my pom.xml file to 2.2.11.
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.2.11</version>
<artifactId>jsf-impl</artifactId>
<version>2.2.11</version>
The postConstruct wasn't been execute in some ManagedBean, without any error.

AbstractCreatorProcessor class not found error

While setting up adopt openjdk 8 with Tomcat 9 with my existing application, I am getting the following error
Caused by: java.lang.NoClassDefFoundError: com/sun/xml/stream/buffer/AbstractCreatorProcessor
at com.sun.xml.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:363)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:321)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:230)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:211)
at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:207)
at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:114)
at javax.xml.ws.Service.<init>(Service.java:77)
at javax.xml.ws.Service.create(Service.java:707)
at org.springframework.remoting.jaxws.LocalJaxWsServiceFactory.createJaxWsService(LocalJaxWsServiceFactory.java:162)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.prepare(JaxWsPortClientInterceptor.java:357)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.afterPropertiesSet(JaxWsPortClientInterceptor.java:339)
It was working fine with Oracle JDK, is there anything I am missing for openjdk?
For openjdk you need the JAX-WS dependency library streambuffer.jar.
You can download it from here or, if you use Maven:
<!-- https://mvnrepository.com/artifact/com.sun.xml.stream.buffer/streambuffer -->
<dependency>
<groupId>com.sun.xml.stream.buffer</groupId>
<artifactId>streambuffer</artifactId>
<version>1.5.6</version>
</dependency>

Categories

Resources