It was a dependency issue

It was the simple beginning of a test:

public class SomethingTest {
    public void testSomething() throws JMSException {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(

Yet when I tried to run it, I got this:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jmsConnectionFactory' defined in class path resource [com/ontsys/learn/transactions/spring/beans.spring.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
Caused by: java.lang.NoClassDefFoundError: javax/transaction/TransactionManager
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(
    at java.lang.Class.getDeclaredMethods(

…and so on.

It looked like my Maven pom file was not set up with everything it needed. I didn’t understand how that could be since I was modelling my pom file after another project that was working fine. I looked in that project’s parent pom file and didn’t see anything about transactions in there.

What it was, was…

It turns out when I thought I was looking at the parent pom file for the project I was following, I missed and got the grandparent pom instead. (We’d just switched around to even have a grandparent pom within the last few days and it didn’t sink in that I was missing looking at the immediate parent.)

Anyway, in the parent pom was the following dependency:


I added that dependency to my new project’s pom.xml (and ran Maven Eclipse* to update my project with the new dependencies) and now my test can find the classes it needs.

Thanks for the help again, Keith!

*Not m2eclipse, mind you (yet, anyway — we haven’t seemed to be able to get that working for what we need) — just the regular Maven Eclipse plugin used as an Eclipse External Tool running the eclipse:clean and eclipse:eclipse goals.


  1. #1 by Jonathan Branam on June 27, 2008 - 3:37 pm

    Nice! You’ve got to love the POM. Intricate and complex, but ultimately helpful.

    Glad my Eclipse setup is still providing use. It would be nice if there was a real plugin that would implement Maven dependencies the same way the command line does!

Leave a Reply

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

You are commenting using your 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