You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Michael Chandler <Mi...@onassignment.com> on 2013/07/25 18:52:38 UTC
JUnit Tests failing after config change
In order to support the use of the @SpringBean annotation, I've made some adjustments to my Wicket application that work beautifully right out of the gate. The documentation and assistance from this list helped get me up to speed and working quickly. HOWEVER, my JUnit tests are now failing when attempting to create my Wicket application bean, as follows:
Error creating bean with name 'wicketApplication' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
Since these tests aren't Wicket specific, I can comment out the bean definition in applicationContext.xml and the tests run flawlessly, but that's certainly not an acceptable fix. The error indicates that I'm missing some dependencies (I'm guessing) but as a Maven project with Eclipse properly configured, I would think I would bomb when running the app normally and not just when running tests.
Anyone have any ideas on what's going wrong here?
To sum up, here are the modifications I made to make use of @SpringBean
Included the following in web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>wicket.wicketFilter</filter-name>
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
<init-param>
<param-name>applicationFactoryClassName</param-name>
<param-value>org.apache.wicket.spring.SpringWebApplicationFactory</param-value>
</init-param>
</filter>
Referenced my primary WicketApplication class as a bean in applicationContext.xml:
<bean id="wicketApplication" class="com.oa.frontoffice.FrontOfficeApp" />
And in my WicketApplication, I included the following in my init() method:
getComponentInstantiationListeners().add(new SpringComponentInjector(this));
The results were great and I've been trucking along... but then I ran my unit tests and found that exception. Does anyone have any advice?
A more complete stack trace follows if it's helpful:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'wicketApplication' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.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:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.oa.frontoffice.service.BeanService.<init>(BeanService.java:9)
at com.oa.frontoffice.service.BeanService.getInstance(BeanService.java:17)
at com.oa.frontoffice.gateway.HotListGateway.<init>(HotListGateway.java:22)
at com.oa.frontoffice.gateway.TestHotListGatewayIntegration.setUp(TestHotListGatewayIntegration.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Thanks,
Mike
RE: JUnit Tests failing after config change
Posted by Michael Chandler <Mi...@onassignment.com>.
Oh man. That's exactly it. Obviously, when I'm not running in the Tomcat environment, I'm missing a few things.
Thanks for pointing that out Gabriel. I'm right back on track! Cheers!
Mike
-----Original Message-----
From: Gabriel Landon [mailto:glandon@piti.pf]
Sent: Thursday, July 25, 2013 11:08 AM
To: users@wicket.apache.org
Subject: Re: JUnit Tests failing after config change
Mike,
Maybe you could just add this in you pom.xml :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
Regards,
Gabriel.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/JUnit-Tests-failing-after-config-change-tp4660493p4660495.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: JUnit Tests failing after config change
Posted by Gabriel Landon <gl...@piti.pf>.
Mike,
Maybe you could just add this in you pom.xml :
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>test</scope>
</dependency>
Regards,
Gabriel.
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/JUnit-Tests-failing-after-config-change-tp4660493p4660495.html
Sent from the Users forum mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org