javax.servlet.ServletException: Not running on Jetty, JSR-356 support unavailable - java

I am facing a problem while deploying a war on to tomcat instance,
Tomcat version details,
D:\Kiran\Kiran\Softwares DH\Webservers\apache-tomcat-7.0.63\bin>version.bat
Using CATALINA_BASE: "D:\Kiran\Kiran\Softwares DH\Webservers\apache-tomcat-7.0.63"
Using CATALINA_HOME: "D:\Kiran\Kiran\Softwares DH\Webservers\apache-tomcat-7.0.63"
Using CATALINA_TMPDIR: "D:\Kiran\Kiran\Softwares DH\Webservers\apache-tomcat-7.0.63\temp"
Using JRE_HOME: "C:\Program Files\Java\jdk1.7.0_07"
Using CLASSPATH: "D:\Kiran\Kiran\Softwares DH\Webservers\apache-tomcat-7.0.63\bin\bootstrap.jar;D:\Kiran\Kiran\Softwares DH\Webservers\apache-to
mcat-7.0.63\bin\tomcat-juli.jar"
Server version: Apache Tomcat/7.0.63
Server built: Jun 30 2015 08:08:33 UTC
Server number: 7.0.63.0
OS Name: Windows 7
OS Version: 6.1
Architecture: amd64
JVM Version: 1.7.0_07-b11
JVM Vendor: Oracle Corporation
D:\Kiran\Kiran\Softwares DH\Webservers\apache-tomcat-7.0.63\bin>
POM Dependency :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
I have created a war using maven plugin and tried to deploy on tomcat 7. I was able to deploy but unable to start the webapp. When I find the logs for it, it gave below stacktrace,
SEVERE: Error during ServletContainerInitializer processing
javax.servlet.ServletException: Not running on Jetty, JSR-356 support unavailable
at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.onStartup(WebSocketServerContainerInitializer.java:146)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5520)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.manager.ManagerServlet.start(ManagerServlet.java:1322)
at org.apache.catalina.manager.HTMLManagerServlet.start(HTMLManagerServlet.java:694)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:217)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
Any help would be appreciated.
Thank you.
Edit :
It runs fine when I run the application using STS

Search in pom.xml for
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
and remove it.

The problem is identified to be confusion over the websocket jars of tomcat and my application jars. I have removed it from the war file and it started working,
I used maven plug in to remove the jars as below,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/lib/websocket-*.jar</packagingExcludes>
</configuration>
</plugin>
The jars which were creating problem are,

As already mentioned by Kiran in another answer, the problematic libraries are websocket-*.jar(s). I encountered these dependencies to be introduced by (upgrade of) Active MQ library in a project.
So in case you have the same error, look for the maven dependency tree in your project and exclude the dependencies:
mvn dependency:tree -Dverbose -Dincludes=javax.websocket

I fixed this problem by adding a WEB-INF/web.xml file with the following contents. We need to configure Tomcat to ignore Jetty SCI(ServerContainerInitializer) implementations.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1"
metadata-complete="true">
<absolute-ordering>
<name>spring_web</name>
</absolute-ordering>
</web-app>
There are some explanation on this:
ActiveMQ
[AMQ-6154] ActiveMQ with websocket on Tomcat fails with NullPointerException at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer - ASF JIRA
HowTo FasterStartUp - Apache Tomcat - Apache Software Foundation

Related

What version of Jersey should I use with Glassfish 3.1 and Java 7?

After I added JAX-RS 2.1/Jersey 2.26+ libraries to my dynamic web project I got the next error:
Glassfish error after upload WAR file 1
The server is running Glassfish 3.1 with JDK 1.7.0_80
I tried to use Jersey 1.19.1 ZIP bundle but then Glassfish said:
Glassfish error after upload WAR file 2
The WAR file with the latest Jersey runs perfect with Tomcat 9 and Java 8 but I need this project to run with Glassfish 3.1 and Java 7.
If you can provide a link to the correct version of Jersey I would appreciate!
This is my very fisrt question so excuse any errors.
To run Jersey with Glassfish 3 you really need to exclude all Jersey.2 things from you war and either:
use the bundled Jersey.1 implementation of your Glassfish 3.1.2.2 installation (check the /lib or /modules folders you shall see it, or online documentation)
EDIT: Jersey version should be 1.11.1
<!-- Keep 1.11.1 for Jersey which is Fish's version -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.11.1</version>
<!-- <scope>provided</scope> ... set Provided scope for GF3 deployment -->
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-servlet</artifactId>
<version>1.11.1</version>
<!-- <scope>provided</scope> ... set Provided scope for GF3 deployment -->
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.11.1</version>
<!-- <scope>provided</scope> ... set Provided scope for GF3 deployment -->
</dependency>
<!-- Etc. - Organize your dependencies accordingly ... -->
replace the bundled Jersey.1 libraries of your Glassfish3 installation by another Jersey.1 implementation/libs(if you need a fresher version) - but never expect Jersey.2 to run with GF3.
Nonetheless you can actually write code that works with Jersey.1 and Jersey.2 but when you come to packaging and deployment you must build it with appropriate target JVM, dependencies and deployment descriptors - as soon as your modularization is "ok". I didn't read this post fully personnally but why not have a look here.
From Jersey latest (2.26) documentation
https://jersey.github.io/documentation/latest/modules-and-dependencies.html#d0e560
Since Jersey 2.26, all modules are build using Java SE 8 and there is no support for running it on older Java SE distributions.
So if you really want to use jersey 2.26 +, JDK should be 1.8+. No alternatives.

hibernate-entitymanager NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V

I'm deploying an EAR application built with Maven which has the following dependency in one of the modules:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
When I try to deploy the application in a Glassfish Server 4.1 I get the following error:
Fatal: java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf(Ljava/lang/String;I)V
at org.hibernate.internal.NamedQueryRepository.checkNamedQueries(NamedQueryRepository.java:149)
I made some research to solve this problem and made the following attempts:
First Attempt
I found this question and used the script in this article to clean the Glassfish's osgi-cache, as suggested in the question and in this issue of the Glassfish/Payara Github repository. Restarted the server. Same error.
Second Attempt
I found this question and tried the suggestion of the first answer, like this: looking at the dependency tree, I see that hibernate-entitymanager has the following dependency:
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
<scope>compile</scope>
</dependency>
So I searched at my Server installation and found the jboss-logging.jar. The installed version was 3.1.0-GA (I'm not sure right now, but surely it was a previous version of the dependency). I downloaded jboss-logging-3.3.0.Final.jar from the Maven Central Repository and replaced the one in my Server installation. Restarted the server. Same error.
Third Attempt
Some comments in the previous post (and others) suggested to add a property org.jboss.logging.provider=slf4j as I'm using these dependencies for logging:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.21</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.21</version>
<scope>test</scope>
</dependency>
I found some .properties files in the /glassfish/domains/domain1/config/ folder but none of them contains such a property and I don't know in which file to add that property. I also made some search in the Admin Console but I didn't found where to add properties. The only logging configuration I found was to configure logging levels.
After that I found where to put some JVM options for the Glassfish Server in the Admin Console and added -Dorg.jboss.logging.provider=slf4j as an option but did not work for me (even more, I had to reboot my computer to get Glassfish in ground zero)
Fourth Attempt
Before all this I had a problem and made another question in StackOverflow. Guided by this comment in that post I changed the project configuration but nothing happened (I solved that problem with a little change in my dependencies, answer still pending)
After all the attempts, I'm running out of ideas and the problem remains. I don't know what could be the problem. Any guide, help or answer will be really appreciated. If anybody needs more details about the situation just let me know.
Thanks in advance for your collaboration.
EDIT 1
I was searching and found this article which says something similar to what I did and adds a provided dependency for jboss-logging like this:
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
<version>3.3.0.Final</version>
<scope>provided</scope>
</dependency>
But the error remains. Apparently it's something with the Server but I can't figure out what. I'm using GlassFish Server Open Source Edition 4.1 (build 13)
I was using JBoss server 7.1 to deploy my project. In my case this error was due to the fact that the I was using jboss-logging-3.3.0.Final.jar in my project but the JBoss 7 had a jboss-logging-3.1.0.GA.jar (/opt/jboss-as-7.1.1.Final/modules/org/jboss/logging/main/) by default. So, may be this was due to the jar conflict or method was not present in the jboss-logging-3.1.0.GA.jar, I am not sure. But replacing the jboss-logging-3.1.0.GA.jar with jboss-logging-3.3.0.Final.jar and change mapping in module.xml (at the same above mentioned location) as follows
<module xmlns="urn:jboss:module:1.1" name="org.jboss.logging">
<resources>
<resource-root path="jboss-logging-3.3.0.Final.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="org.jboss.logmanager"/>
</dependencies>
</module>
And the error was gone. Hope it helps.
This is because GlassFish ships with an earlier version of JBoss Logging and this is being picked up by your application hence the NoSuchMethod error. The version of JBoss Logging shipped with GlassFish 4.1 does not have the method defined. You can try and replace the version of jboss-logging in the modules directory of glassfish this may or may not work but it looks like you tried and failed with this approach.
Another option is to upgrade to the latest Payara 4.1.1.162 which ships with JBoss Logging 3.3.0.Final.
Block Glassfish for using its own lib when project lib is provided
Just create a glassfish-web.xml file in the WEB-INF directory. The contents of the file are shown below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
 <class-loader delegate="false"/>
</glassfish-web-app>
This ensures that glassfish does not load it's internal libraries, but libraries from your project.

Netbeans 8: Project Properties -> Change EJB Java EE Version

I created a maven EJB project on Netbeans 8.0.1, when I originally created the project I didn't specify a Server for it to run on and left the Java EE Version on 5 (Thinking I'll change it later).
Now I want to change the Project properties so run uses Java EE version 6.
I cant do that. I tried looking for the (project-folder)/nbproject/project.properties file, it does not exist.
I tried re-checking out the project from git, there is only (project-folder)/src, a pom.xml and a .gitingore file, Yet Neatbeans knows this project is configured to use Java EE Version 5.
This also results in the maven build breaking:
Failed to execute goal org.apache.maven.plugins:maven-ejb-plugin:2.3:ejb (default-ejb) on project : Error assembling EJB: META-INF/ejb-jar.xml is required for ejbVersion 2.x
Any help, on how I can change the Java EE Version so it reflects on both Netbeans 8 and the maven build?
May the force be with you!
You should go to <project-folder>/nbproject/project.properties update the j2ee version:
j2ee.platform=1.6
for maven you should use:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
<ejbVersion>3.0</ejbVersion>
</configuration>
</plugin>
</plugins>
</build>
Thanks Everyone!
I ended up solving it by including an ejb-jar.xml with the module which specified an ejb 3.0 version.
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee"
version = "3.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
</ejb-jar>
Built properly and its all systems go!
Thanks #whitlaaa

JAXWS Client ServiceConfigurationError on weblogic

I have created a client to connect to external webservice. This was done by using wsimport to generate the artifacts and then copied the java classes in my existing web application.
I have tomcat on my workstation and this projects deploys and functions perfectly in this environment.
But as soon as I deploy the same to weblogic servers I get the below error.
Can you please help me understand the problem and its potential solution.
java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider weblogic.wsee.jaxws.spi.WLSProvider could not be instantiated: java.lang.ClassCastException
at java.util.ServiceLoader.fail(ServiceLoader.java:207)
at java.util.ServiceLoader.access$100(ServiceLoader.java:164)
at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:353)
at java.util.ServiceLoader$1.next(ServiceLoader.java:421)
at javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Provider.java:180)
at javax.xml.ws.spi.Provider.provider(Provider.java:140)
at javax.xml.ws.Service.<init>(Service.java:92)
Thanks in advance!
In my case importing jaxb - api did the trick
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>...</version>
</dependency>
I changed the version of jaxws-api.jar library and it worked. I was using 2.2.5 and I changed it to 2.1-1 version and it worked for me.
Also, in the META-INF/weblogic-application.xml of your EAR, put
<?xml version="1.0" encoding="UTF-8"?> <weblogic-application xmlns="http://www.bea.com/ns/weblogic/90">
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
<prefer-application-packages>
<package-name>org.springframework.*</package-name>
<package-name>javax.jws.*</package-name>
<package-name>javax.wsdl.*</package-name>
<package-name>com.ctc.wstx.*</package-name>
<package-name>javax.xml.ws.*</package-name>
<package-name>com.sun.xml.messaging.saaj.*</package-name>
</prefer-application-packages>

Maven dependency plugin not supported by maven

Im trying to download a Spring/Java code from a book to run their code and test it but unfortunately I get errors,
I see this is a common error but don't see a fix for my pom file,
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.apress.springrecipes</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>springintro</artifactId>
<name>Introduction to Spring</name>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.javaee</groupId>
<artifactId>jboss-jca-api</artifactId>
</dependency>
</dependencies>
</project>
Error
Jul 17, 2013 3:51:20 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#be41ec: startup date [Wed Jul 17 15:51:20 EDT 2013]; root of context hierarchy
Jul 17, 2013 3:51:20 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [beans.xml]
Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [beans.xml]; nested exception is java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.apress.springrecipes.hello.Main.main(Main.java:10)
Caused by: java.io.FileNotFoundException: class path resource [beans.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
... 13 more
Pom file error:
maven-dependency-plugin (goals "copy-dependencies", "unpack") is not supported by m2e.
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
What #Pace said is totally valid, and I believe OP should try to understand what m2e is doing. Personally I hate the behavior of m2e after 0.10, for which they introduced the connector concept. The concept is good but the way to tell Eclipse how to react to unsupported plugins is by seriously polluting the POM which looks awful to me. Switching back to older M2E version may make your life easier though you lose some feature.
Going back to your question, from the error message you quoted:
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
it seems suggest to me that m2e did support maven-resources-plugin >= 2.4 (I am not sure, I haven't encountered similar issue as you before). Try to make use of newer version (2.4 or after, latest is 2.6) of maven-resources-plugin in your POM, M2E may be able to pick up the settings for you.
i.e.
<project>
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
....
</pluginManagement>
....
</build>
</project>
it is always a good practice to stamp the version of plugins you used. This lead to a more "reproducible" build.
m2e is not Maven. The POM file error is saying that Eclipse's Maven plugin (m2e) does not know what to do with the "copy-dependencies":"unpack" goal. The way m2e works it has to understand what a goal does in a pom file so that it can duplicate that behavior in the Eclipse build.
There are a two main things you can do:
Tell Eclipse to ignore the goal - This will allow you to not get the error. That unpack step will never occur during Eclipse incremental builds, it will still happen when you do full Maven builds.
Install a "connector" which tells Eclipse what to do when it encounters that goal. The connector for this goal can be found here.
As for the maven-resources-plugin I don't see any other option than upgrading the plugin version specified in the POM. The error there is saying that Eclipse's Maven plugin can't work with Maven plugins that old.
I have no idea what is causing the file not found error but suspect it is because that file is contained in whatever it is that Eclipse is not unpacking.

Categories

Resources