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>
Related
I have tried a lot of solutions/ try and error which I got from stackover flow and through googling. Using Weblogic 12.2.1.3 and my project weblogic.xml
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.8/weblogic-web-app.xsd">
<security-role-assignment>
<role-name>admin</role-name>
<principal-name>Administrators</principal-name>
</security-role-assignment>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>org.opensaml</wls:package-name>
</wls:prefer-application-packages>
<wls:show-archived-real-path-enabled>true</wls:show-archived-real-path-enabled>
</wls:container-descriptor>
</wls:weblogic-web-app>
The issue is, even I mentioned in weblogic.xml about opensaml that take from my project, then also Server is taking from Oracle weblogic. It is not taking from my project. I am using 2.6.6 version of opensaml jar for my project. I have tried with <wls:package-name>org.opensaml.*</wls:package-name> but no success.
The main reason to check weblogic.xml is that when I tried to open one specific url it is showing following error in the browser. But it works for Tomcat server when you open the same url. So my assumption is weblogic.xml --> prefer-application-packages tag is not working.
java.lang.IncompatibleClassChangeError: Implementing class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at weblogic.utils.classloaders.GenericClassLoader.defineClassInternal(GenericClassLoader.java:1113)
at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:1046)
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:1038)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:990)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:104)
at weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:611)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:543)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:496)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:72)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:53)
at org.springframework.security.saml.SAMLBootstrap.postProcessBeanFactory(SAMLBootstrap.java:42)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:179)
Work Around:
When you delete com.oracle.weblogic.security.opensaml2 from
weblogic-->Module folder, the issue get fix. No need to delete
com.oracle.weblogic.security.opensaml jar.
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.
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.
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
I am working on a webapp, using spring 3.0, hibernate. When I try to deploy my app on WAS 7.0, it gives me the error - Failed to load listener: org.springframework.web.context.ContextLoaderListener]: java.lang.ClassNotFoundException:
Here is how my web app looks:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>ABC</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
The exception being thrown is as follows,
com.ibm.ws.webcontainer.webapp.WebApp logError SRVE0293E: [Servlet Error]-[Failed to load listener: org.springframework.web.context.ContextLoaderListener]: java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at java.beans.Beans.instantiate(Beans.java:190)
at java.beans.Beans.instantiate(Beans.java:75)
at com.ibm.ws.webcontainer.webapp.WebApp.loadListener(WebApp.java:1643)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.loadListener(WebAppImpl.java:671)
at com.ibm.ws.webcontainer.webapp.WebApp.loadLifecycleListeners(WebApp.java:1554)
So, is there anything wrong in web.xml ?
Edit: Sorry I did not mention, I am using Maven to get the jars. I have the required jar file in the WEB-INF folder too i.e. org.springframework.web.context
Have a look at the following link
http://forum.springsource.org/showthread.php?60812-ClassNotFoundException-org.springframework.web.con-text.ContextLoaderListener
It says you can fix this problem by going to project properties -> Deployment Assembly and adding the Maven Dependency Build Path entry
class java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at java.beans.Beans.instantiate(Beans.java:190)
Is the .jar file containing org.springframework.web.context.ContextLoaderListener on the classpath?
You have the wrong definition of the spring-web dependency, instead of:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.web</artifactId>
<version>${org.springframework.version}</version>
</dependency>
You should have what I've written in the comments:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
ArtifactId is spring-web. ${spring.version} of course is not important, just be sure it matches your defined version string.
Take any jars that you add to your project and make sure that they're also placed in your WEB-INF/lib directory. This is where your server looks at runtime when 3rd party libs are referenced. They aren't put there automatically; but there are ways you can automate this (ie using an ANT script or something like that). Just to get things up and running though, you can just manually copy/paste jars to that directory. If you add them to that directory outside of your IDE, make sure you refresh the folder from within your IDE after placing the files there.
the java engine fails too find the class (as your exception says: java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener)
java will search for the class on the class-path. you have a folder in your web app structure (on the computer where your 'was'-server runs) where you can put jar-files containing classes. you need to put spring.jar or spring-web.jar in this folder. i'm guessing the folder is called lib, and it will probably be located in a folder called WEB-INF, but i'm not sure, cause i don't know 'was'.
after you've put the jar-file in there, you'll probably need to restart your web/app-server. hope this helps! ^^
Project> properties> deployment assembly> add > referenced project class path entries> maven dependencies
Deploy again.
It works for me
Dave is right! You need all the required JARs in two places:
If you are seeing exceptions when you start the server, then you do not have the required JARs in WEB-INF/lib dir, so you need to keep all the JARs there.
If you are seeing any compile errors in your Java code, then you do not have your build path configured correctly. Keep all the JARs you put in WEB-INF/lib in your build path as "Referenced Libraries".
struggled with this same error all day ...
i had the spring-web jar, but turns out that i also needed the spring-context-support jar.
i added it into my pom and everything is working now.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework-version}</version>
</dependency>
error log:
com.ibm.ws.webcontainer.annotation.WASAnnotationHelper collectClasses unable to instantiate class
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
SRVE0293E: [Servlet Error]-[Failed to load listener: org.springframework.web.context.ContextLoaderListener]:
java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
loadLifecycleListeners SRVE0279E: Error occured while processing global listeners for the application {0}: {1}
java.lang.NullPointerException
at com.ibm.ws.webcontainer.annotation.WASAnnotationHelper.inject(WASAnnotationHelper.java:266)
I had the same exact problem.
Hopefully this helps someone.
Some of my dependency jars were missing from my WEB-INF/lib folder but were there in Referenced libraries.
I had to to do a maven clean install again to make sure all the jars were pulled into the lib folder.
The problem might be in your pom.xml too if it is not able to pull in the jars properly. So keep an eye out for that as well.
Project-> Maven clean and build -> lib folder refresh and make sure all jars are there (or the particular jar that throws the exception)