Announcement Announcement Module
Collapse
No announcement yet.
EJB3 XML injection configuration seems to work but get NullPointerException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • EJB3 XML injection configuration seems to work but get NullPointerException

    I'm trying to get an EJB3 injected into a Spring managed bean, i'm simply using a
    Code:
    <jee:jndi-lookup>
    , i also get the same result using,
    Code:
    <bean id = "usuario" class = "org.springframework.jndi.JndiObjectFactoryBean">
    , i'll post the dispatcher-servlet.xml shortly.

    I used the
    Code:
    value = "java:comp/env/+JNDIName
    , the
    Code:
    <property name="resourceRef" value="true" />
    , and the <jee:jndi-lookup resource-ref="true"> all three yielding NameNotFound JNDI exceptions, this was solved using just the JNDI name as is.

    So everything seems to work, and the injection is supposed to be happening, and then when the application tries to use the injected been i get a NullPointerException, which makes me think... there nothing being injected.

    Here I post the whole -servlet.xml code, and the NullPointerException, although it looks just as a plain old fashion NullPointerException to me.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:p="http://www.springframework.org/schema/p"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:jee="http://www.springframework.org/schema/jee"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
           http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
           http://www.springframework.org/schema/jee
           http://www.springframework.org/schema/jee/spring-jee-2.0.xsd">
               
        <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
            
        </bean>
        
        <bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
            <property name="mappings">
                <props>
                    <prop key="/index.htm">indexController</prop>
                </props>
            </property>
        </bean>
        
        <bean id="viewNameTranslator"
              class="org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator">
        </bean>
        
        <bean id="viewResolver"
              class="org.springframework.web.servlet.view.InternalResourceViewResolver"
              p:prefix="/WEB-INF/jsp/"
              p:suffix=".jsp">
        </bean>
        
        <!-- 
        for the majority of the controllers use the new ControllerClassNameHandlerMapping 
        above, but because the class used is the ParameterizableViewController we
        are specifying a bean name to define the mapping as /index.htm
        -->
        <bean name="indexController"
              class="org.springframework.web.servlet.mvc.ParameterizableViewController"
              p:viewName="index">
        </bean>
        
        <!--<bean id = "usuario"                  
              class = "org.springframework.jndi.JndiObjectFactoryBean"> 
            <property name = "jndiName"  
                      value = "ProyectoArquiTPS/UsuarioSFacade/remote"/>
        </bean>-->
        
        <!--<bean id="usuario" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="ProyectoArquiTPS/UsuarioSFacade/remote" />
            <property name="expectedType" value="sessionfacades.usuario.UsuarioSFacadeRemote" />
        </bean>-->
        <jee:jndi-lookup id="usuario" jndi-name="ProyectoArquiTPS/UsuarioSFacade/remote"
            resource-ref="false" />
        
        <bean id = "DelMailAutenticacion"
              class = "com.delegates.usuario.DelMailAutenticacion">
                  <property name = "usuario" ref = "usuario"/>   
        </bean>
    </beans>
    Code:
    ERROR [STDERR] 21/04/2008 10:40:40 PM javax.faces.event.MethodExpressionActionListener processAction
    GRAVE: Received 'java.lang.NullPointerException' when invoking action listener '#{LoginCommand.processAction}' for component 'j_id_jsp_1826821804_5'
    2008-04-21 22:40:40,718 ERROR [STDERR] 21/04/2008 10:40:40 PM javax.faces.event.MethodExpressionActionListener processAction
    GRAVE: java.lang.NullPointerException
    	at com.delegates.usuario.DelMailAutenticacion.login(DelMailAutenticacion.java:66)
    	at com.command.usuario.LoginCommand.processAction(LoginCommand.java:34)
    	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.apache.el.parser.AstValue.invoke(AstValue.java:131)
    	at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
    	at org.apache.jasper.el.JspMethodExpression.invoke(JspMethodExpression.java:68)
    	at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:88)
    	at javax.faces.event.ActionEvent.processListener(ActionEvent.java:77)
    	at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:746)
    	at javax.faces.component.UICommand.broadcast(UICommand.java:368)
    	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:447)
    	at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:752)
    	at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
    	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
    	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
    	at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
    	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    	at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
    	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
    	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
    	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
    	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
    	at java.lang.Thread.run(Thread.java:619)

    Anyone out there has a clue about what's happening?? THNX in advance!

    .:Wolfs:.

    EDIT: Forgot to mention: i'm using Jboss 4.2.2
    Last edited by WolfEng; Apr 22nd, 2008, 12:09 AM. Reason: Forgot to mention the app server i'm running the application on

  • #2
    Is the 'DelMailAutenticacion' in your LoginCommand the same as the one defined in your applicationContext or are you creating a new one?!

    Comment


    • #3
      hehehe

      Jeebus, you've got a sharp eye, intuition... or sumthing, tho i'm ashamed of it , i'm also very thankfull for your wise words, you were right that was all what was missing. Since the application was previously pure EJB3, the DelMailAutenticacion object was still being initialized thru a faces context lookup. hehehe. Ohh well i really thank you for the early response.

      Have a great day man!!

      Cheers!

      .:Wolfs:.

      Comment

      Working...
      X