Results 1 to 7 of 7

Thread: Problems running DeclarativeTransactionalManagement Spring Framework tutorial in STS

  1. #1
    Join Date
    Oct 2006
    Posts
    12

    Default Problems running DeclarativeTransactionalManagement Spring Framework tutorial in STS

    First let me say that my initial reaction to the STS and its tutorials is to think really great stuff guys! I managed to work through all 7 OSGi tutorials and was really looking forward to getting into the meat of things with the Spring Framework tutorials, but then I ran across a bit of a snag in the first Spring Framework tutorial entitled "Adding Declarative Transaction Management to Your Spring Applications" involving what appears to be a missing commons-logging jar in the project's classpath.

    The error occurs late in the tutorial around the "" step towards the end during the JUnit testing of the TransferServiceTransactionManagementTests class in the "Verify Transactional Behavior" step, and consists of the following Classpath not found on LogFactory error :

    java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.<clinit>(SpringJUnit4ClassRunner.jav a:62) at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Construc tor.java:494) at org.junit.internal.requests.ClassRequest.buildRunn er(ClassRequest.java:33) at org.junit.internal.requests.ClassRequest.getRunner (ClassRequest.java:28) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.<init>(JUnit4TestReference.java:28) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestC lassReference.<init>(JUnit4TestClassReference.java :24) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestL oader.createTest(JUnit4TestLoader.java:40) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestL oader.loadTests(JUnit4TestLoader.java:30) at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:445) at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)

    ---------------
    I was able to get around this error by downloading and placing a copy of the latest commons-logging jar (commons-logging-1.1.1.jar) into the classpath of the BankApp project's launch config for this test, but now I am seeing another error which is an apparent inability for the test application to find the applicationContext :


    java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Cla ss.java:2357)
    at java.lang.Class.getConstructor0(Class.java:2671)
    at java.lang.Class.getDeclaredConstructor(Class.java: 1953)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:74)
    at org.springframework.test.context.TestContext.<init >(TestContext.java:107)
    at org.springframework.test.context.TestContextManage r.<init>(TestContextManager.java:103)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.createTestContextManager(SpringJUnit 4ClassRunner.java:102)
    at org.springframework.test.context.junit4.SpringJUni t4ClassRunner.<init>(SpringJUnit4ClassRunner.java: 79)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:494)
    at org.junit.internal.requests.ClassRequest.buildRunn er(ClassRequest.java:33)
    at org.junit.internal.requests.ClassRequest.getRunner (ClassRequest.java:28)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestR eference.<init>(JUnit4TestReference.java:28)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestC lassReference.<init>(JUnit4TestClassReference.java :24)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestL oader.createTest(JUnit4TestLoader.java:40)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestL oader.loadTests(JUnit4TestLoader.java:30)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:445)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)

    ---------------
    Before I continue hacking away at this thing, I figured I ought to do the unmanly thing and stop and ask for directions... First of all, is it just me, or is anyone else seeing this problem? And, is there maybe some bigger problem anyone can think of going on here which may be causing all of these hassles?

    Thanks!

  2. #2
    Join Date
    Sep 2006
    Location
    Work in New York City
    Posts
    127

    Default

    I am getting the same error on STS 2.3.1 trying to run the JUnit tests that are in the "Verify Transactional Behavior" step of the tutorial:

    Code:
    java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
    	at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.<clinit>(SpringJUnit4ClassRunner.java:62)
    This is particularly vexing for me because I am using a new MacBookPro and am an Apple newbie and all the STS/Eclipse menus are different than in Ubuntu and WinDoz.

    Looking in the .m2/repository, I see that instead of the org.apache.commons.logging that I expect, there is instead org.apache.commons/com.springsource.org.apache.commons.logging/1.1.1/com.springsource.org.apache.commons.logging-1.1.1.jar

    Has anyone besides to two of us grappled with this?
    Java Developer with all the usual Sun Java certifications.

  3. #3
    Join Date
    Jun 2010
    Location
    Dallas, TX
    Posts
    6

    Default

    I am getting this same error, and it appears to have nothing to do with STS or the Transactional nature of the example, I am getting it in both command line using maven to run the test, and regular eclipse junit running as well. (not STS).

    Onward, to guess through the many jars that might solve the problem. Does this mean that not many people are exercising this new release yet?

  4. #4
    Join Date
    Sep 2006
    Location
    Work in New York City
    Posts
    127

    Default

    Quote Originally Posted by petecarapetyan View Post
    .... Does this mean that not many people are exercising this new release yet?
    I have reached that conclusion myself, but have no way to verify if it's
    really true. It seems to me that most and possibly all of the STS tutorials
    do not actually work. Rather, they sort of "give you the idea" without
    actually compiling and running cleanly.


    Sadly, I have bigger problems than that. STS uses the m2elipcse plugin
    that under the covers uses maven 3.0beta. Maven, unfortunately, starting
    having problems getting through corporate firewalls starting with the maven
    2.2x release. The band aid approach to solving this which maven has
    adopted (a configuration parameter that supposedly reverts it to use the
    proxy the way it used to work before maven 2.2) has not worked for me.
    The only versions of m2Eclipse that work for me on the job are the older,
    "0.97xx" releases of m2Eclipse because they use maven 2.09.


    So, I am between a rock and a hard place. At work with the firewall, STS
    won't work because of the version of m2Eclipse it uses. At work I instead use
    Eclipse 3.4 with the older m2Eclipse version. I have lost the benefits of STS
    entirely on the job.
    Java Developer with all the usual Sun Java certifications.

  5. #5
    Join Date
    Jun 2010
    Location
    Dallas, TX
    Posts
    6

    Default

    Robert, the challenges you mentioned above do not seem to be the problem for me. I've got access to everything I need with a local nexus server and no firewall issues. The problem seems to be an undeclared dependency or some other missing reference that I don't grok.

    I am running the simplest hello world level code that I can think of constructing, excepting that I'm using the jars from the OSGI bundle repository. It compiles fine, just blows up at runtime.

  6. #6
    Join Date
    Jun 2010
    Location
    Dallas, TX
    Posts
    6

    Default

    Add this to your pom.xml and you'll be off and running:

    <dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>com.springsource.org.apache.commons.lo gging</artifactId>
    <version>1.1.1</version>
    </dependency>
    Normally I think of such transitive dependencies as being handled for me automagically, which is why I had to scratch my head first.
    Last edited by petecarapetyan; Jun 18th, 2010 at 01:26 PM.

  7. #7
    Join Date
    Sep 2006
    Location
    Work in New York City
    Posts
    127

    Default

    [QUOTE=petecarapetyan;305557...I've got access to everything I need with a
    local nexus server and no firewall issues. ...[/QUOTE]

    Mea Culpa (that is Latin for "I am guilty"). I went off topic. It seems to me
    Spring is at a crossroads. Using Spring in a corporate setting is shifting to an
    area where it is best to have a support contract with Spring so that tricky
    "border case" issues can be addressed quickly by the right people. Meanwhile,
    Spring for many of us, regardless of the work sitatuation, remains a wonderful place
    to experiment at home in an unrestricted, proxyless environment.
    Java Developer with all the usual Sun Java certifications.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •