3 Replies Latest reply on Feb 20, 2011 12:45 AM by Sam W

    Could not dereference object

    Sam W Expert

      Hello,

       

      I have deployed a web service in Jboss 6.0. It shown that the service is deployed successfully:

      Registered Service Endpoints

      Endpoint Namejboss.ws:context=HousewareEnterpriseApplication1-ejb,endpoint=RoleWS
      Endpoint Addresshttp://localhost:8080/HousewareEnterpriseApplication1-ejb/RoleWS/RoleWS
      StartTimeStopTime
      Sun Feb 20 11:15:13 EST 2011

      RequestCountResponseCountFaultCount
      202
      MinProcessingTimeMaxProcessingTimeAvgProcessingTime
      22608315

       

      With my web service client, when I open its jsf page at:

      http://localhost:8080/HousewareEnterpriseApplicationClient-war/faces/role_admin.xhtml

       

      it throws the following exception:

       

      11:22:15,044 WARN  [org.apache.cxf.phase.PhaseInterceptorChain] Application {http://ws.houseware.com.au/}RoleWS#{http://ws.houseware.com.au/}findAll has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: org.jboss.injection.manager.spi.InjectionException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: RoleFacade not bound]]

       

      I have attached my client codes in the following section for reference.

       

      RoleManager.java:

       

      @Stateless

      @LocalBean

      public class RoleManager {

          @WebServiceRef(wsdlLocation = "META-INF/wsdl/localhost_8080/HousewareEnterpriseApplication1-ejb/RoleWS/RoleWS.wsdl")

          private RoleWS_Service service;

       

          public java.util.List<au.com.houseware.wsdl.generated.Role> findAll() {

              au.com.houseware.wsdl.generated.RoleWS port = service.getRoleWSPort();

              return port.findAll();

          }

       

      RoleController.java:

       

      @ManagedBean(name="role")

      @SessionScoped

      public class RoleController

      {

          @EJB

          private RoleManager roleManager;

          private Role role;

          private final static Logger logger = Logger.getLogger(RoleController.class.getName());

          private ArrayList<Role> roleList;

       

           public ArrayList<Role> getRoles()

           {

              if (roleList == null) {

                  List<Role> retList = roleManager.findAll();

                  roleList = new ArrayList<Role>();

                  for (Role cust : retList) {

                      roleList.add((Role) cust);

                  }

       

              }

              return roleList;

       

          }

       

      RoleFacade.java:

       

      @Stateless

      public class RoleFacade extends AbstractFacade<Role> {

          @PersistenceContext(unitName = "HousewareEnterpriseApplication1-ejbPU")

          private EntityManager em;

          @Resource

          private javax.transaction.UserTransaction utx;

       

          protected EntityManager getEntityManager() {

              return em;

          }

       

          public RoleFacade() {

              super(Role.class);

          }

       

          public void createRoleFromName(String name) {

              Role role = new Role();

              role.setRoleId(RandomNumberUtil.tinyId());

              role.setRoleName(name);

              super.create(role);

          }

      }

       

       

      Very appreciate for any suggestion and help to resolve this error.

       

      Thanks

      Sam

        • 1. Could not dereference object
          Sam W Expert

          Further investigate the cause of the error, I found that the error is not caused by invoking the findAll() remote call.

          Here is my test:

          In my xhtml file, I removed all codes that make calls to the bean, - making the xhtml file like an empty file except for its headers (xlmns tags).

          Executed this strip-down xhtml page, jboss thrown a similar exception:

           

          15:29:54,046 ERROR [org.jboss.webservices.integration.invocation.InvocationHandlerEJB3] Method invocation failed with exception: org.jboss.injection.manager.spi.InjectionException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: RoleFacade not bound]]: javax.ejb.EJBException: org.jboss.injection.manager.spi.InjectionException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: RoleFacade not bound]]

           

          I might have missing some configuration of RoleFacade in my project setup. RoleFacade is a session bean which provides web service to the Client code. But I wouldn't know what I have missing

           

          Thanks

          Sam

          • 2. Could not dereference object
            Sam W Expert

            Here is more info about my jboss xml files.

             

            jboss-web.xml:

             

            <?xml version="1.0" encoding="UTF-8"?>

            <jboss-web>

              <context-root>/HousewareEnterpriseApplicationClient-war</context-root>

            </jboss-web>

             

             

            beans.xml:

             

            <?xml version="1.0" encoding="UTF-8"?>

            <beans xmlns="http://java.sun.com/xml/ns/javaee"

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">

            </beans>

             

            web.xml:

             

            <?xml version="1.0" encoding="UTF-8"?>

            <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

                <context-param>

                    <param-name>javax.faces.PROJECT_STAGE</param-name>

                    <param-value>Development</param-value>

                </context-param>

                <servlet>

                    <servlet-name>Faces Servlet</servlet-name>

                    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                    <load-on-startup>1</load-on-startup>

                </servlet>

                <servlet-mapping>

                    <servlet-name>Faces Servlet</servlet-name>

                    <url-pattern>/faces/*</url-pattern>

                </servlet-mapping>

                <session-config>

                    <session-timeout>

                        30

                    </session-timeout>

                </session-config>

                <welcome-file-list>

                    <welcome-file>faces/index.xhtml</welcome-file>

                </welcome-file-list>

            </web-app>

             

            I dont' know what else I should check against with.

             

            Thanks

            Sam

            • 3. Could not dereference object
              Sam W Expert

              Hello,

               

              I found the offending line in my client code:

               

              Caused by: javax.xml.ws.soap.SOAPFaultException: org.jboss.injection.manager.spi.InjectionException: javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NamingException: Could not dereference object [Root exception is javax.naming.NameNotFoundException: RoleFacade not bound]]

                      at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:146) [:2.3.1]

                      at $Proxy322.findAll(Unknown Source)    at au.com.houseware.c.ejb.bean.RoleManager.findAll(RoleManager.java:48) [:]

                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_11]

                      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_11]

                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_11]

                      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_11]

               

              Here is the line of code in RoleManager.java

               

              public java.util.List<au.com.houseware.wsdl.generated.Role> findAll() {

                      au.com.houseware.wsdl.generated.RoleWS port = service.getRoleWSPort();

                      return port.findAll(); <== root cause of the exception.

                  }

               

              RoleWS is a wsdl generated interface class, which is shown below:

               

              @WebService(name = "RoleWS", targetNamespace = "http://ws.houseware.com.au/")

              @XmlSeeAlso({

                  ObjectFactory.class

              })

              public interface RoleWS {

               

              @WebMethod

                  @WebResult(targetNamespace = "")

                  @RequestWrapper(localName = "findAll", targetNamespace = "http://ws.houseware.com.au/", className = "au.com.houseware.wsdl.generated.FindAll")

                  @ResponseWrapper(localName = "findAllResponse", targetNamespace = "http://ws.houseware.com.au/", className = "au.com.houseware.wsdl.generated.FindAllResponse")

                  public List<Role> findAll();

               

              Am I missing the implementation class of RoleWS?

               

              Thanks

              Sam