I'm migrating an application that uses Spring security 3.0 to Spring security 3.1.
I have been getting an error about incorrect schema being referenced:
SEVERE: Exception sending context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration
problem: You must use a 3.0 schema with Spring Security 3.0.(2.0 or 3.1 versions are not
valid) Please update your schema declarations to the 3.0.3 schema (spring-security-
3.0.3.xsd).
Offending resource: ServletContext resource [/WEB-INF/security-context.xml]
When I look in /lib I see a number of jars that are 3.1 versions are duplicated as 3.0 versions. I suspect this is what is causing the error above.
When I look at the dependency tree of the pom.xml using the Eclipse Maven plugin, I can see where the earlier versions are being referenced (eg spring-security-acl depends on several 3.0 jars) but they are marked as 'omitted for conflict with...'. Does that not mean they should be omitted from the built war file?
I've tried explicitly naming 3.1 versions of those files at the root of my pom but the older versions still get included.
Offending resource: ServletContext resource
[/WEB-INF/security-context.xml]
Actually the message indicates that security-context.xml uses schema/declarations which are incompatible with spring-security-3.1. The message is requesting you to use a 3.0 version of the library instead. You may want to review and update it and retry.
I'm still not sure what was going on, but I tried creating a new project in Eclipse with the same pom and source files and now the project seems to behave itself.
Related
I'm upgrading a Spring MVC application from Spring 3.1 to 4.3, and Hibernate 3.6 to 5.2. I'll be running this in Wildfly 8. Dependencies are managed by Maven.
Spring uses commons-logging, which looks at the classpath of the application and attempts to choose a suitable logging framework. In my case, it seems to be choosing the wrong one. I have included log4j in my pom.xml, and checking the dependency hierarchy I can see that jboss-logging is not there. Here is the error message I'm getting:
Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.jboss.logging.Logger.debugf
So even though I don't have jboss logging in my project, commons-logging is finding it somewhere and attempting to use it, but unsuccessfully. After some searching I found jboss-logging-3.1.4.GA.jar in Wildfly.
The reason for the error is that this is an old version of jboss-logging. I added a newer jar to the server and edited module.xml to point to it, and the error went away. That proves that commons-logging is finding jboss-logging on the server.
The problem is that I don't want jboss-logging, I want log4j. How do I force commons-logging to use log4j and ignore what is on the server?
Edit: I followed the link chrisharm put up and added these lines to the standalone.xml file :
<add-logging-api-dependencies value="false"/>
<use-deployment-logging-config value="false"/>
I also changed the module.xml to point to the older jar again, since I would rather see an error if jboss is used. When I run now I get this:
Caused by: java.lang.NoClassDefFoundError: org/jboss/logging/Logger
This may be a step in the right direction, since now Spring doesn't have access to jboss-logging, but it is still trying to use it for some reason.
https://docs.jboss.org/author/display/WFLY8/How+To#HowTo-HowdoIusemyownversionoflog4j%3F
If you need/want to include your version of log4j then you need to do the following two steps.
Disable the adding of the logging dependencies to all your deployments with the add-logging-api-dependencies attribute and disable the use-deployment-logging-config attribute OR exclude the logging subsystem in a jboss-deployment-structure.xml.
Then need to include a log4j library in your deployment.
This only works for logging in your deployment. Server logs will continue to use the logging subsystem configuration.
I am trying to create the Spring Boot application which is submodule of our project's parent pom (which depends on our internal framework which locks down spring dependency versions - as of now we are at 4.2.4-RELEASE)
If I specify the latest Spring Boot version (1.4.1-RELEASE) which depends on spring 4.3.3-RELEASE, I am facing conflicts
One of them is following error:
Caused by: java.lang.NoClassDefFoundError:
org/springframework/beans/factory/ObjectProvider
This class was introduced in 4.3, which explains that error
Is there a way how to keep my Spring Boot dependencies up-to-date without updating Spring versions in internal framework?
You're supposed to keep all your Spring dependencies in sync by making spring-boot-starter-parent your parent.
That sets up all the <dependencyManagement> for you, and you should not then be using <version> when you pull in specific dependencies.
If you need to override a version managed by the parent, there should be a property that you can change, named e.g. logback.version, spring-security.version, etc.
You can also stop one of your dependencies from overriding the versions of its dependencies by using <excludes> to remove the transitive dependency entirely, and ensuring you pull it in from elsewhere. This is a much more brittle though.
You could also try importing spring-boot-dependencies into your dependencyManagement, but you're probably making more work for yourself trying to add your existing projects as the Boot project's parent, rather than as dependencies.
I am running my application on mule server. Mule server has there own sets of jars and my application that is running on mule server also has few jars. While working on Spring batch I found that JettisonMappedXmlDriver class exists in my application xstream jar as well as mule server jar as well. This class internally refer MappedXMLOutputFactory class that is in jettision jar which is also in my application but some how I am getting classnotfound error for MappedXMLOutputFactory class. This looks like class-loader issue.
If I add jettision jar in mule server then everything work fine but, I can't add this jar on my production environment. Can some body tell me how do I force to load the class from my application jettision jar file. It looks weird to me as classloader should have load MappedXMLOutputFactory class from jettision jar that is in my application folder like it is doing for other classes.
Please let me know if anybody found such issue.
The Mule application classloader is configurable: http://www.mulesoft.org/documentation/display/current/Classloader+Control+in+Mule
So just configure your application's classloader to first look at the JARs it embeds in /lib before deferring to the Mule System classloader.
You will encounter this issue if you have multiple versions of the same class in differnet jars, albeit with different method signatures. The ClassNotFound Error is usually not the only exception that occurs, you will often see another one before that, typically a "NoSuchMethodException" which forces class loader to unload the offending class.
I would suggest using maven or gradle to assemble your application and then use the dependency:tree target to query version conflicts.
i am using spring 3.2.4 (latest stable version) with hibernate
i have added all the dependencies but still i am getting the error which is below
java.lang.NoClassDefFoundError: org/springframework/transaction/interceptor/TransactionInterceptor
if i use maven
then i get too many errors like Failed to Autowired (in both service and DAO),
org.springframework.beans.factory.BeanCreationException:
java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider
please help me to solve problem for one of above. i want to create an application (spring + Hibernate) any of way (with maven or without maven)
The application is missing the hibernate-core-x.x.x.jar file. You will need to find the appropriate version of the jar.
Use FindJar: http://www.findjar.com/jar/org/hibernate/hibernate-core/3.3.2.GA/hibernate-core-3.3.2.GA.jar.html
The class java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider is included in version of Hibernate before version 4.0. I would update all of your libraries to use the 4.0 version.
I have a webapp running JAX-RS web services using the Jersey implementation. The target app server is a WebLogic 12c whose default JAXRS implementation is Jersey v1.9.
1) when run on Jetty (6.1.26) with jersey-server-1.9 dependency, everything is fine.
2) when run on WebLogic 12c with jersey-core.jar + jersey-server.jar (v1.9) jars both embedded in the WEB-INF/lib of my war, it is also working.
2) when run on WebLogic 12c with the same war amputed from these 2 jars (assuming there are not needed as already provided by the weblogic Java EE stack), it does NOT work anymore. I got the following error:
"weblogic.application.ModuleException: [HTTP:101216]Servlet: "jersey-servlet" failed to preload on startup in Web application: "cachede-newgen.war".
com.sun.jersey.api.container.ContainerException: The ResourceConfig instance does not contain any root resource classes.
at com.sun.jersey.server.impl.application.RootResourceUriRules.(RootResourceUriRules.java:99)"
Needless to say the Jersey version is exactly identical in all three cases:
"Apr 24, 2013 4:10:24 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.9 09/02/2011 11:17 AM'"
It sounds again (sight!) like a classpath or classloader issue :-(
Any idea or workaround to solve this issue (taking accound that I do NOT want to repeat jersey jars in every deployed war) ?
Ok I found the reason :-) - and "better_use_mkstemp" put me on the right direction (many thx!).
The solution consists in adding a reference to the deployed Jersey version in the weblogic descriptor file:
<library-ref>
<library-name>jersey-bundle</library-name>
<specification-version>1.1.1</specification-version>
<implementation-version>1.1.5.1</implementation-version>
</library-ref>
The strange thing is that, without such ref, the error message (ie "The ResourceConfig instance does not contain any root resource classes") gives the feeling that Jersey is able to start and scan your annotated classes...
NB: Actually, you also need a reference to the JSR-311 api, as explained here:
http://theblasfrompas.blogspot.be/2011/03/time-to-deploy-restful-web-service-from.html
Have you "deployed" the jersey jar to your server? In the admin console go to Deployables (click Customize the table and uncheck exclude libraries). See if Jersey is listed there. If not, you will need to "deploy" it and target whatever servers you need it on. Then try to redeploy your war file.
Jersey should live in:
wlserver_10.3/common/deployable-libraries
Those shared libraries aren't automatically available to your server until they are targetted to it.
Just remove all Jersey jars and add one Jersey Bundle jar it will work. I have faced the same Issue and resolved after adding Jersey Bundle jar into to class path.