Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » greenpages sample getting errors on junit test(greenpages sample getting errors on junit test Caused by: org.springframework.beans.factory.BeanCreationException)
greenpages sample getting errors on junit test [message #1161410] Tue, 29 October 2013 15:58 Go to next message
Brent Jacox is currently offline Brent Jacox
Messages: 5
Registered: February 2013
Junior Member
I have downloaded the greenpages samples-3.0.0.RC1. When I run a mvn package on the greenpages home I was getting an error about the Log Factory:
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running greenpages.jpa.JpaDirectorySpringContextTests
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.04 sec <<< FAILURE!

Results :

Tests in error:
  initializationError(greenpages.jpa.JpaDirectorySpringContextTests): org/apache/commons/logging/LogFactory

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0


So I found another post here that recommended adding another dependency

Now I am getting this error:
-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running greenpages.jpa.JpaDirectorySpringContextTests
Oct 29, 2013 1:53:28 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/spring/module-context.xml]
Oct 29, 2013 1:53:28 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [META-INF/spring/test-context.xml]
Oct 29, 2013 1:53:28 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing org.springframework.context.support.GenericApplicationContext@5f08cd64: startup date [Tue Oct 29 13:53:28 MDT 2013]
; root of context hierarchy
Oct 29, 2013 1:53:29 PM org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@9856ec1: defining beans [org.spr
ingframework.context.weaving.AspectJWeavingEnabler#0,org.springframework.context.config.internalBeanConfigurerAspect,loadTimeWeaver,
entityManagerFactory,transactionManager,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springfr
amework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationPro
cessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersi
stenceAnnotationProcessor,org.springframework.transaction.config.internalTransactionAspect,org.springframework.dao.annotation.Persis
tenceExceptionTranslationPostProcessor#0,directory,dataSource,greenpages.jpa.TestDataPopulator#0,org.springframework.context.annotat
ion.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
Oct 29, 2013 1:53:29 PM org.springframework.test.context.TestContextManager prepareTestInstance
SEVERE: Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecu
tionListener@452d9a56] to prepare test instance [greenpages.jpa.JpaDirectorySpringContextTests@34efa795]
java.lang.IllegalStateException: Failed to load ApplicationContext
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:308)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionT
estExecutionListener.java:109)
        at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjection
TestExecutionListener.java:75)
        at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:321)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:220)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:301)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:303)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:240)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
        at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:
61)
        at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70
)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
        at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:180)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:236)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:134)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:113)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:103)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:74)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.weavi
ng.AspectJWeavingEnabler#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationExcept
ion: Error creating bean with name 'loadTimeWeaver': Initialization of bean failed; nested exception is java.lang.IllegalStateExcept
ion: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(ClassFileTransformer)' method. Specify a cus
tom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.springframework.instrument.jar
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFact
ory.java:527)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactor
y.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:197)
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1097)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext
.java:661)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:84)
        at org.springframework.test.context.support.AbstractGenericContextLoader.loadContext(AbstractGenericContextLoader.java:1)
        at org.springframework.test.context.TestContext.loadApplicationContext(TestContext.java:280)
        at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:304)
        ... 30 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loadTimeWeaver': Initialization o
f bean failed; nested exception is java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide
an 'addTransformer(ClassFileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's a
gent: -javaagent:org.springframework.instrument.jar
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFact
ory.java:527)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactor
y.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:197)
        at org.springframework.context.weaving.LoadTimeWeaverAwareProcessor.postProcessBeforeInitialization(LoadTimeWeaverAwareProce
ssor.java:95)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(
AbstractAutowireCapableBeanFactory.java:394)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFa
ctory.java:1448)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFact
ory.java:519)
        ... 42 more
Caused by: java.lang.IllegalStateException: ClassLoader [sun.misc.Launcher$AppClassLoader] does NOT provide an 'addTransformer(Class
FileTransformer)' method. Specify a custom LoadTimeWeaver or start your Java virtual machine with Spring's agent: -javaagent:org.spr
ingframework.instrument.jar
        at org.springframework.context.weaving.DefaultContextLoadTimeWeaver.setBeanClassLoader(DefaultContextLoadTimeWeaver.java:93)

        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBe
anFactory.java:1472)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFa
ctory.java:1443)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFact
ory.java:519)
        ... 51 more

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.767 sec <<< FAILURE!

Results :

Tests in error:
  search(greenpages.jpa.JpaDirectorySpringContextTests): Failed to load ApplicationContext

I am running Win7 with JDK1.7.0_25
Re: greenpages sample getting errors on junit test [message #1161682 is a reply to message #1161410] Tue, 29 October 2013 20:03 Go to previous messageGo to next message
Florian Waibel is currently offline Florian Waibel
Messages: 87
Registered: June 2010
Member
Hi,

thanks for giving the greenpages sample a try.

Could you please verify that you have

org.springframework.instrument-3.1.0.RELEASE.jar


in your local Maven repository? This is the javaagent configured in the greenpages.parent pom.xml.

<argLine>-javaagent:${user.home}/.m2/repository/org/springframework/org.springframework.instrument/3.1.0.RELEASE/org.springframework.instrument-3.1.0.RELEASE.jar</argLine>


Regards,
florian
Re: greenpages sample getting errors on junit test [message #1163200 is a reply to message #1161682] Wed, 30 October 2013 18:33 Go to previous messageGo to next message
Brent Jacox is currently offline Brent Jacox
Messages: 5
Registered: February 2013
Junior Member
The 3.0.0.RC1 release did not have the line:
<argLine>-javaagent:${user.home}/.m2/repository/org/springframework/org.springframework.instrument/3.1.0.RELEASE/org.springframework.instrument-3.1.0.RELEASE.jar</argLine>

in the greenpages.parent pom.xml. I had to look at a previous version 2.5 to understand what you meant. This is what it looks like from the 3.0.0.RC1
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>2.12</version>
	<configuration>
		<includes>
			<include>**/*Tests.java</include>
		</includes>
		<excludes>
			<exclude>**/Abstract*.java</exclude>
		</excludes>
	    <junitArtifactName>org.junit:com.springsource.org.junit</junitArtifactName>
	</configuration>
</plugin>


and this is what I changed it to:
<plugin>
	<groupId>org.apache.maven.plugins</groupId>
	<artifactId>maven-surefire-plugin</artifactId>
	<version>2.12</version>
	<configuration>
		<includes>
			<include>**/*Tests.java</include>
		</includes>
		<excludes>
			<exclude>**/Abstract*.java</exclude>
		</excludes>
		<junitArtifactName>org.junit:com.springsource.org.junit</junitArtifactName>
		<argLine>-javaagent:${user.home}/.m2/repository/org/springframework/org.springframework.instrument/3.1.0.RELEASE/org.springframework.instrument-3.1.0.RELEASE.jar</argLine>
	</configuration>
</plugin>

that seem to fix the original problem. But then I got a FileNotFoundException on the db.sql file. I found another post here that worked perfectly.

Thanks for your Help!
Re: greenpages sample getting errors on junit test [message #1165449 is a reply to message #1163200] Fri, 01 November 2013 05:37 Go to previous messageGo to next message
Florian Waibel is currently offline Florian Waibel
Messages: 87
Registered: June 2010
Member
Thanks for your feedback and looking into the problem in such a detail.

There is an updated version of the Greenpages sample available from Hudson[1] now. It can be found in the workspace at build-samples/target/artifacts/

Should be much easier to import the project into your IDE now, too.

Regards,
florian

[1] https://hudson.eclipse.org/hudson/view/Virgo/job/virgo.samples.snapshot/
Re: greenpages sample getting errors on junit test [message #1167347 is a reply to message #1165449] Sat, 02 November 2013 11:50 Go to previous message
Brent Jacox is currently offline Brent Jacox
Messages: 5
Registered: February 2013
Junior Member
I was able to use the link you supplied and create the project in eclipse. I noticed that the eclipse .project and .classpath were missing. I assume that is on purpose. The end result was I was able to use it with STS 3.4.0 where as before I was only able to get it running on STS 2.9.1.

Thanks for all your help! Next step is to get Hibernate and Tiles integrated.
Previous Topic:Java EE 6 Web Profile
Next Topic:KernelBundleClassLoader - Wiring problem?
Goto Forum:
  


Current Time: Thu Apr 24 11:18:25 EDT 2014

Powered by FUDForum. Page generated in 0.02470 seconds