nullpointerexception - Spring managed object always null. wicket framework -


today have had infuriating problem follows:

i have wicket based application using spring manage objects connecting application database, in past has worked fine me.

i using inbuilt jetty server in eclipse run application , note when put breakpoint in datasource method in class populating, @ startup setter seems called , datasource object has data want.

however when go use object spring has injected values it's datasource object comes null object.

a code snippet follows:

declaring class be managed spring:

public class homepage extends webpage {  @springbean(name = "userimpl") private userimpl userimp;  /**  *   */ 

where calling object:

    protected void onsubmit() {             super.onsubmit();              try {                 person returneduser = userimp.finduser(model.getusername(),                         model.getpassword());                 setresponsepage(studentpage.class);                 returneduser.getemail();             } catch (exception e) { 

my application context file:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xmlns:context="http://www.springframework.org/schema/context" xsi:schemalocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">  <!-- datasource (parameterized configuration via propertyplaceholderconfigurer) --> <bean id="datasource" destroy-method="close"     class="org.apache.commons.dbcp.basicdatasource">     <property name="driverclassname" value="com.mysql.jdbc.driver" />     <property name="url" value="jdbc:mysql://localhost:3306" />     <property name="username" value="root" />     <property name="password" value="admin" /> </bean>  <bean id="userimp" class="com.bascombe.persistance.userimpl">     <property name="datasource" ref="datasource" /> </bean> 

my web.xml:

<?xml version="1.0" encoding="iso-8859-1"?> 

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<display-name>finalyearproject</display-name>  <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>classpath:applicationcontext.xml</param-value> </context-param>  <filter>     <filter-name>wicket.finalyearproject</filter-name>     <filter-class>org.apache.wicket.protocol.http.wicketfilter</filter-class>     <init-param>         <param-name>applicationclassname</param-name>         <param-value>com.bascombe.pages.wicketapplication</param-value>     </init-param> </filter>  <filter>     <filter-name>springrequestcontextfilter</filter-name>     <filter-class>org.springframework.web.filter.requestcontextfilter</filter-class> </filter> <filter-mapping>     <filter-name>wicket.finalyearproject</filter-name>     <url-pattern>/*</url-pattern> </filter-mapping>  <listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class> </listener> 

the result on submit of form null pointer exception follows:

java.lang.nullpointerexception @ com.bascombe.pages.homepage$1.onsubmit(homepage.java:37) @ org.apache.wicket.markup.html.form.form$9.component(form.java:1246) @ org.apache.wicket.markup.html.form.form$9.component(form.java:1240) @ org.apache.wicket.util.visit.visits.visitpostorderhelper(visits.java:274) @ org.apache.wicket.util.visit.visits.visitpostorder(visits.java:245) @ org.apache.wicket.markup.html.form.form.delegatesubmit(form.java:1239) @ org.apache.wicket.markup.html.form.form.process(form.java:921) @ org.apache.wicket.markup.html.form.form.onformsubmitted(form.java:767) @ org.apache.wicket.markup.html.form.form.onformsubmitted(form.java:700) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.apache.wicket.requestlistenerinterface.internalinvoke(requestlistenerinterface.java:258) @ org.apache.wicket.requestlistenerinterface.invoke(requestlistenerinterface.java:216) @ org.apache.wicket.core.request.handler.listenerinterfacerequesthandler.invokelistener(listenerinterfacerequesthandler.java:240) @ org.apache.wicket.core.request.handler.listenerinterfacerequesthandler.respond(listenerinterfacerequesthandler.java:226) @ org.apache.wicket.request.cycle.requestcycle$handlerexecutor.respond(requestcycle.java:840) @ org.apache.wicket.request.requesthandlerstack.execute(requesthandlerstack.java:64) @ org.apache.wicket.request.cycle.requestcycle.execute(requestcycle.java:254) @ org.apache.wicket.request.cycle.requestcycle.processrequest(requestcycle.java:211) @ org.apache.wicket.request.cycle.requestcycle.processrequestanddetach(requestcycle.java:282) @ org.apache.wicket.protocol.http.wicketfilter.processrequestcycle(wicketfilter.java:244) @ org.apache.wicket.protocol.http.wicketfilter.processrequest(wicketfilter.java:188) @ org.apache.wicket.protocol.http.wicketfilter.dofilter(wicketfilter.java:267) @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1332) @ org.eclipse.jetty.servlet.servlethandler.dohandle(servlethandler.java:477) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:119) @ org.eclipse.jetty.security.securityhandler.handle(securityhandler.java:524) @ org.eclipse.jetty.server.session.sessionhandler.dohandle(sessionhandler.java:227) @ org.eclipse.jetty.server.handler.contexthandler.dohandle(contexthandler.java:1031) @ org.eclipse.jetty.servlet.servlethandler.doscope(servlethandler.java:406) @ org.eclipse.jetty.server.session.sessionhandler.doscope(sessionhandler.java:186) @ org.eclipse.jetty.server.handler.contexthandler.doscope(contexthandler.java:965) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:117) @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:111) @ org.eclipse.jetty.server.server.handle(server.java:348) @ org.eclipse.jetty.server.abstracthttpconnection.handlerequest(abstracthttpconnection.java:452) @ org.eclipse.jetty.server.blockinghttpconnection.handlerequest(blockinghttpconnection.java:47) @ org.eclipse.jetty.server.abstracthttpconnection.content(abstracthttpconnection.java:894) @ org.eclipse.jetty.server.abstracthttpconnection$requesthandler.content(abstracthttpconnection.java:948) @ org.eclipse.jetty.http.httpparser.parsenext(httpparser.java:851) @ org.eclipse.jetty.http.httpparser.parseavailable(httpparser.java:235) @ org.eclipse.jetty.server.blockinghttpconnection.handle(blockinghttpconnection.java:66) @ org.eclipse.jetty.server.bio.socketconnector$connectorendpoint.run(socketconnector.java:254) @ org.eclipse.jetty.server.ssl.sslsocketconnector$sslconnectorendpoint.run(sslsocketconnector.java:665) @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:603) @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:538) @ java.lang.thread.run(unknown source) java.lang.nullpointerexception @ com.bascombe.pages.homepage$1.onsubmit(homepage.java:37) @ org.apache.wicket.markup.html.form.form$9.component(form.java:1246) @ org.apache.wicket.markup.html.form.form$9.component(form.java:1240) @ org.apache.wicket.util.visit.visits.visitpostorderhelper(visits.java:274) @ org.apache.wicket.util.visit.visits.visitpostorder(visits.java:245) @ org.apache.wicket.markup.html.form.form.delegatesubmit(form.java:1239) @ org.apache.wicket.markup.html.form.form.process(form.java:921) @ org.apache.wicket.markup.html.form.form.onformsubmitted(form.java:767) @ org.apache.wicket.markup.html.form.form.onformsubmitted(form.java:700) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.apache.wicket.requestlistenerinterface.internalinvoke(requestlistenerinterface.java:258) @ org.apache.wicket.requestlistenerinterface.invoke(requestlistenerinterface.java:216) @ org.apache.wicket.core.request.handler.listenerinterfacerequesthandler.invokelistener(listenerinterfacerequesthandler.java:240) @ org.apache.wicket.core.request.handler.listenerinterfacerequesthandler.respond(listenerinterfacerequesthandler.java:226) @ org.apache.wicket.request.cycle.requestcycle$handlerexecutor.respond(requestcycle.java:840) @ org.apache.wicket.request.requesthandlerstack.execute(requesthandlerstack.java:64) @ org.apache.wicket.request.cycle.requestcycle.execute(requestcycle.java:254) @ org.apache.wicket.request.cycle.requestcycle.processrequest(requestcycle.java:211) @ org.apache.wicket.request.cycle.requestcycle.processrequestanddetach(requestcycle.java:282) @ org.apache.wicket.protocol.http.wicketfilter.processrequestcycle(wicketfilter.java:244) @ org.apache.wicket.protocol.http.wicketfilter.processrequest(wicketfilter.java:188) @ org.apache.wicket.protocol.http.wicketfilter.dofilter(wicketfilter.java:267) @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1332) @ org.eclipse.jetty.servlet.servlethandler.dohandle(servlethandler.java:477) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:119) @ org.eclipse.jetty.security.securityhandler.handle(securityhandler.java:524) @ org.eclipse.jetty.server.session.sessionhandler.dohandle(sessionhandler.java:227) @ org.eclipse.jetty.server.handler.contexthandler.dohandle(contexthandler.java:1031) @ org.eclipse.jetty.servlet.servlethandler.doscope(servlethandler.java:406) @ org.eclipse.jetty.server.session.sessionhandler.doscope(sessionhandler.java:186) @ org.eclipse.jetty.server.handler.contexthandler.doscope(contexthandler.java:965) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:117) @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:111) @ org.eclipse.jetty.server.server.handle(server.java:348) @ org.eclipse.jetty.server.abstracthttpconnection.handlerequest(abstracthttpconnection.java:452) @ org.eclipse.jetty.server.blockinghttpconnection.handlerequest(blockinghttpconnection.java:47) @ org.eclipse.jetty.server.abstracthttpconnection.content(abstracthttpconnection.java:894) @ org.eclipse.jetty.server.abstracthttpconnection$requesthandler.content(abstracthttpconnection.java:948) @ org.eclipse.jetty.http.httpparser.parsenext(httpparser.java:851) @ org.eclipse.jetty.http.httpparser.parseavailable(httpparser.java:235) @ org.eclipse.jetty.server.blockinghttpconnection.handle(blockinghttpconnection.java:66) @ org.eclipse.jetty.server.bio.socketconnector$connectorendpoint.run(socketconnector.java:254) @ org.eclipse.jetty.server.ssl.sslsocketconnector$sslconnectorendpoint.run(sslsocketconnector.java:665) @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:603) @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:538) @ java.lang.thread.run(unknown source) java.lang.nullpointerexception @ com.bascombe.pages.homepage$1.onsubmit(homepage.java:37) @ org.apache.wicket.markup.html.form.form$9.component(form.java:1246) @ org.apache.wicket.markup.html.form.form$9.component(form.java:1240) @ org.apache.wicket.util.visit.visits.visitpostorderhelper(visits.java:274) @ org.apache.wicket.util.visit.visits.visitpostorder(visits.java:245) @ org.apache.wicket.markup.html.form.form.delegatesubmit(form.java:1239) @ org.apache.wicket.markup.html.form.form.process(form.java:921) @ org.apache.wicket.markup.html.form.form.onformsubmitted(form.java:767) @ org.apache.wicket.markup.html.form.form.onformsubmitted(form.java:700) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) @ sun.reflect.nativemethodaccessorimpl.invoke(unknown source) @ sun.reflect.delegatingmethodaccessorimpl.invoke(unknown source) @ java.lang.reflect.method.invoke(unknown source) @ org.apache.wicket.requestlistenerinterface.internalinvoke(requestlistenerinterface.java:258) @ org.apache.wicket.requestlistenerinterface.invoke(requestlistenerinterface.java:216) @ org.apache.wicket.core.request.handler.listenerinterfacerequesthandler.invokelistener(listenerinterfacerequesthandler.java:240) @ org.apache.wicket.core.request.handler.listenerinterfacerequesthandler.respond(listenerinterfacerequesthandler.java:226) @ org.apache.wicket.request.cycle.requestcycle$handlerexecutor.respond(requestcycle.java:840) @ org.apache.wicket.request.requesthandlerstack.execute(requesthandlerstack.java:64) @ org.apache.wicket.request.cycle.requestcycle.execute(requestcycle.java:254) @ org.apache.wicket.request.cycle.requestcycle.processrequest(requestcycle.java:211) @ org.apache.wicket.request.cycle.requestcycle.processrequestanddetach(requestcycle.java:282) @ org.apache.wicket.protocol.http.wicketfilter.processrequestcycle(wicketfilter.java:244) @ org.apache.wicket.protocol.http.wicketfilter.processrequest(wicketfilter.java:188) @ org.apache.wicket.protocol.http.wicketfilter.dofilter(wicketfilter.java:267) @ org.eclipse.jetty.servlet.servlethandler$cachedchain.dofilter(servlethandler.java:1332) @ org.eclipse.jetty.servlet.servlethandler.dohandle(servlethandler.java:477) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:119) @ org.eclipse.jetty.security.securityhandler.handle(securityhandler.java:524) @ org.eclipse.jetty.server.session.sessionhandler.dohandle(sessionhandler.java:227) @ org.eclipse.jetty.server.handler.contexthandler.dohandle(contexthandler.java:1031) @ org.eclipse.jetty.servlet.servlethandler.doscope(servlethandler.java:406) @ org.eclipse.jetty.server.session.sessionhandler.doscope(sessionhandler.java:186) @ org.eclipse.jetty.server.handler.contexthandler.doscope(contexthandler.java:965) @ org.eclipse.jetty.server.handler.scopedhandler.handle(scopedhandler.java:117) @ org.eclipse.jetty.server.handler.handlerwrapper.handle(handlerwrapper.java:111) @ org.eclipse.jetty.server.server.handle(server.java:348) @ org.eclipse.jetty.server.abstracthttpconnection.handlerequest(abstracthttpconnection.java:452) @ org.eclipse.jetty.server.blockinghttpconnection.handlerequest(blockinghttpconnection.java:47) @ org.eclipse.jetty.server.abstracthttpconnection.content(abstracthttpconnection.java:894) @ org.eclipse.jetty.server.abstracthttpconnection$requesthandler.content(abstracthttpconnection.java:948) @ org.eclipse.jetty.http.httpparser.parsenext(httpparser.java:851) @ org.eclipse.jetty.http.httpparser.parseavailable(httpparser.java:235) @ org.eclipse.jetty.server.blockinghttpconnection.handle(blockinghttpconnection.java:66) @ org.eclipse.jetty.server.bio.socketconnector$connectorendpoint.run(socketconnector.java:254) @ org.eclipse.jetty.server.ssl.sslsocketconnector$sslconnectorendpoint.run(sslsocketconnector.java:665) @ org.eclipse.jetty.util.thread.queuedthreadpool.runjob(queuedthreadpool.java:603) @ org.eclipse.jetty.util.thread.queuedthreadpool$3.run(queuedthreadpool.java:538) @ java.lang.thread.run(unknown source) 

after debugging found object calling finduser on null.

any ideas?

if bean id "userimp" typo in question : have not actived annotation configuration annotation @springbean has no effect.

you must add application context :

<context:annotation-config/> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -