Captain, we’re experiencing a configuration problem…

Last time we briefly tried to divine whether we were truly in an XA transaction, and ended wanting to set up AOP-controlled transactions.  That’s where we are today…


I added this (with the class name of my domain class) to my Spring bean file to enable transactions for the messagelistener:

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="*" />
    </tx:attributes>
</tx:advice>

<aop:config>
    <aop:pointcut id="stuff" expression="execution(* com.example.MessageListener(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="stuff" />
</aop:config>

When I deployed this, I got:

15:12:25,757 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/aop]
Offending resource: class path resource [applicationContext.xml]

The AOP xmlns and schemaLocation looked right in the applicationContext.xml, so I did a web search for the error and…

An entry in the note19 blog gave me the idea to check to make sure my project includes the AOP portion of the Spring libraries in its dependencies… so I ended up adding both spring-aop and spring-aspects to my pom file.

I needed both

With only spring-aspects I still got the Unable to locate Spring NamespaceHandler error; with only spring-aop I got an exception (nested, of course :), to wit:

NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldException

But with both spring-aspects and spring-aop in my pom as dependencies, the error is gone!  Replaced by…

The next error

Now I get this:

16:18:30,896 ERROR [ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘queueConnectionFactory’: Initialization of bean failed; nested
exception is java.lang.IllegalArgumentException: warning no match for this type name: com.example [Xlint:invalidAbsoluteTypeName]

My queueConnectionFactory JNDI-lookup bean definition looks like this:

<jee:jndi-lookup id="queueConnectionFactory" jndi-name="java:activemq/QueueConnectionFactory" />

And that definition has been working — my messageListener has been getting messages using that queue connection factory.  So I suspect that somehow the AOP beans — which look like this:

<tx:advice id="txAdvice" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="*" />
    </tx:attributes>
</tx:advice>

<aop:config>
    <aop:pointcut id="stuff" expression="execution(* com.example.MessageListener(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="stuff" />
</aop:config>

— are causing the problem.

If I comment out the

<aop:advisor advice-ref="txAdvice" pointcut-ref="stuff" />

line, the error goes away (but then of course the message receives don’t roll back when a runtime exception is encountered either…)

Let’s pursue this next time.

Advertisements

,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s