How Do I use Jasypt with springs autowire? - java

I have see some solutions for this without the autowire but I am trying to get it to work with with the auto wire. I have been trying this since last week but found no solutions that worked in my case, it may be that I am not implementing it correctly so any help would be great.
I have a properties file myprops.properties:
Wsdl=someurl
UserName=admin
UserPassword=ENC(encriptedpassword)
and in my servlet.xml file I replaced
<context:property-placeholder location="classpath*:myprops.properties" />
with
<bean id="propertyPlaceholderConfigurer"
class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="configurationEncryptor" />
<property name="location" value="classpath:myprops.properties" />
</bean>
<bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config" ref="environmentVariablesConfiguration" />
</bean>
<bean id="environmentVariablesConfiguration"
class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWithMD5AndDES" />
<property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" />
</bean>
and in my service.java I am auto wiring these values like this:
#Autowired
public void setUserPassword(#Value("${UserPassword}") String userPassword) {
this.userPassword = userPassword;
}
#Autowired
public void setUserName(#Value("${UserName}") String userName) {
this.userName = userName;
}
#Autowired
public void setWsdl(#Value("${Wsdl}") String wsdl) {
this.wsdl = wsdl;
}
Thing is this works when I don't have the password encripted i.e. UserPassword=nonencriptedpassword
but as soon as I encripted it and use ENC() I get the following error
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NullPointerException
at org.jasypt.encryption.pbe.config.SimplePBEConfig.getPasswordCharArray(SimplePBEConfig.java:434)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:740)
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:590)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)
Truncated. see log file for complete stacktrace
This may be down something stupidly simple that I am unaware of or have over looked but I have tried following tutorials on the Jasypt wiki and site as well as tutorials xmx1024 and on jayway and I'm sure I had found one using the autowired but I can't seem to find it again.
FYI: I am using spring 3.0.4, Spring Security 3.0.4 and jasypt 1.9
any help would be Awesome
Update
I have set an Enviorment Variable APP_ENCRYPTION_PASSWORD equal to the plain text password and set the password in the properties file as the returned value of
encrypt input=plaintextpassword password=APP_ENCRYPTION_PASSWORD
I now get the Error
<11-Mar-2013 16:33:54 o'clock GMT> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.jasypt.exceptions.EncryptionOperationNotPossibleException.
org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:112)
Truncated. see log file for complete stacktrace
>
<11-Mar-2013 16:33:54 o'clock GMT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1363019632631' for task '0'. Error is: 'weblogic.application.ModuleException: '
weblogic.application.ModuleException:
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1510)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:482)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:425)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
Truncated. see log file for complete stacktrace
Caused By: org.jasypt.exceptions.EncryptionOperationNotPossibleException
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:112)
Truncated. see log file for complete stacktrace
>
<11-Mar-2013 16:33:54 o'clock GMT> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application 'adminUI_EA'.>
<11-Mar-2013 16:33:54 o'clock GMT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'adminUI_EA'.>
<11-Mar-2013 16:33:54 o'clock GMT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: :org.jasypt.exceptions.EncryptionOperationNotPossibleException:null
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:981)
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
at org.jasypt.properties.PropertyValueEncryptionUtils.decrypt(PropertyValueEncryptionUtils.java:72)
at org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer.convertPropertyValue(EncryptablePropertyPlaceholderConfigurer.java:109)
at org.springframework.beans.factory.config.PropertyResourceConfigurer.convertProperty(PropertyResourceConfigurer.java:112)
Truncated. see log file for complete stacktrace
>
Password encription was done in the following way
C:\Users\jonnie\Desktop\jasypt-1.9.0\bin>encrypt input=****** password=APP_ENCRYPTION_PASSWORD
----ENVIRONMENT-----------------
Runtime: Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM 20.12-b01
----ARGUMENTS-------------------
input: *******
password: APP_ENCRYPTION_PASSWORD
----OUTPUT----------------------
****encriptedPassword****

This blog post has a nice example of using #Value on a bean that is build using #Service. The test uses #Autowire to set up the #Service bean.

Set the below variable
Eclipse - go to run config and under environment tab set below new variable key/value
APP_ENCRYPTION_PASSWORD=MyKey
If running on UNIX - export APP_ENCRYPTION_PASSWORD=MyKey
Create the beans like below =>
classpath:/app1.properties
classpath:/app2.properties

Related

Getting Servlet: "AxisServlet" failed to preload on startup in Web application java.lang.StackOverflowError in Weblogic 12c

I am getting below error while deploying application on WLS 12c
<Jun 8, 2020 11:02:03,120 AM IST> <Error> <HTTP> <BEA-101216> <Servlet: "AxisServlet" failed to
preload on startup in Web application: "MyApplication1.0.war".
java.lang.StackOverflowError
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader$3.next(URLClassLoader.java:601)
at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:626)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
Truncated. see log file for complete stacktrace
>
<Jun 8, 2020 11:02:08,698 AM IST> <Error> <Deployer> <BEA-149231> <Unable to set the activation state
to true for the application "MyApplication1.0".
weblogic.application.ModuleException: java.lang.StackOverflowError
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: java.lang.StackOverflowError
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader$3.next(URLClassLoader.java:601)
at java.net.URLClassLoader$3.hasMoreElements(URLClassLoader.java:626)
at sun.misc.CompoundEnumeration.next(CompoundEnumeration.java:45)
at sun.misc.CompoundEnumeration.hasMoreElements(CompoundEnumeration.java:54)
Truncated. see log file for complete stacktrace
Below is my project structure
Same project is working fine with Weblogic 11G
I was able to resolve issue.
For people having similar issue.
Add weblogic.xml with following content in tag.
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
This step will remove stackoverflow error.
Later you might get some dependency error which can be resolved as required.

Unable to deploy CXF3.x JAX-RS service in Weblogic 12c (12.2.1)

After upgrading a JAX-RS service built with CXF3.x from weblogic 12.1.3 to 12.2.1 I am facing the following weird issue
<03-ago-2017, 3:22:38,789 PM CEST> <Error> <HTTP> <BEA-101216> <Servlet: "JAX-RS/Jersey#1" failed to preload on startup in Web application: "sife".
A MultiException has 1 exceptions. They are:
1. java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1007)
at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:962)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1054)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1046)
at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:696)
Truncated. see log file for complete stacktrace
Note that I am using CXF, not Jersey, but seems Weblogic is trying to use it (it does not happen with 12.1.3). I disabled it in configuration files following this recommendations: https://jerometambo.github.io/blog/2016/12/13/How-to-use-CXF-3x-implementation-of-JAX-RS-20-REST-with-Weblogic-12c.html
With default configuration, Weblogic wants to use its internal implementation (JAX-RS 2.0 and serialization) to deploy the REST web services (Error 500):
META-INF/weblogic-application.xml
<weblogic-application xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application
http://xmlns.oracle.com/weblogic/weblogic-application/1.8/weblogic-application.xsd">
<prefer-application-packages>
<package-name>javax.ws.rs.*</package-name>
<package-name>com.fasterxml.jackson.*</package-name>
<package-name>weblogic.jaxrs.api.client.*</package-name>
<package-name>weblogic.jaxrs.internal.api.*</package-name>
<package-name>weblogic.jaxrs.dispatch.*</package-name>
<package-name>weblogic.jaxrs.monitoring.util.*</package-name>
</prefer-application-packages>
</weblogic-application>
WEB-INF/weblogic.xml
<weblogic-web-app
xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
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/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<container-descriptor>
<prefer-application-packages>
<package-name>javax.ws.rs.*</package-name>
<package-name>com.fasterxml.jackson.*</package-name>
</prefer-application-packages>
</container-descriptor>
</weblogic-web-app>
I do not know if this is a specific problem of my project or it is a weblogic issue. I have found similar issues like this and this, and I tried to use them.
These are my dependencies (IVY syntax)
<dependency org="org.apache.cxf" name="cxf-rt-frontend-jaxrs" rev="3.1.10" conf="default" />
<dependency org="org.apache.cxf" name="cxf-rt-rs-extension-providers" rev="3.1.10" conf="default" />
<dependency org="org.apache.cxf" name="cxf-rt-transports-http" rev="3.1.10" conf="default" />
<dependency org="com.fasterxml.jackson.jaxrs" name="jackson-jaxrs-json-provider" rev="2.6.6" conf="default" />
And the full stack trace
<03-ago-2017, 3:32:03,645 PM CEST> <Warning> <JAXRSIntegration> <BEA-2192510> <Cannot add Jersey servlet for application class org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet$ApplicationImpl because ApplicationPath annotation is not set on it.>
<03-ago-2017, 3:32:03,737 PM CEST> <Warning> <JAXRSIntegration> <BEA-2192511> <The list of resource packages: com.fasterxml.jackson.jaxrs.base;org.apache.cxf.jaxrs.provider;com.fasterxml.jackson.jaxrs.json;org.apache.cxf.jaxrs.provider.aegis;es.aragon.sife.server.filter;org.apache.cxf.jaxrs.provider.jsrjsonp;es.aragon.sife.keystore.api;es.aragon.sife.server.account.api;org.apache.cxf.jaxrs.provider.xmlbeans;org.apache.cxf.jaxrs.validation;es.aragon.sife.server.task.api;org.apache.cxf.jaxrs.provider.json;org.apache.cxf.jaxrs.provider.atom;es.aragon.sife.server.config.api>
ago 03, 2017 3:32:16 PM es.gob.afirma.signers.xml.Utils installXmlDSigProvider
<03-ago-2017, 3:32:20,581 PM CEST> <Error> <HTTP> <BEA-101216> <Servlet: "JAX-RS/Jersey#1" failed to preload on startup in Web application: "sife".
A MultiException has 1 exceptions. They are:
1. java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1007)
at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:962)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1054)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1046)
at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:696)
Truncated. see log file for complete stacktrace
Caused By: java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:146)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179)
at org.glassfish.jersey.media.sse.SseFeature.<clinit>(SseFeature.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Truncated. see log file for complete stacktrace
>
<03-ago-2017, 3:32:20,696 PM CEST> <Error> <Deployer> <BEA-149231> <Unable to set the activation state to true for the application "sife".
weblogic.application.ModuleException: java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: java.lang.LinkageError: ClassCastException: attempting to castzip:C:/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/tmp/_WL_user/sife/845176/war/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar!/javax/ws/rs/ext/RuntimeDelegate.class to jar:file:/C:/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.ws.rs.javax.ws.rs-api.jar!/javax/ws/rs/ext/RuntimeDelegate.class
at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:146)
at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
at javax.ws.rs.core.MediaType.valueOf(MediaType.java:179)
at org.glassfish.jersey.media.sse.SseFeature.<clinit>(SseFeature.java:62)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
Truncated. see log file for complete stacktrace
>
<03-ago-2017, 3:32:20,762 PM CEST> <Notice> <Log Management> <BEA-170027> <The server has successfully established a connection with the Domain level Diagnostic Service.>
<03-ago-2017, 3:32:20,931 PM CEST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to ADMIN.>
<03-ago-2017, 3:32:21,46 PM CEST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RESUMING.>
<03-ago-2017, 3:32:21,174 PM CEST> <Notice> <WebLogicServer> <BEA-000360> <The server started in RUNNING mode.>
<03-ago-2017, 3:32:21,186 PM CEST> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to RUNNING.>
<03-ago-2017, 3:32:22,710 PM CEST> <Error> <HTTP> <BEA-101216> <Servlet: "weblogic.management.rest.Application" failed to preload on startup in Web application: "wls-management-services.war".
A MultiException has 1 exceptions. They are:
1. java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
at org.jvnet.hk2.internal.Utilities.justCreate(Utilities.java:1007)
at org.jvnet.hk2.internal.ServiceLocatorImpl.create(ServiceLocatorImpl.java:962)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1054)
at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1046)
at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:696)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1350)
Truncated. see log file for complete stacktrace
>
<03-ago-2017, 3:32:22,747 PM CEST> <Error> <J2EE> <BEA-160001> <Error deploying Internal Application: weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
weblogic.application.utils.StateChangeException: weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:58)
at weblogic.application.services.BackgroundDeploymentManagerService$BackgroundDeployAction.run(BackgroundDeploymentManagerService.java:396)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
Truncated. see log file for complete stacktrace
Caused By: weblogic.application.ModuleException: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:233)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:228)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoClassDefFoundError: Could not initialize class org.glassfish.jersey.media.sse.SseFeature
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.glassfish.hk2.utilities.reflection.ReflectionHelper.makeMe(ReflectionHelper.java:1350)
Truncated. see log file for complete stacktrace
WORKAROUND
It works if I deploy previously other CXF module using the default JAX-RS implementation and removing WEB-INF/lib/javax.ws.rs-api-2.0.1.jar. Maybe weblogic does some kind of internal initialization.
myapp.ear
init.war (JAX-RS with CXF and removing javax.ws.rs-api-2.0.1.jar)
myapp.war (JAX-RS with CXF and weblogic configuration)
#pedrofb, this may not fully answer your question, however, I once had a similar issue with Tomcat. The symptoms are similar, the problem was not really due to the presense of different class present in different jars i.e. jar shadowing. It was due to classloader shadowing. In Tomcat, classloading is actually inverted, not the usual 'ask-your-parent-classloader-first' kind of model, if an application classloader can find a class (where it only loads from WEB-INF/lib or classes) then the classloader loads the class. Now, in your case, I think, since the JAX-RS jars are present in your WEB-INF/lib, it is getting loaded from there at web application level. However, when the same object is being passed to the container, it is trying to cast it to the same class but at container level loaded by a different classloader. Classes loaded by different classloaders are considered different; this would be the cause for ClassCastException.
This would also explain why there is no ClassCastException when you remove the JAX-RS jar from WEB-INF/lib. The workaround here are limited, either you remove the JAX-RS jar from your WEb-INF/lib as you have done. (This could be potentially problematic but you could experiment in non production server), replace the container JAX-RS jar with the one that you want.
As I said, this will probably not solve your problem completely but may point in a direction to where the problem is coming from. [As I noticed some years back, Weblogic uses tomcat as its web container core (not sure if it is still the same) with changed package names like com.bea.weblogic.org.apache.tomcat ...].
Hope this helps.

Error is: "weblogic.application.ModuleException: java.lang.ClassNotFoundException weblogic server 12.2.1

I am new to spring ,spring security,and weblogic so i am developing a project that is using them.
i am using here weblogic server 12.2.1
however the problem is the project is working perfect on tomcat 8 server
and i have deployed the application once on weblogic and it is worked once before i added spring security ,but after i have finished on tomcat now weblogic is asking for a deleted class
my stack trace is
<Nov 18, 2016 7:15:13 PM AST> <Error> <HTTP> <BEA-101371> <There was a failure when processing annotations for application C:\MarsWorkspace\xxx\target\m2e-wtp\web-resources. Ensure that the annotations are valid. The error is org.xxx.services.Login>
<Nov 18, 2016 7:15:13 PM AST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1477051442040128" for task "0" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.xxx.services.Login"
weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:196)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:191)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:981)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:942)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:83)
at weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:564)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:500)
Truncated. see log file for complete stacktrace
>
<Nov 18, 2016 7:15:13 PM AST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating distribute task for application "_auto_generated_ear_".>
<Nov 18, 2016 7:15:13 PM AST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:196)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:191)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:981)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:942)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:83)
at weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:564)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:500)
Truncated. see log file for complete stacktrace
>
<Nov 18, 2016 7:15:17 PM AST> <Error> <HTTP> <BEA-101371> <There was a failure when processing annotations for application C:\MarsWorkspace\xxx\target\m2e-wtp\web-resources. Ensure that the annotations are valid. The error is org.xxx.services.Login>
<Nov 18, 2016 7:15:17 PM AST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "1477056982276446" for task "1" on [partition-name: DOMAIN]. Error is: "weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.xxx.services.Login"
weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:196)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:191)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:981)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:942)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:83)
at weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:564)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:500)
Truncated. see log file for complete stacktrace
>
<Nov 18, 2016 7:15:18 PM AST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating distribute task for application "_auto_generated_ear_".>
<Nov 18, 2016 7:15:18 PM AST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:196)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:191)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
Truncated. see log file for complete stacktrace
Caused By: java.lang.ClassNotFoundException: org.xxx.services.Login
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:981)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:942)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:83)
at weblogic.utils.classloaders.GenericClassLoader.doFindClass(GenericClassLoader.java:564)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:500)
Truncated. see log file for complete stacktrace
>
now when put this class back i got
Error creating bean with name 'login': Injection of autowired dependencies failed;
versions in pom.xml
<!-- Generic properties -->
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- Spring -->
<spring-framework.version>4.2.5.RELEASE</spring-framework.version>
<!-- <aspectj.version>1.7.4</aspectj.version> -->
<!-- Hibernate / JPA -->
<hibernate.version>5.2.4.Final</hibernate.version>
<!-- JSF Version -->
<jsf.version>2.2.13</jsf.version>
<!-- Logging -->
<logback.version>1.0.13</logback.version>
<slf4j.version>1.7.5</slf4j.version>
<!-- spring security -->
<springSecurity.version>4.0.3.RELEASE</springSecurity.version>
also when i have searched for this error i thought maybe the weblogic spring module is conflicting with mine so i have added weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<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://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.7/weblogic-web-app.xsd">
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
</wls:weblogic-web-app>
also i have deleted the cache,log and tmp files in C:\Weblogic12_2_1\user_projects\domains\adminDomain\servers\AdminServer but nothing happened.
will i was searching for days now but no luck if any body can point me to something it would be appreciated.
I solved the issue by lowering the libraries versions.

jersey rest Application not deploying with shared library jax-rs 2.0 in weblogic 12.1.3

I have a jersey rest application. I have used jersey 2.x classes including http request interceptors. however my weblogic 12.1.3 server has jersey 1.8. i deployed a jax-rs 2.0 shared library from this link in the server and referenced it in my weblogic.xml file. But when deploying it, it says There was a failure when processing annotations for application.
below are the error logs. what I'm I missing here?
<Sep 8, 2015 2:31:05 PM EAT> <Error> <HTTP> <BEA-101371> <There was a
failure when processing annotations for application /home/martin/Dev/wls1213/user_projects/domains/base_domain/servers/AdminServer/upload/web-1.war. Ensure that the annotations are valid. The error is null
java.lang.NullPointerException
at
weblogic.servlet.internal.WebAnnotationProcessor.processMultipartConfigAnnotation(WebAnnotationProcessor.java:275)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:169)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:114)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:141)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:102)
Truncated. see log file for complete stacktrace
>
<Sep 8, 2015 2:31:06 PM EAT> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "19063043237576" for task "0". Error is: "weblogic.application.ModuleException: java.lang.NullPointerException"
weblogic.application.ModuleException: java.lang.NullPointerException
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:175)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:170)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:80)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NullPointerException
at weblogic.servlet.internal.WebAnnotationProcessor.processMultipartConfigAnnotation(WebAnnotationProcessor.java:275)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:169)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:114)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:141)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:102)
Truncated. see log file for complete stacktrace
>
<Sep 8, 2015 2:31:06 PM EAT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application "web-1".>
<Sep 8, 2015 2:31:06 PM EAT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: java.lang.NullPointerException
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:175)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:170)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:80)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NullPointerException
at weblogic.servlet.internal.WebAnnotationProcessor.processMultipartConfigAnnotation(WebAnnotationProcessor.java:275)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:169)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:114)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:141)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:102)
Truncated. see log file for complete stacktrace
>
<Sep 8, 2015 2:31:06 PM EAT> <Error> <Console> <BEA-240003> <Administration Console encountered the following error: weblogic.application.ModuleException: java.lang.NullPointerException
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:175)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:170)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:80)
at weblogic.work.ContextWrap.run(ContextWrap.java:40)
at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
Caused by: java.lang.NullPointerException:
at weblogic.servlet.internal.WebAnnotationProcessor.processMultipartConfigAnnotation(WebAnnotationProcessor.java:275)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:169)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:114)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:141)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:102)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:79)
at weblogic.servlet.internal.WebAppModule.processAnnotations(WebAppModule.java:1804)
at weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:764)
at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:295)
at weblogic.application.internal.ExtensibleModuleWrapper$PrepareStateChange.next(ExtensibleModuleWrapper.java:285)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:109)
below is my weblogic.xml file
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app" 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/web-app_2_5.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<jsp-descriptor>
<keepgenerated>true</keepgenerated>
<debug>true</debug>
</jsp-descriptor>
<context-root>/web</context-root>
<session-descriptor>
<persistent-store-type>coherence-web</persistent-store-type>
</session-descriptor>
<library-ref>
<library-name>jax-rs</library-name>
<specification-version>2.0</specification-version>
</library-ref>
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<prefer-application-packages>
<package-name>org.slf4j</package-name>
</prefer-application-packages>
<prefer-application-resources>
<resource-name>org/slf4j/impl/StaticLoggerBinder.class</resource-name>
</prefer-application-resources>
</container-descriptor>
</weblogic-web-app>
The major 2 means Jersey has incompatibilities with version 1. I wouldn't expect it to be backwards compatible. I suppose you'll have to migrate or keep working in version 1.

Deploying a Jersey application on Weblogic 12.1.3

I am having difficulty deploying a Jersey application to Weblogic 12, I have spent a lot of time battling with it and am still struggling. I have followed various suggestions on various sites (including this one), but I am still having issues. I don't know if I am fundamentally misunderstanding something basic, so I am hoping someone can help me.
Here is what I have so far:
I have created a new maven project.
Here is my POM:
<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>
<groupId>uk.co.omnicomengineering</groupId>
<artifactId>jersey-weblogic</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>jersey-weblogic</name>
<build>
<finalName>jersey-weblogic</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
I have also deployed the jax-rs to Weblogic as in https://docs.oracle.com/middleware/1213/wls/RESTF/use-jersey20-ri.htm#RESTF299 and added the following weblogic.xml to my WEB-INF directory:
<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.7/weblogic-web-app.xsd">
<wls:library-ref>
<wls:library-name>jax-rs</wls:library-name>
<wls:specification-version>2.0</wls:specification-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref>
Now, when I try to deploy the application, I get the following error:
<06-Jul-2015 11:19:45 o'clock BST> <Error> <HTTP> <BEA-101216> <Servlet: "Jersey Web Application" failed to preload on startup in Web application: "jersey-weblogic".
java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;
at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:329)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
Truncated. see log file for complete stacktrace
>
<06-Jul-2015 11:19:45 o'clock BST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "10095322227139" for task "12". Error is: "weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;"
weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;
at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:329)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
Truncated. see log file for complete stacktrace
>
<06-Jul-2015 11:19:45 o'clock BST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 7 task for the application "_auto_generated_ear_".>
<06-Jul-2015 11:19:45 o'clock BST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating start task for application "_auto_generated_ear_".>
<06-Jul-2015 11:19:45 o'clock BST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: org.glassfish.hk2.api.ServiceLocatorFactory.create(Ljava/lang/String;Lorg/glassfish/hk2/api/ServiceLocator;Lorg/glassfish/hk2/extension/ServiceLocatorGenerator;Lorg/glassfish/hk2/api/ServiceLocatorFactory$CreatePolicy;)Lorg/glassfish/hk2/api/ServiceLocator;
at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:123)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:329)
at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:339)
at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:170)
Truncated. see log file for complete stacktrace
I am not really sure what is going wrong; am I using the wrong dependencies in my POM?
Any help that anyone could give would be gratefully received, I have spend a lot of time battling with Weblogic and Jersey!
--EDIT --
I have added the following to my weblogic.xml (following http://www.widecodes.com/CxVkWWgPUj/using-jersey-2x-web-service-on-weblogic-1211.html which seems to be a similar issue):
<weblogic-web-app xmlns="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.7/weblogic-web-app.xsd">
<library-ref>
<library-name>jax-rs</library-name>
<specification-version>2.0</specification-version>
<exact-match>false</exact-match>
</library-ref>
<container-descriptor>
<prefer-application-packages>
<package-name>com.sun.jersey.*</package-name>
<package-name>org.glassfish.jersey.*</package-name>
<package-name>org.glassfish.hk2.*</package-name>
<package-name>org.jvnet.hk2.*</package-name>
<package-name>jersey.repackaged.org.objectweb.asm.*</package-name>
<package-name>com.sun.research.ws.wadl.*</package-name>
<package-name>com.sun.ws.rs.ext.*</package-name>
<package-name>org.codehaus.jackson.*</package-name>
<package-name>com.fasterxml.jackson.*</package-name>
<package-name>org.codehaus.jettison.*</package-name>
<package-name>javax.ws.rs.*</package-name>
<package-name>org.objectweb.asm.*</package-name>
<package-name>antlr.*</package-name>
</prefer-application-packages>
</container-descriptor>
Now, when I deploy I get the following error:
<08-Jul-2015 14:16:25 o'clock BST> <Error> <HTTP> <BEA-101216> <Servlet: "Jersey Web Application" failed to preload on startup in Web application: "jersey-weblogic".
java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.PropertiesHelper.getValue(Ljava/util/Map;Ljavax/ws/rs/RuntimeType;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
at org.glassfish.jersey.moxy.json.MoxyJsonFeature.configure(MoxyJsonFeature.java:67)
at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:714)
at org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:644)
at org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:822)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:452)
Truncated. see log file for complete stacktrace
>
<08-Jul-2015 14:16:26 o'clock BST> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID "193463109842784" for task "12". Error is: "weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.PropertiesHelper.getValue(Ljava/util/Map;Ljavax/ws/rs/RuntimeType;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;"
weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.PropertiesHelper.getValue(Ljava/util/Map;Ljavax/ws/rs/RuntimeType;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.PropertiesHelper.getValue(Ljava/util/Map;Ljavax/ws/rs/RuntimeType;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
at org.glassfish.jersey.moxy.json.MoxyJsonFeature.configure(MoxyJsonFeature.java:67)
at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:714)
at org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:644)
at org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:822)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:452)
Truncated. see log file for complete stacktrace
>
<08-Jul-2015 14:16:26 o'clock BST> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 7 task for the application "_auto_generated_ear_".>
<08-Jul-2015 14:16:26 o'clock BST> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating start task for application "_auto_generated_ear_".>
<08-Jul-2015 14:16:26 o'clock BST> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
weblogic.application.ModuleException: java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.PropertiesHelper.getValue(Ljava/util/Map;Ljavax/ws/rs/RuntimeType;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: org.glassfish.jersey.internal.util.PropertiesHelper.getValue(Ljava/util/Map;Ljavax/ws/rs/RuntimeType;Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Class;)Ljava/lang/Object;
at org.glassfish.jersey.moxy.json.MoxyJsonFeature.configure(MoxyJsonFeature.java:67)
at org.glassfish.jersey.model.internal.CommonConfig.configureFeatures(CommonConfig.java:714)
at org.glassfish.jersey.model.internal.CommonConfig.configureMetaProviders(CommonConfig.java:644)
at org.glassfish.jersey.server.ResourceConfig.configureMetaProviders(ResourceConfig.java:822)
at org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:452)
Truncated. see log file for complete stacktrace
Since you were trying to deploy jersey as a shared library in WLS initially, I am assuming you were not supplying the jersey jar files with your EAR file, or at least that was not the intent.
I suspect the initial problem was that you might have deployed an older version of jax-rs from the deployable library. What you want to see in your deployments is jax-rs(2.0,2.5.1) - spec 2.0, implementation 2.5.1 - deployed as a shared library.
you should not put in the weblogic.xml unless you want the packages you specified "must always be loaded from the application" (ref Oracle doc here) - i.e. wls would look for these packages provided from your EAR - which I suspect is not what you want to do. You would only do this if you want to supply your own version of the jersey files - typically later more up to date version than what WLS provides.
I suggest you back out your changes you made on the weblogic.xml, you redeploy the jax-rs shared library, and make sure you did not accidentally included any of the jersey jar files in your EAR. I am not a maven user, so I'm not sure what you have on the POM file would automatically include these dependent files in your EAR file. You do not want this if you want to use the WLS versions of jersey.
Also, not sure if this would make a difference, but on my version of weblogic.xml, I included the implementation-version to match that of the shared library.
<wls:library-ref>
<wls:library-name>jax-rs</wls:library-name>
<wls:specification-version>2.0</wls:specification-version>
<wls:implementation-version>2.5.1</wls:implementation-version>
<wls:exact-match>false</wls:exact-match>
</wls:library-ref>
Good luck. These deployment issues can be tricky to maddening.
As you may already know before deploying a JAX-RS application to Weblogic you must install jax-rs shared library on the server. It resides in $WLHOME/common/deployable-libraries/jax-rs-2.0.war
After that you should not have any jersey jars on your ear/war application. You just reference the jax-rs library from weblogic.xml preferably with its implementation version. This <prefer-application-packages> section is supposed to be defined in the weblogic.xml inside jax-rs library war and not in yours weblogic.xml.
If you want to use more recent version of the jax-rs library check this answer

Categories