Problem when deploying project with web socket on Jetty 9.2.13.v20150730 - websocket

I've experienced a problem while migrating an app from PrimeFaces 5.2 to 10.
This problem is related to migration of web socket implementation from Primefaces to Omnifaces.
The versions I'm using:
PF: 10.0.0
PF extensions: 10.0.6
Omnifaces 2.7.7
CDI 1.1
JSF 2.2
I don't have anything fancy, just a simple PushBean which sends a message.
I've tried downgrading to PF8, but, as expected, the result is the same.
The configuration is made as requested in the documentation, in my web.xml file having this flag enabled:
<context-param>
<param-name>org.omnifaces.SOCKET_ENDPOINT_ENABLED</param-name>
<param-value>true</param-value>
</context-param>
However, when I try to deploy my app to jetty, I'm receiving the following error:
java.lang.IllegalStateException: OmniFaces failed to initialize! Report an issue to OmniFaces.
at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:88)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:800)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
.
.
.
Caused by: java.lang.RuntimeException: Cannot load platform configurator
at javax.websocket.server.ServerEndpointConfig$Configurator.fetchContainerDefaultConfigurator(ServerEndpointConfig.java:123)
at javax.websocket.server.DefaultServerEndpointConfig.<init>(DefaultServerEndpointConfig.java:85)
at javax.websocket.server.ServerEndpointConfig$Builder.build(ServerEndpointConfig.java:301)
at org.omnifaces.cdi.push.Socket.registerEndpointIfNecessary(Socket.java:1114)
at org.omnifaces.ApplicationListener.contextInitialized(ApplicationListener.java:85)
at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:800)
at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:444)
at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:791)
at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:294)
I'm guessing that there is something that I'm not doing right, but, I don't know exactly what is it.
Can you please, give a little hand?
Thanks in advance!

The stacktrace / exception ...
Caused by: java.lang.RuntimeException: Cannot load platform configurator
at javax.websocket.server.ServerEndpointConfig$Configurator.fetchContainerDefaultConfigurator(ServerEndpointConfig.java:123)
at javax.websocket.server.DefaultServerEndpointConfig.<init>(DefaultServerEndpointConfig.java:85)
at javax.websocket.server.ServerEndpointConfig$Builder.build(ServerEndpointConfig.java:301)
This is coming from the javax.websocket API jar, when it attempts to find the Server Container Default Configuration (in other words, the implementation specific defaults, which would be Jetty)
If you are running Jetty, you need to be including the jetty support jar for javax.websocket.server in your classpath.
Which on Jetty 9.2.x would be the javax-websocket-server-impl-<ver>.jar file (and associated dependencies).
Per #BalusC, omnifaces is just a web-fragment deployed in your WAR's WEB-INF/lib.
That means you have to enable support for websocket on the Jetty server side.
For standalone (using ${jetty.base} and ${jetty.home} split) this means enabling the correct module for your version of Jetty.
Jetty ver
WebSocket spec
Module
Jetty 8.x and older
n/a
n/a
Jetty 9.0.x
n/a
n/a
Jetty 9.1.x
javax.websocket (beta)
websocket
Jetty 9.2.x - 9.4.x
javax.websocket 1.0
websocket
Jetty 10.0.x
javax.websocket 1.1
websocket-javax
Jetty 11.0.x
jakarta.websocket 2.0
websocket-jakarta
To do that you'll use the command line.
Jetty 9.x
[~]$ cd /path/to/my-jetty-base
[my-jetty-base]$ java -jar /path/to/jetty-home/start.jar
--add-to-start=websocket
Jetty 10+
[~]$ cd /path/to/my-jetty-base
[my-jetty-base]$ java -jar /path/to/jetty-home/start.jar
--add-module=websocket-javax

Related

NoClassDefFoundError: Could not initialize class java.awt.image.DataBuffer --> When try to load a PNG Image in Spring Boot

I have a Spring Boot app that basically receives a JSON from the client side and create/return a PDF.
I can load JPG images without problem. But when I load PNG files I have this exception. My Spring Boot "war" app is running inside a Tomcat.
If I execute the Spring Boot app by "java -jar ...", it works well.
Apache Tomcat/9.0.29
Headless OpenJDK 64-Bit VM 1.8
Spring Boot 2.2.1
OpenPDF 1.3
CentOS Linux 7
2020-02-24 01:57:14,042 ERROR [http-nio-8080-exec-217] org.springframework.boot.web.servlet.support.ErrorPageFilter: Forwarding to error page from request [/pdf/create] due to exception [Could not initialize class java.awt.image.DataBuffer]
java.lang.NoClassDefFoundError: Could not initialize class java.awt.image.DataBuffer
at javax.imageio.ImageTypeSpecifier.createComponentCM(ImageTypeSpecifier.java:249)
at javax.imageio.ImageTypeSpecifier$Interleaved.<init>(ImageTypeSpecifier.java:305)
at javax.imageio.ImageTypeSpecifier.createInterleaved(ImageTypeSpecifier.java:399)
at javax.imageio.ImageTypeSpecifier.createSpecifier(ImageTypeSpecifier.java:1169)
at javax.imageio.ImageTypeSpecifier.getSpecifier(ImageTypeSpecifier.java:1118)
at javax.imageio.ImageTypeSpecifier.createFromBufferedImageType(ImageTypeSpecifier.java:901)
at com.sun.imageio.plugins.png.PNGImageReader.getImageTypes(PNGImageReader.java:1531)
at com.sun.imageio.plugins.png.PNGImageReader.readImage(PNGImageReader.java:1318)
at com.sun.imageio.plugins.png.PNGImageReader.read(PNGImageReader.java:1614)
at javax.imageio.ImageIO.read(ImageIO.java:1462)
at javax.imageio.ImageIO.read(ImageIO.java:1357)
at com.lowagie.text.ImageLoader.getPngImage(ImageLoader.java:76)
at com.lowagie.text.Image.getInstance(Image.java:284)
at com.company.myapp.service.pdf.pages.Page00.render(Page00.java:69)
at com.company.myapp.service.pdf.pages.PageImpl.<init>(PageImpl.java:27)
at com.company.myapp.service.pdf.pages.Page00.<init>(Page00.java:21)
at com.company.myapp.service.PdfServiceImpl.getPDF(PdfServiceImpl.java:33)
at com.company.myapp.controller.PdfController.generate(PdfController.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Issue in Jboss 7.2.2 migration

I am deploying a WAR file to JBoss EAP 7.2.2. During deployment, I am getting
"Caused by: java.lang.IllegalArgumentException: Unable to load generated mapper class com.amadeus.jcp.services.ttr.display.structured.builder.response.selma.mapper.offer.DisplayTripCartResponseOfferQuotationMapperSelmaGeneratedClass"
which is caused by "Caused by: java.lang.ClassNotFoundException: com.amadeus.jcp.services.ttr.display.structured.builder.response.selma.mapper.offer.DisplayTripCartResponseOfferQuotationMapperSelmaGeneratedClass"
It is a selma generated class and available in a jar inside WEB-INF/lib.
Same WAR file is deploying successfully in JBoss EAP 7.1.
As per class loader hierarchy, it should be identified but not happening.
Anybody have any idea of this issue, please help.
Verified standalone.xml and jboss-deployment-structure.xml. Using same version before and after migration except for name space version upgrade to subsystems.
Using Java 1.8.0_191

JSF 2.3 on EAP 7

I would like to upgrade to JSF 2.3 on an Jboss EAP 7.
I followed this guide:
https://docs.jboss.org/author/display/WFLY10/JSF+Configuration#JSFConfiguration-ConfiguringaJSFapptouseanondefaultJSFimplementation
I splitted the JSF 2.3 jar following this guide:
How to install one jar variant of JSF (javax.faces.jar) on WildFly
However, when I start EAP 7 I get this error:
2017-04-30 12:55:00,280 WARN (JSFDependencyProcessor.java:75) = WFLYJSF0005: Unknown JSF version 'mojarra-2.3.0'. Default version 'mojarra-2.3.0' will be used instead.
2017-04-30 12:55:00,281 ERROR (ServiceControllerImpl.java:1955) = MSC000001: Failed to start service jboss.deployment.unit."monitoring.war".DEPENDENCIES: org.jboss.msc.service.StartException in service jboss.deployment.unit."monitoring.war".DEPENDENCIES: WFLYSRV0153: Failed to process phase DEPENDENCIES of deployment "monitoring.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:154)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
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.as.server.deployment.DeploymentUnitProcessingException: WFLYJSF0014: Default JSF implementation slot 'mojarra-2.3.0' is invalid
at org.jboss.as.jsf.deployment.JSFDependencyProcessor.deploy(JSFDependencyProcessor.java:80)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:147)
... 5 more
Does anybody successfully upgraded EAP 7 to JSF 2.3?
I made a mistake by misreading the place where to put all the needed jars.
For instance, the module javax.faces.api I put in the folder:
EAP_HOME/modules/system/layers/base/javax/faces/api/JSF_IMPL
Instead, it needed to go to:
EAP_HOME/modules/javax/faces/api/JSF_IMPL.
It was specified like this in the guide, but for other modules (Oracle JDBC Driver...) I needed to put stuff directly under the base folder. Apparently, for JSF, this needs to be in the root of the modules folder...
Now it is loaded correctly and, when I use LOG.info(FacesContext.class.getPackage().getImplementationVersion()); it prints 2017-05-02 08:59:47,872 INFO (Web.java:66) = 2.3.0

JBoss 5 - Caused by: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator

I keep getting that exception when I run JBoss. I'm in the process of migrating an application from JBoss 4.2.3 to JBoss 5.
First I had to migrate from Spring 2.5 to Spring 3.0.3, then from spring-jpa to spring-orm due to exceptions I was getting and solutions I found on google.
But now I've got that one and I'm not able to solve it. I'm also using Hibernate 3.5.4 Final.
This is the exception:
Caused by: java.lang.NoSuchMethodException: org.hibernate.validator.ClassValidator.<init>(java.lang.Class, java.util.ResourceBundle, org.hibernate.validator.MessageInterpolator, java.util.Map, org.hibernate.annotations.common.reflection.ReflectionManager)
at java.lang.Class.getConstructor0(Class.java:2706)
at java.lang.Class.getDeclaredConstructor(Class.java:1985)
at org.hibernate.cfg.AnnotationConfiguration.applyHibernateValidatorLegacyConstraintsOnDDL(AnnotationConfiguration.java:443)
... 106 more
There might be a conflict between Hibernate versions, as JBoss 5+ comes bundled with Hibernate. Make sure that you only have one version of Hibernate in your server (check the /lib dir).

How to separate ear classloader and system classloader in JBoss 6?

I'm trying to upgrade from JBoss 4.2.1 to JBoss 6. In JBoss 4.2.1, we are manually deploying our application as an exploded war and everything works beautifully.
I'm running into problems because the application that I am trying to deploy uses versions of 3rd party libraries that are older than the ones that JBoss 6 now includes by default. The result of this is that I'm getting classloader conflicts all over the place and the application won't even start.
At present, I have tried using the JBoss Classloading Documentation as well as the scanty bits of documentation for jboss-classloading.xml and haven't had any success.
Has anyone out there managed to do this successfully? If you have, how did you do it?
I've included a stack trace below in case it offers any useful information.
Caused by: java.lang.Error: Error visiting "/C:/jboss6/server/default/deploy/app.war/WEB-INF/lib/jaxb-xjc-2.1.12.jar/1.0/com/sun/codemodel/JConditional.class"
at org.jboss.classloading.plugins.vfs.VFSResourceVisitor.visit(VFSResourceVisitor.java:268) [jboss-classloading-vfs.jar:2.2.0.Alpha9]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:407) [jboss-vfs.jar:3.0.0.CR5]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:409) [jboss-vfs.jar:3.0.0.CR5]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:409) [jboss-vfs.jar:3.0.0.CR5]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:409) [jboss-vfs.jar:3.0.0.CR5]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:409) [jboss-vfs.jar:3.0.0.CR5]
at org.jboss.vfs.VirtualFile.visit(VirtualFile.java:395) [jboss-vfs.jar:3.0.0.CR5]
at org.jboss.classloading.plugins.vfs.VFSResourceVisitor.visit(VFSResourceVisitor.java:102) [jboss-classloading-vfs.jar:2.2.0.Alpha9]
at org.jboss.deployers.vfs.plugins.classloader.VFSDeploymentClassLoaderPolicyModule.visit(VFSDeploymentClassLoaderPolicyModule.java:181) [:2.2.0.Alpha8]
at org.jboss.scanning.plugins.DeploymentUnitScanner.scan(DeploymentUnitScanner.java:111) [:1.0.0.Alpha7]
at org.jboss.scanning.spi.helpers.UrlScanner.scan(UrlScanner.java:96) [:1.0.0.Alpha7]
at org.jboss.scanning.deployers.ScanningDeployer.deploy(ScanningDeployer.java:90) [:1.0.0.Alpha7]
at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:179) [:2.2.0.Alpha8]
... 41 more
Have you tried "java2ParentDelegation=false"? Also you might find the below two useful
jboss classloading usecases
jee-j2ee-classloading-standard
Some links on fixing JAXB and JBOSS issues
http://kishantha.blogspot.com/2010/03/fixing-jaxb-linkageerror-in-jboss-with.html
https://issues.jboss.org/browse/JBWS-1931
http://community.jboss.org/wiki/LinkageErrorWithJBoss5Java6
http://community.jboss.org/message/568820
We use the following in ear-deployer-jboss-beans.xml
<bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
<property name="isolated">true</property>
</bean>

Resources