Struts 2 Annotation With Interceptors not Working - spring

I have been trying to implement Interceptors in my application each and everything works fine till the time I don't include interceptor Annotation in my action. But, when I just add the InterceptoRef tag in my action like the code below:
#InterceptorRefs({
#InterceptorRef("mylogging")
})
public class LoginAction implements ModelDriven{
It starts giving me exception
SEVERE: Exception starting filter struts2
Unable to load configuration. - [unknown location]
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:431)
at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:69)
at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51)
at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:281)
at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:262)
at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:107)
at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4746)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5399)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1654)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: Unable to load configuration. - [unknown location]
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:58)
at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:374)
at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:418)
... 19 more
Caused by: Unable to find interceptor class referenced by ref-name mylogging - [unknown location]
I am using Struts 2 with Struts2-convention-plugin , Hibernate, Spring and using Maven for dependency management.
I have following dependencies which I have defined in Maven's POM file:
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.1.8.1</version>
</dependency>
<!-- Struts 2 + Spring plugins -->
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-spring-plugin</artifactId>
<version>2.1.8.1</version>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>2.5.6</version>
</dependency>
<!-- Hibernate core -->
<dependency>
<groupId>asm</groupId>
<artifactId>asm-all</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.7.Final</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.1.8.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
I have placed Struts.xml in the src root. So as far as I think there must be something missing in configuration.
Struts.xml file configuration:
<struts>
<constant name="struts.devMode" value="false" />
<constant name="struts.convention.package.locators.basePackage" value="com.abc.lab"/>
<constant name="struts.convention.exclude.packages" value="org.apache.struts.*,org.apache.struts2.*,org.springframework.web.struts.*,org.springframework.web.struts2.*,org.hibernate.*,WarFileName.*"/>
<constant name="struts.convention.action.checkImplementsAction" value="false"/>
<constant name="struts.convention.package.locators" value="action,actions,struts,struts2"/>
<package name="default" extends="struts-default" namespace="/">
<interceptors>
<interceptor name="mylogging"
class="com.abc.lab.interceptor.LoggingInterceptor">
</interceptor>
<interceptor-stack name="loggingStack">
<interceptor-ref name="mylogging" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
</package>
</struts>

If you get errors like "Unable to find interceptor class referenced by ref-name XYZ". This means that the package where Convention is placing your actions, does not extend the package where the interceptor is defined. To fix this problem either 1)Use #ParentPackage annotation(or struts.convention.default.parent.package) passing the name of the package that defines the interceptor, or 2) Create a package in XML that extends the package that defines the interceptor, and use #ParentPackage(or struts.convention.default.parent.package) to point to it.

Related

OrientDB with spring mvc configuration

Please suggest me how can i configure the orientdb with spring mvc.
<bean id="databaseFactory" class="org.ops4j.orient.spring.tx.OrientObjectDatabaseFactory"
p:url="remote:localhost/MyDB" p:username="userName" p:password="pwd" />
<bean id="orTransactionManager" class="org.ops4j.orient.spring.tx.OrientTransactionManager"
p:databaseManager-ref="databaseFactory" />
I have added above code into my mvc-dispacher-servlet.xml file
and i have added dependencies also in to pom.xml
<dependency>
<groupId>org.ops4j.orient</groupId>
<artifactId>orient-spring-tx</artifactId>
<version>0.3.0</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-graphdb</artifactId>
<version>2.2.13</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-enterprise</artifactId>
<version>2.2.0-beta</version>
</dependency>
My OrientDb server is 2.2.13 version which is latest.
help me in configuring it.if possible suggest a sample project URL also.
Thank You

Can we run drools 5 and drool 6 in parallel in same application ( drools- spring ) integration application

I have existing application based on drools 5 rules engine and need to migrate to drools 6 but we can not do in one go i.e we have to do in multiple stages .
So my requirement is i want to support droosl 5 and drool 6 execution in parallel in same application .
For that i have created sample poc
1) Created drools spring integration application having both drools 5 and drool 6 spring integration configuration files .
For Drools 5 :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:oxm="http://www.springframework.org/schema/oxm"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd
http://drools.org/schema/drools-spring org/drools/container/spring/drools-spring-1.2.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<drools:grid-node id="node" />
<drools:kbase id="drools5Kbase" node="node">
<drools:resources >
<!-- <drools:resource type="DRF" source="classpath:rules/distribution/regulatory/Test.rf" /> -->
<drools:resource type="DRL" source="classpath:rules/Sample.drl" />
</drools:resources>
</drools:kbase>
</beans>
****Drools 6 :****
<kie:kmodule id="Drools6POC">
<kie:kbase name="rules-two" packages="rules.two" />
<kie:kbase name="drools6KieBase" packages="rules, process" includes="rules-two">
<!--<kie:ksession name="ksessionRules">
<kie:fileLogger file="drools.log" threaded="true" interval="10" />
<kie:listeners>
<kie:ruleRuntimeEventListener ref="org.kie.api.event.rule.DebugRuleRuntimeEventListener" />
<kie:agendaEventListener ref="org.kie.api.event.rule.DebugAgendaEventListener" />
<kie:processEventListener ref="org.drools.core.event.DebugProcessEventListener" />
</kie:listeners>
</kie:ksession>
-->
</kie:kbase>
</kie:kmodule>
2) Added maven depencies for both drools 5 and drools 6 by changing drools 5 standard jar's group id and arctifact id in order to avoid version overwite
3) With above configuration drools 6 working fine but while loading drools 5 spring configuration file getting error
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#70c44470: defining beans [node,drools5Kbase,drools5RuleSet]; root of factory hierarchy
Apr 20, 2015 12:11:33 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#70c44470: defining beans [node,drools5Kbase,drools5RuleSet]; root of factory hierarchy
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'drools5Kbase': Invocation of init method failed; nested exception is org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel:org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration'
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.sample.service.ProcessAndRuleService.main(ProcessAndRuleService.java:55)
Caused by: org.drools.RuntimeDroolsException: Unable to load dialect 'org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration:mvel:org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration'
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:310)
at org.drools.compiler.PackageBuilderConfiguration.buildDialectConfigurationMap(PackageBuilderConfiguration.java:295)
at org.drools.compiler.PackageBuilderConfiguration.init(PackageBuilderConfiguration.java:184)
at org.drools.compiler.PackageBuilderConfiguration.<init>(PackageBuilderConfiguration.java:162)
at org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactoryServiceImpl.java:22)
at org.drools.builder.KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(KnowledgeBuilderFactory.java:74)
at org.drools.container.spring.beans.KnowledgeBaseBeanFactory.afterPropertiesSet(KnowledgeBaseBeanFactory.java:80)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 12 more
Caused by: java.lang.ClassCastException: org.drools.compiler.rule.builder.dialect.mvel.MVELDialectConfiguration cannot be cast to org.drools.compiler.DialectConfiguration
at org.drools.compiler.PackageBuilderConfiguration.addDialect(PackageBuilderConfiguration.java:305)
... 20 more
4) Pom.xml
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestDroolsVersion</groupId>
<artifactId>TestDroolsVersion</artifactId>
<version>1.0.0</version>
<name>TestDroolsVersion</name>
<description>TestDroolsVersion</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<drools6.version>6.1.0.Final</drools6.version>
<spring.framework.version>3.1.0.RELEASE</spring.framework.version>
<mvel2.version>2.1.0.drools4</mvel2.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${drools6.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-api</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-ci</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-spring</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.jbpm</groupId>
<artifactId>jbpm-bpmn2</artifactId>
<version>6.1.0.Final</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.0.2</version>
</dependency>
<!-- START : Drools 5 -->
<dependency>
<groupId>org.drools.custom</groupId>
<artifactId>drools-core-custom</artifactId>
<version>5.3.1.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.drools.custom</groupId>
<artifactId>drools-compiler-custom</artifactId>
<version>5.3.1.Final</version>
<exclusions>
<exclusion>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-spring</artifactId>
<version>5.3.1.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.framework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.framework.version}</version>
</dependency>
</dependencies>
</project>
Your help will be appriciated .
1) Can we support drools 5 and drool 6 in parallel in same classpath
2) If yes is there any way or any one have any sample
Thanks and regards
Sri
It's possible to run multiple versions of drools on the same container, but in this case both the versions are being installed in the same assembly.
Using maven it's possible to have a parent pom project and a multiple module sub-project structure. In this case there will not be any classpath collisions on the Drools compiler and this will work. Otherwise conflicting versions in the same project will need maven exclusions and i'm certain this will work correctly.

Why does Spring Data MongoDB 1.5.2 fail a with NoSuchMethodError?

I can't seem to get the most basic MongoTemplate to initialize with spring-mongodb.
Here's the relevant extract from my POM:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
My XML context setup looks like this:
<mongo:db-factory id="mongoDbFactory"
host="${mongo.host}"
port="${mongo.port}"
dbname="${mongo.db}"/>
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean>
This results in:
java.lang.NoClassDefFoundError: Could not initialize class org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper
org.springframework.data.mongodb.core.convert.MappingMongoConverter.<init>(MappingMongoConverter.java:104)
org.springframework.data.mongodb.core.MongoTemplate.getDefaultMongoConverter(MongoTemplate.java:1670)
org.springframework.data.mongodb.core.MongoTemplate.<init>(MongoTemplate.java:205)
org.springframework.data.mongodb.core.MongoTemplate.<init>(MongoTemplate.java:191)
...
Debugging the initialization of DefaultMongoTypeMapper reveals:
java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/TypeInformation;
I've tried all sorts of different version combinations for spring-core and spring-data, as well as trying to manually specify a version of spring-data-commons, no dice.
Is there something basic I'm doing wrong here?
EDIT: Full trace of error is:
Error creating bean with name 'mongoTemplate' defined in ServletContext resource [/WEB-INF/mvc-dispatcher-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.data.mongodb.core.MongoTemplate]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.data.util.ClassTypeInformation.from(Ljava/lang/Class;)Lorg/springframework/data/util/TypeInformation;
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1120)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:522)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:647)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:598)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:517)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:458)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:138)
As indicated in the ticket you filed, Spring Data MongoDB 1.5.2 requires Spring Data Commons 1.8.2 (or any other 1.8.x version). The Spring version has to be at least 3.2.10 (although Spring itself doesn't play into the exception you see as it is about a tiny signature change in Spring Data Common's ClassTypeInformation). If that's the case, you won't see the original exception.
We generally recommend to use the Spring Data Releasetrain BOM or the Spring IO platform instead of manually dealing with versions.
Try making your dependencies like this ;). You might be missing something from the tutorial page.
<dependencies>
<!-- Spring framework -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.2.2.RELEASE</version>
</dependency>
<!-- mongodb java driver -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.0</version>
</dependency>
<!-- Spring data mongodb -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>
</dependencies>
source: http://www.mkyong.com/mongodb/spring-data-mongodb-hello-world-example/
OK.. so it seems there is an incompatibility somewhere. It's unclear but the stack trace seems to indicate that AutowiredAnnotationBeanPostProcessor is trying to call a method of ClassTypeInformation that doesn't exist. This method was last seen in 1.7.3-RELEASE of spring-data-commons. Reverting to that version appears to fix things, but I'm not sure if this will cause errors elsewhere.
The final POM looks like this:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.7.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>1.5.2.RELEASE</version>
</dependency>
Try including spring-data-commons Jar. This class is defined here. I guess this is why it is causing the issue.

Could not initialize class org.apache.cxf.staxutils.StaxUtils

I'm developing an application using Spring/Maven and I'm experiencing a problem with a dependency. Everything was working but when I added a dependency to Spring-WS, my tests stopped working.
Here is the stacktrace I have, leading to a Failed to load ApplicationContext
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.cxf.staxutils.StaxUtils
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:256)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:203)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:98)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:199)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:98)
at javax.xml.ws.Service.<init>(Service.java:77)
at com.mycompany.webservice.documentservice.client.DocumentServiceService.<init>(DocumentServiceService.java:61)
at com.mycompany.service.implementation.DocumentService.<init>(DocumentService.java:121)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
And here is the new dependencies :
<!--
Spring WS
-->
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
<version>${spring-ws.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-security</artifactId>
<version>${spring-ws.version}</version>
</dependency>
I think there is a conflict with CXF dependencies but can't find where :
<!--
Web Service
-->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>${cxf.version}</version>
</dependency>
Here are the conflicts, but when I add an exclusion the problem still occurs
Thanks for the help.
Ok I fixed the issue by doing the following :
Upgrade from CXF 2.7.6 to 2.7.7
Add dependency to
<dependency>
<groupId>com.sun.xml.stream</groupId>
<artifactId>sjsxp</artifactId>
<version>${sjsxp.version}</version>
</dependency>
Can't explain why but the tests run well and the application too.

what versions to use when using Spring-ws spring-integration and spring-security altogether

I'm using Spring-integration 2.0.0 and wanted to secure the calls to the web services exposed by Spring integration. So I used the secured channels and it works fine so far using Spring-core 3.0.5 and Spring security 3.0.5.
But then I wanted to use the WSS interceptors of Spring web services. And then came the following problem :
when I declare the XwsSecurityInterceptor like this :
<bean id="wsSecurityInterceptor" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
<description>
This interceptor validates incoming messages according to the policy defined in 'securityPolicy.xml'.
The policy defines that all incoming requests must have a UsernameToken with a password digest in it.
The actual authentication is performed by the Spring Security callback handler.
</description>
<property name="secureResponse" value="false"/>
<property name="policyConfiguration"
value="classpath:securityPolicy.xml"/>
<property name="callbackHandler">
<bean class="org.springframework.ws.soap.security.xwss.callback.SpringPlainTextPasswordValidationCallbackHandler">
<property name="authenticationManager" ref="authenticationManager"/>
</bean>
</property>
</bean>
I get this stack :
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wsSecurityInterceptor' defined in class path resource [SES/Operations/Logging/applicationContext-security.xml]: Cannot create inner bean 'org.springframework.ws.soap.security.xwss.callback.SpringPlainTextPasswordValidationCallbackHandler#b0dbb' of type [org.springframework.ws.soap.security.xwss.callback.SpringPlainTextPasswordValidationCallbackHandler] while setting bean property 'callbackHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.ws.soap.security.xwss.callback.SpringPlainTextPasswordValidationCallbackHandler#b0dbb' defined in class path resource [SES/Operations/Logging/applicationContext-security.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/AuthenticationManager
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:281)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:120)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1317)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:574)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630)
at org.apache.catalina.core.StandardContext.reload(StandardContext.java:3391)
at org.apache.catalina.loader.WebappLoader.backgroundProcess(WebappLoader.java:426)
at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1309)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.ws.soap.security.xwss.callback.SpringPlainTextPasswordValidationCallbackHandler#b0dbb' defined in class path resource [SES/Operations/Logging/applicationContext-security.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/AuthenticationManager
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:270)
... 25 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/security/AuthenticationManager
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.privateGetPublicMethods(Class.java:2547)
at java.lang.Class.getMethods(Class.java:1410)
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1280)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1154)
at java.beans.Introspector.getBeanInfo(Introspector.java:405)
at java.beans.Introspector.getBeanInfo(Introspector.java:164)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:149)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:305)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:335)
at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:407)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 27 more
Caused by: java.lang.ClassNotFoundException: org.springframework.security.AuthenticationManager
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491)
... 43 more
my maven dependencies are :
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-ldap</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-core</artifactId>
<version>1.5.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-server-jndi</artifactId>
<version>1.5.5</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-security</artifactId>
<version>1.5.9</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Spring integration dependencies -->
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-xml</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-security</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-ws</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
I guess this has something to do with a dependency problem as I read that some packages have been reworked between 2.x and 3.x versions. Please note that I had to exclude transitive dependency from spring-ws-security to spring-beans as it was bringing the 2.0.6 version of spring beans which were conflicting with 3.0.5 release of the same jar.
So my question is : what versions of the different Spring modules (Spring-ws, Spring-integration, Spring-security, Spring-framework) should I use ?
Thanks in advance for any help
Fabrice
The latest versions should work together. As spring-ws version 2.0 was released this week your problem should be solved for production too.

Resources