Announcement Announcement Module
Collapse
No announcement yet.
errors running Juint tests outside of Tomcat with Spring and Hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • errors running Juint tests outside of Tomcat with Spring and Hibernate

    I am running a large web application that makes use of the Spring and Hibernate frameworks. The application runs fine in Tomcat, but when I run my unit tests, I get errors when instantiating beans. I believe this to be a classpath issue, but cannot seem to figure out where. It seems like the spring framework is not being built (as it would be by the Tomcat container) prior to unit tests running, therefore causing a problem when instantiating the beans from c3p0.*. Below is a stacktrace of my errors when running Junit tests. Any help is appreciated. Thanks.

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'mcdsDataSource' defined in file [C:\Documents and Settings\jmeacham\myEclipse_Workspace\MCDS\WebRoot \WEB-INF\applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/jboss/mx/util/PropertyAccess
    org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [com.mchange.v2.c3p0.ComboPooledDataSource]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/jboss/mx/util/PropertyAccess
    java.lang.NoClassDefFoundError: org/jboss/mx/util/PropertyAccess
    at javax.management.MBeanServerFactory.createMBeanSer ver(MBeanServerFactory.java:202)
    at javax.management.MBeanServerFactory.createMBeanSer ver(MBeanServerFactory.java:153)
    at javax.management.MBeanServerFactory.createMBeanSer ver(MBeanServerFactory.java:147)
    at sun.management.ManagementFactory.createPlatformMBe anServer(ManagementFactory.java:302)
    at java.lang.management.ManagementFactory.getPlatform MBeanServer(ManagementFactory.java:504)
    at com.mchange.v2.c3p0.management.ActiveManagementCoo rdinator.<init>(ActiveManagementCoordinator.java:4 2)
    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:513)
    at java.lang.Class.newInstance0(Class.java:355)
    at java.lang.Class.newInstance(Class.java:308)
    at com.mchange.v2.c3p0.C3P0Registry.<clinit>(C3P0Regi stry.java:134)
    at com.mchange.v2.c3p0.impl.PoolBackedDataSourceBase. <init>(PoolBackedDataSourceBase.java:228)
    at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSou rce.<init>(AbstractPoolBackedDataSource.java:62)
    at com.mchange.v2.c3p0.ComboPooledDataSource.<init>(C omboPooledDataSource.java:109)
    at com.mchange.v2.c3p0.ComboPooledDataSource.<init>(C omboPooledDataSource.java:105)
    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:513)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:171)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:148)
    at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:52)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:486)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:362)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:233)
    at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:145)
    at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:283)
    at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:313)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:89)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:74)
    at com.meddorna.util.SpringBeanFactory.init(SpringBea nFactory.java:71)
    at com.meddorna.util.SpringBeanFactory.getCtx(SpringB eanFactory.java:108)
    at com.meddorna.delegate.db.BaseDbDelegate.getCtx(Bas eDbDelegate.java:36)
    at com.meddorna.delegate.db.BaseDbDelegate.getService (BaseDbDelegate.java:62)
    at com.meddorna.delegate.db.CodeLookupDelegate.getSvc (CodeLookupDelegate.java:82)
    at com.meddorna.delegate.db.CodeLookupDelegate.getDec odeForCode(CodeLookupDelegate.java:66)
    at com.meddorna.domain.view.McdsBaseView.getDecodeFor Code(McdsBaseView.java:18)
    at com.meddorna.domain.view.VisitView.setStatus(Visit View.java:577)
    at test.practiceITprn.translators.VisitTranslatorTest .stuffVisitView(VisitTranslatorTest.java:760)
    at test.practiceITprn.translators.VisitTranslatorTest .setUp(VisitTranslatorTest.java:711)
    at junit.framework.TestCase.runBare(TestCase.java:125 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit 3TestReference.run(JUnit3TestReference.java:130)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
    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)


  • #2
    errors running Juint tests outside of Tomcat with Spring and Hibernate: JBoss

    The string "java.lang.NoClassDefFoundError: org/jboss/mx/util/PropertyAccess" that appears in the stack trace multiple times does agree with your assertion that this is likely a classpath issue. The fact that it is a JBoss class that cannot be found also coincides with your description of the application working within a container (presumably a JBoss container or container that uses injected JBoss classes) but not working outside the container. The container often provides a large classpath of its own in addition to any files in the relevant WAR or EAR's classpath. Therefore, it is likely that you need one of these JARs or .class files in your outside-of-the-container environment. You might look into what is requiring a JBoss class in the first place to determine if that can have something else not JBoss-specific injected in its place (such as a mock object).

    Comment


    • #3
      Problem Solved!

      Thanks very much for the reply. Turns out that it was the Hibernate jar that was causing the problem. It must be added to the classpath and the source path specified in the .classpath file. I suppose that Tomcat will add hibernate during its own build process, but since I am running the unit tests outside of the container, I must specify the entry and source for hibernate in the classpath.

      Comment

      Working...
      X