Solved. Had to add:
<property name="countryManager" ref="countryManager" />
to my controller bean definition.
Cheers,
Greg
gederer wrote:
>
> Hi,
>
> In my applicationContext-service.xml, I have:
>
>
> <bean id="countryManager"
> class="com.firstworldtoys.service.impl.GenericManagerImpl">
> <constructor-arg>
> <bean
> class="com.firstworldtoys.dao.hibernate.GenericDaoHibernate"
> autowire="byType">
> <constructor-arg value="com.firstworldtoys.model.Country"/>
> </bean>
> </constructor-arg>
> </bean>
>
> In my Controller, I have:
>
> private GenericManager<Country, Long> countryManager = null;
>
> public GenericManager<Country, Long> getCountryManager()
> {
> return countryManager;
> }
>
> public void setCountryManager(GenericManager<Country, Long>
> countryManager)
> {
> this.countryManager = countryManager;
> }
>
> public Map referenceData(HttpServletRequest request)
> {
> Map map = new HashMap();
>
> map.put("countries", countryManager.getAll());
>
> return map;
> }
>
> When I run my test (or try to load the page that uses this controler), I
> get:
>
> -------------------------------------------------------------------------------
> Test set:
> com.firstworldtoys.webapp.controller.ToyProviderSignupControllerTest
> -------------------------------------------------------------------------------
> Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 4.216 sec
> <<< FAILURE!
> testDisplayForm(com.firstworldtoys.webapp.controller.ToyProviderSignupControllerTest)
>
> Time elapsed: 3.746 sec <<< ERROR!
> java.lang.NullPointerException
> at
> com.firstworldtoys.webapp.controller.ToyProviderSignupController.referenceData(ToyProviderSignupController.java:76)
> at
> org.springframework.web.servlet.mvc.SimpleFormController.referenceData(SimpleFormController.java:214)
> at
> org.springframework.web.servlet.mvc.AbstractFormController.showForm(AbstractFormController.java:559)
> at
> org.springframework.web.servlet.mvc.SimpleFormController.showForm(SimpleFormController.java:198)
> at
> org.springframework.web.servlet.mvc.SimpleFormController.showForm(SimpleFormController.java:175)
> at
> org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:323)
> at
> org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:263)
> at
> org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
> at
> com.firstworldtoys.webapp.controller.ToyProviderSignupControllerTest.testDisplayForm(ToyProviderSignupControllerTest.java:28)
> 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:585)
> at junit.framework.TestCase.runTest(TestCase.java:168)
> at junit.framework.TestCase.runBare(TestCase.java:134)
> at
> org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
> at junit.framework.TestResult$1.protect(TestResult.java:110)
> at junit.framework.TestResult.runProtected(TestResult.java:128)
> at junit.framework.TestResult.run(TestResult.java:113)
> at junit.framework.TestCase.run(TestCase.java:124)
> at junit.framework.TestSuite.runTest(TestSuite.java:232)
> at junit.framework.TestSuite.run(TestSuite.java:227)
> at
> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
> at
> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
> at
> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
> at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
> 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:585)
> at
> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
> at
> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
>
> What am I doing wrong?
>
> Thanks!
>
--
View this message in context:
http://www.nabble.com/GenericManager-not-injected-tf4417249s2369.html#a12619809
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]