Spring Boot REST service deploy on Weblogic12c - java

I'm deploy my application on oracle weblogic 12c.
My application use Spring Boot, Spring REST service and Jackson
All lib for jackson:
jackson-annotations.2.6.1.jar
jackson-core.2.6.1.jar
jackson-databind.2.6.1.jar
jackson-datatype-hibernate4.2.6.1.jar
jackson-datatype-hppc.2.6.1.jar
jackson-datatype-json-org.2.6.1.jar
jackson-datatype-jsr310.2.6.1.jar
I get this error:
java.lang.IllegalAccessError: tried to access method com.fasterxml.jackson.databind.ser.std.StdSerializer.(Ljava/lang/Class;)V from class com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
I think jackson-datatype-jsr310 confict in weblogic lib.
Please help me!

it worked for me to add this to the weblogic.xml :
<wls:prefer-application-packages>
<wls:package-name>com.fasterxml.jackson.*</wls:package-name>
</wls:prefer-application-packages>

Related

Multiple annotations found at this line: Factory bean not Found

I am building a Spring project in Spring Tool Suite(3.6.4.RELEASE).
I am trying to upgrade spring framework version from 4.0.3.RELEASE to 4.2.7.RELEASE using maven.
Before upgradation there was no error and everything running smoothly. Now project is compiling and running without error but login page is not showing and also I am getting error in my spring security configuration xml.
Error in spring-security.xml:
Showing following error on STS hovering:
Multiple annotations found at this line:
- Factory bean 'org.springframework.security.config.http.FilterInvocationSecurityMetadataSourceParser
$DefaultWebSecurityExpressionHandlerBeanFactory' not found [config set: mcare-dashboard-web/web-context]
- Factory bean 'org.springframework.security.config.http.HttpConfigurationBuilder
$SecurityContextHolderAwareRequestFilterBeanFactory' not found [config set: mcare-dashboard-web/web-context]
Project Hierarchy:
My pom.xml was like following:
Then I just changed the version number like this:
After that spring-security.xml was showing the error.
Can anybody explain why is this happening?
You state that you are upgrading Spring from version 4.0.3.RELEASE to 4.2.7.RELEASE. However effectively you are upgrading both Spring and Spring Security. This due to having a single version property, named org.springframework-version, to manage both the version of the Spring and Spring Security dependencies.
So changing org.springframework-version to 4.2.7.RELEASE effectively upgrades Spring Security as well.
To fix this you want to have two distinct version properties one for Spring and another for Spring Security. You can than upgrade only Spring or Spring Security.

Spring Web Reactive not working as war file deployed on Tomcat 8.5

I have Spring Boot (2.0.0 M5) application which provides some REST API. I'd like to implement this API using RouterFunctions.
While I'm running app using embedded Jetty everything works fine.
When I convert the app to WAR file (following documentation here) and deploy it to Tomcat 8.5 I always get 404 when trying to call any of the endpoints.
I can see in the log that endpoints are recognised:
[ost-startStop-1] s.w.r.r.m.a.RequestMappingHandlerMapping : Mapped "{[/say-hello],methods=[GET]}" onto java.lang.String com.example.demo.DemoController.test()
[ost-startStop-1] o.s.w.r.f.s.s.RouterFunctionMapping: Mapped /api => {
/v1 => {
/status ->
com.example.demo.DemoApplication$$Lambda$189/1904651750#5fdc83e
}
}
But when calling curl -v http://localhost:8080/demo/say-hello or curl -v http://localhost:8080/demo/api/v1/status I see default Tomcat 404 page. The path is correct, I rename .war to demo.war before deploying it.
Did anybody come across similar issue? You can find the code here.
I'm afraid the WAR deployment model is not supported in Spring Boot for WebFlux at the moment. Spring Framework does support that model (although I'm not sure it supports deploying an app to a non-root context).
You can always create an issue on the Spring Boot issue tracker, but I'm not sure this will be implemented, as deploying to a Servlet container is not the primary focus there (and you can't do that with Netty).
Quick note: adding #EnableWebFlux is a signal that you'd like to take the WebFlux configuration in your own hands and that Spring Boot should not auto-configure things for you in that space.
Answering it now just in case some one else is still facing this issue.
In the POM file, you need to exclude the netty and add tomcat separately.
compile ('org.springframework.boot:spring-boot-starter-webflux') {
exclude group: 'org.springframework.boot', module: 'spring-boot-starter-
reactor-netty'
}
compile 'org.springframework.boot:spring-boot-starter-tomcat'
Please check the link for full code : https://github.com/sushantkr16/Spring-boot2-webflux-annotation

How to configure Weblogic 12.1.3 to use older version of Jersey while deploying Enterprise App

I have installed Weblogic 12.1.3 as part of upgrade from Weblogic 10.3.6 to Weblogic 12.1.3
My application uses Jersey version 1.17 jars
However, after we install Weblogic 12.1.3, we get Jersey 1.18 Jars inside folder ORACLE_HOME/oracle_common/modules
The Jersey 1.18 Jars override the Jersey 1.17 jars which are bundled in our application and causes error in deploying our application.
We get error/warning messages as give below
WARNING: Return type javax.xml.bind.JAXBElement of method public javax.xml.bind.JAXBElement com.ipc.dms.dsfs.service.rs.DSFSResource.getEnterpriseContacts(java.lang.String,java.lang.Integer,java.lang.Integer,java.lang.String) is not resolvable to a concrete type
WARNING: Return type javax.xml.bind.JAXBElement of method public javax.xml.bind.JAXBElement com.ipc.dms.dsfs.service.rs.DSFSResource.getMediaServiceConfigList(java.lang.String) is not resolvable to a concrete type
The application is using ServletContainerInitializer class com.sun.jersey.server.impl.container.servlet.JerseyServletContainerInitializer that is loaded from:file:/opt/oracle/oracle_common/modules/jersey-servlet-1.18.jar. This initializer overrides the one available in the system.
**********>
java.lang.NoClassDefFoundError: Could not initialize class org.jgroups.conf.XmlConfigurator
at org.jgroups.conf.ConfiguratorFactory.getXmlConfigurator(ConfiguratorFactory.java:216)
at org.jgroups.conf.ConfiguratorFactory.getStackConfigurator(ConfiguratorFactory.java:93)
at org.jgroups.JChannel.(JChannel.java:142)
If we remove the Jersey 1.18 Jars from ORACLE_HOME/oracle_common/modules we DO NOT get these error messages.
However, removing jars from installation folder causes other issues.To be specific I get the issue mentioned below if I remove the Jersey 1.18 jars from from ORACLE_HOME/oracle_common/modules
weblogic.kernel.Default (self-tuning)'> <> <> <> <1467281457661> < BEA-149231 > < Unable to set the activation state to true for the application "dunkin".
weblogic.application.ModuleException: java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
So, I need to know if we can configure our EAR to use older version of Jersey i.e Jersey 1.17 while deploying the application on Weblogic 12.1.3.
If yes, please provide configuration details.
You have got 2 options:
To include the <prefer-application-packages> tag in the weblogic-application.xml of your ear as below:
<weblogic-application>
<prefer-application-packages>
<package-name>com.sun.jersey.*</package-name>
</prefer-application-packages>
</weblogic-application>
To inlcude the <wls:prefer-web-inf-classes> tag in the weblogic.xml of your war file as below:
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
If you decide to use option 2 then all the common libs of weblogic will be overidden by the libs of your application. So I would suggest to go with option 1.

Not able to integrate and test Jersey in my project

I'm able to test mkyong example http://www.mkyong.com/webservices/jax-rs/restful-java-client-with-jersey-client/ of jersey using Get and Post methods in a separate project. But, when I try to integrate the same example in my project which is maven and using Struts framework too , it doesn't run. I've added all the dependencies in pom.xml and configured in web.xml
URL I'm passing is
http://localhost:8080/MyProject/restful/json/metallica/get
The error which I get is
java.lang.AbstractMethodError
at org.codehaus.jackson.map.AnnotationIntrospector$Pair.findSerializer(AnnotationIntrospector.java:1148)
at org.codehaus.jackson.map.ser.BasicSerializerFactory.findSerializerFromAnnotation(BasicSerializerFactory.java:367)
at org.codehaus.jackson.map.ser.BeanSerializerFactory.createSerializer(BeanSerializerFactory.java:252)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createUntypedSerializer(StdSerializerProvider.java:782)
at org.codehaus.jackson.map.ser.StdSerializerProvider._createAndCacheUntypedSerializer(StdSerializerProvider.java:735)
at org.codehaus.jackson.map.ser.StdSerializerProvider.findValueSerializer(StdSerializerProvider.java:344)
at org.codehaus.jackson.map.ser.StdSerializerProvider.findTypedValueSerializer(StdSerializerProvider.java:420)
at org.codehaus.jackson.map.ser.StdSerializerProvider._serializeValue(StdSerializerProvider.java:601)
at org.codehaus.jackson.map.ser.StdSerializerProvider.serializeValue(StdSerializerProvider.java:256)
at org.codehaus.jackson.map.ObjectMapper.writeValue(ObjectMapper.java:1613)
at org.codehaus.jackson.jaxrs.JacksonJsonProvider.writeTo(JacksonJsonProvider.java:520)
at com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy.writeTo(JacksonProviderProxy.java:160)
Any ideas what is going on wrong?

Axis2 Weblogic 10 jar conflict

I am trying to deploy a axis2 webservice client on Weblogic 10 server. However i get the below error :
java.lang.ClassCastException:
com.ctc.wstx.stax.WstxInputFactory at
javax.xml.stream.XMLInputFactory.newInstance(XMLInputFactory.java:136)
at
weblogic.servlet.internal.WebAppHelper$IOHelperImpl.parseXML(WebAppHelper.java:247)
at
weblogic.descriptor.DescriptorCache.parseXML(DescriptorCache.java:350)
at
weblogic.servlet.internal.WebAppHelper.parseTagLibraries(WebAppHelper.java:142)
at
weblogic.servlet.internal.WebAppHelper.(WebAppHelper.java:60)
at
weblogic.servlet.internal.WebAppServletContext.(WebAppServletContext.java:402)
at
weblogic.servlet.internal.WebAppServletContext.(WebAppServletContext.java:452)
at
weblogic.servlet.internal.HttpServer.loadWebApp(HttpServer.java:410)
at
weblogic.servlet.internal.WebAppModule.registerWebApp(WebAppModule.java:582)
at
weblogic.servlet.internal.WebAppModule.prepare(WebAppModule.java:298)
at
weblogic.application.internal.flow.ScopedModuleDriver.prepare(ScopedModuleDriver.java:176)
at
weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
at
weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:360)
at
weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at
weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:56)
at
weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:46)
at
weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
at
weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at
weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:191)
at
weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:147)
at
weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
at
weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:189)
at
weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:87)
at
weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217)
at
weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:719)
at
weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1186)
at
weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:248)
at
weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:157)
at
weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157)
at
weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12)
at
weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45)
at
weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:464)
at
weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at
weblogic.work.ExecuteThread.run(ExecuteThread.java:172)cuteThread.run(ExecuteThread.java:172)
My weblogic-application.xml is as follows:
<wls:prefer-application-packages>
<wls:package-name>com.ctc.wstx.*</wls:package-name>
<wls:package-name>javax.xml.*</wls:package-name>
<wls:package-name>org.apache.*</wls:package-name>
</wls:prefer-application-packages>
</wls:weblogic-application>
All help would be appreciated!
Fixed the issue:
The weblogic-application.xml should be:
<wls:prefer-application-packages>
<wls:package-name>org.apache.*</wls:package-name>
</wls:prefer-application-packages>
</wls:weblogic-application>
So that it picks up the weblogic stax-api implementation jar. Also there is no direct way to get weblogic stax parser to work with Axis2 1.5.2. So you need to have woodstock parser in the class path.
The issue is same with CXF. I tried all these approaches and ended up putting huge package list. Finally gave up as we decided to use Tomcat.
The above list given is only apache classes, you may have to add more packages for dependencies and beyond.
Refer: http://cxf.apache.org/docs/application-server-specific-configuration-guide.html#ApplicationServerSpecificConfigurationGuide-WebLogic

Categories

Resources