Spring boot 2.2.6 application with apache axis Issue - java

My question is similar to this one (Spring boot application with apache axis) but I am running Spring Boot v2.2.6. When I execute the command
java -jar -Dspring.profiles.active=local myjar-0.0.1-SNAPSHOT.jar
I get the error
2021-06-01 00:41:53,152 myjar [http-nio-9090-exec-1] ERROR
org.apache.axis2.deployment.ModuleDeployer - deploy:94 - The addressing-1.6.3-classpath-
module.jar module, which is not valid, caused The /Users/xxxx/workspace/myjar/build/libs/myjar-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/addressing-1.6.3-classpath-
module.jar file cannot be found.
org.apache.axis2.AxisFault: The /Users/xxxx/workspace/.../build/libs/myjar-0.0.1-
SNAPSHOT.jar!/BOOT-INF/lib/addressing-1.6.3-classpath-module.jar file cannot be found.
I also have the relevant build.gradle snippet
api "org.apache.axis2:addressing:1.6.3:classpath-module"
api "org.apache.axis2:axis2:1.6.3"
api "org.apache.axis2:axis2-adb:1.6.3"
api "org.apache.axis2:axis2-transport-local:1.6.3"
api "org.apache.axis2:axis2-transport-http:1.6.3"
I confirmed that the file /Users/xxxx/workspace/myjar/build/libs/myjar-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/addressing-1.6.3-classpath-module.jar does exist. Can anyone help fix this issue?

It looks like Axis cannot cope with one jar file being nested inside another. For situations like this, you can configure Spring Boot to automatically unpack the nested jar when you start your application:
bootJar {
requiresUnpack '**/addressing-*-classpath-module.jar'
}

Related

Upgraded Spring, Now Freemarker throws NoSutchMethod error

I had a perfectly working Spring applicaton (4.2.7 -> 4.3.7) Simple upgrade, but now when I deploy catalina.out is giving me a:
Caused by: java.lang.NoSuchMethodError: freemarker.template.Configuration.<init>(Lfreemarker/template/Version;)V
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.newConfiguration(FreeMarkerConfigurationFactory.java:320)
I looked through the API but doesn't look like anything changed. I also can confirm the freemarker-2.3.20.jar is in the lib directory, but this looks like a spring issue
Took a bit of searching, but Spring also upgraded Freemarker to 2.3.23 -- So use that in your pom and it should work.

Spring Cloud Config in web application

I have legacy Java web application (with Spring MVC and web.xml) which are deployed in Tomcat. I want to swtich configuration to Spring Cloud Config.
Structure of this application (just simplify it for example) - jar file with Spring Controller and services, which I want to do Spring Cloud Config compatible. And another module with web.xml, which add jar as dependency.
I added bootstrap.yml with application name to module, which packaged to jar in "resources" folder and add "EnableAutoConfiguration" and "SpringBootApplication" annotations, but got exception:
java.lang.IllegalArgumentException: Could not resolve placeholder 'foo' in string value "${foo}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:126)
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:219)
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:193)
Config server is run. I wrote simple client, which I run via main method and it works, but when I deploy legacy app in Tomcat - it doesn't work.
Can someone help with it?

NoSuchMethodError: org.hibernate.SessionFactory.openSession()

I'm having hibernate3.jar and hibernate-core-4.2.0.CR1.jar in my classpath and I'm using Spring 3.1.3 version. Code got compiles sucessfully but while runtime I'm getting following error
2014-10-28 10:51:25,174 DEBUG [RMI TCP Connection(2)-10.126.30.203] -
Target method failed for RemoteInvocation: method name
'getPriceByKeys'; parameter types [java.util.List, java.util.Date]
java.lang.NoSuchMethodError:
org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;
I google it but not find any solution. Please note : My project needs hibernate3.jar but at the same time my project dependent on some other 3rd party jar which inturn using hibernet4.2.0 jar.
Any help Pls ??
You need to remove multiple hibernate JAR files from your classpath. Without doing this, your application may not work as you expect; which means you need to migrate the hibernate version of your application from 3 to 4.1.
Although Spring 3.1 uses Hibernate 3 JAR files, you can still migrate to Hibernate 4. Check out Spring blog gives a small tutorial to do so.
Migrating to Spring 3.1 and Hibernate 4.1
As part of the Core-Spring course, we have a lab application that we
use to show how to integrate Spring and JPA/Hibernate together. We
have just upgraded it to Spring 3.1 / Hibernate 4.1, and thought we
should share a few tips.
Just an update. The cause of problem is , I'm having two spring-context xml files in project (one of my project and one related to another module that I'm integrating). I'm loading context xmls from two different classes. So one of the DAO class loaded by one of spring-context xml not getting the hibernate Session.
Later on using import tag, I included 2nd spring application context file in 1st application context file and then loaded a Single application context file from the class. It solved the error.
Thanks,

Spring Boot Starter Integration and Starter WS not playing well together?

I'm working on a spike to try to exercise a number of technologies with spring boot (1.1.6.RELEASE), gradle (2.1) and Java 1.8. So we are looking at supporting some old style SOAP Web Service calls as well as Spring Integration. So to get off the ground I was looking at working with the example for producing a web service (http://spring.io/guides/gs/producing-web-service/) and adding spring integration into the mix.
When I did this though and try to hit the WSDL location I am now seeing this stack trace :
2014-09-22 09:53:17.823 ERROR 15188 --- [nio-8080-exec-1] a.c.c.C.[.[.[.[messageDispatcherServlet] : Servlet.service() for servlet[messageDispatcherServlet] in
context with path [] threw exception [Request processing failed; nested exception is java.lang.AbstractMethodError: org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z] with root cause
java.lang.AbstractMethodError: org.apache.xerces.dom.DeferredDocumentImpl.getXmlStandalone()Z
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.setDocumentInfo(DOM2TO.java:377)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:131)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(DOM2TO.java:98)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(TransformerImpl.java:699)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:743)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:357)
at org.springframework.ws.transport.http.WsdlDefinitionHandlerAdapter.handle(WsdlDefinitionHandlerAdapter.java:144)...
Looking around this looks to be related to the Xerces implementation that is pulled in for Integration. You can reproduce this by taking the example Producing a SOAP web service and changing the dependency section to look like this :
dependencies {
compile("org.springframework.boot:spring-boot-starter-ws")
compile("wsdl4j:wsdl4j:1.6.1")
jaxb("com.sun.xml.bind:jaxb-xjc:2.2.4-1")
compile(files(genJaxb.classesDir).builtBy(genJaxb))
compile("org.springframework.boot:spring-boot-starter-integration")
}
Basically adding compile("org.springframework.boot:spring-boot-starter-integration") and then try hitting the WSDL at http://:/ws/countries.wsdl. (running gradle bootRun)
Now arguably this may not be the best way to do this and maybe I should just look to spring integration to expose the endpoint, but has anyone else seen and dealt with this?
Thanks in advance
Tristan
Note I did add the compile "org.apache.ws.xmlschema:xmlschema-core:2.1.0" dep
Here is my jar list from the lib directory
aopalliance-1.0.jar
aspectjrt-1.8.2.jar
aspectjweaver-1.8.2.jar
classmate-1.0.0.jar
commons-codec-1.2.jar
commons-httpclient-3.0.1.jar
commons-io-2.4.jar
hibernate-validator-5.0.3.Final.jar
jackson-annotations-2.3.0.jar
jackson-core-2.3.4.jar
jackson-databind-2.3.4.jar
jboss-logging-3.1.1.GA.jar
jcl-over-slf4j-1.7.7.jar
jdom-1.0.jar
jul-to-slf4j-1.7.7.jar
log4j-over-slf4j-1.7.7.jar
logback-classic-1.1.2.jar
logback-core-1.1.2.jar
rome-1.0.0.jar
rome-fetcher-1.0.0.jar
slf4j-api-1.7.7.jar
snakeyaml-1.13.jar
spring-aop-4.0.7.RELEASE.jar
spring-beans-4.0.7.RELEASE.jar
spring-boot-1.1.6.RELEASE.jar
spring-boot-autoconfigure-1.1.6.RELEASE.jar
spring-boot-starter-1.1.6.RELEASE.jar
spring-boot-starter-aop-1.1.6.RELEASE.jar
spring-boot-starter-integration-1.1.6.RELEASE.jar
spring-boot-starter-logging-1.1.6.RELEASE.jar
spring-boot-starter-tomcat-1.1.6.RELEASE.jar
spring-boot-starter-web-1.1.6.RELEASE.jar
spring-boot-starter-ws-1.1.6.RELEASE.jar
spring-context-4.0.7.RELEASE.jar
spring-core-4.0.7.RELEASE.jar
spring-expression-4.0.7.RELEASE.jar
spring-integration-core-4.0.3.RELEASE.jar
spring-integration-file-4.0.3.RELEASE.jar
spring-integration-http-4.0.3.RELEASE.jar
spring-integration-ip-4.0.3.RELEASE.jar
spring-integration-stream-4.0.3.RELEASE.jar
spring-jms-4.0.7.RELEASE.jar
spring-messaging-4.0.7.RELEASE.jar
spring-oxm-4.0.7.RELEASE.jar
spring-retry-1.1.0.RELEASE.jar
spring-tx-4.0.7.RELEASE.jar
spring-web-4.0.7.RELEASE.jar
spring-webmvc-4.0.7.RELEASE.jar
spring-ws-core-2.2.0.RELEASE.jar
spring-ws-support-2.2.0.RELEASE.jar
spring-xml-2.2.0.RELEASE.jar
tomcat-embed-core-7.0.55.jar
tomcat-embed-el-7.0.55.jar
tomcat-embed-logging-juli-7.0.55.jar
validation-api-1.1.0.Final.jar
wsdl4j-1.6.1.jar
xercesImpl-2.4.0.jar
xmlschema-core-2.1.0.jar
Looks like for the WSDL generation you should provide this dependency:
compile "org.apache.ws.xmlschema:xmlschema-core:2.1.0"
Which is optional from the Spring WS and looks like there is no appropriate implementation in your environment.
UPDATE
Try to add xalan too:
compile "xalan:xalan:2.7.1"
https://groups.google.com/forum/#!topic/google-web-toolkit/07rVeEkCtyU
Or do some tricks with Xerses: java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String

Spring Social XML configuration

My application uses Spring XML configuration. I must add Spring Social's functionality(i want to configure it also by XML) but i encounter an error:
nested exception is java.lang.ClassNotFoundException: org.springframework.social.connect.signin.web.ProviderSignInController
I have tried configuring by XML in my application and also in the spring-social-showcase sample app but the same error... All the jars are in the right place... I took the configuration model from the Spring Social guide. Did anyone configured it by XML?
found the probelm... It seems that there are 2 ProviderSignInController classes in different packages. In the docs there is org.springframework.social.connect.signin.web.ProviderSignInController
and in the jar there is org.springframework.social.connect.web.ProviderSignInController
The ClassNotFoundException tells you that your don't have all the jars in the right place. You're probably missing spring-social-web-1.x.x.RELEASE.jar.

Categories