2 Replies Latest reply on May 2, 2010 12:38 AM by mehdi zarei

    Web Services class not known in context

    Tim Eakins Newbie

      This is probably a simple one, but I'm stuck.  I call a new Web Service, queryByObject, which could return several different objects.

       

      I have the below test case to return a User object.  If I change the method signature to return a User, it works.  If I leave it as an Object, I get 'javax.xml.bind.JAXBException: class pfcommon.data.User nor any of its super class is known to this context.'  Even with the XmlSeeAlso, it just won't add User into the schema.

       

      Any help really appreciated!  I put in all the components that I felt were relevant.  JBoss 5.1.0.

       

      Also, if there's anything else wrong in my style, happy to take comments, this is my first attempt at expanding my working EJBs to also be Web Services.

       

      Thanks,
      Tim

       


      //Interface

       

      @WebService
      @SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
      @XmlSeeAlso({pfcommon.data.User.class})
      public interface TestConnectionInterface {
      ...
          /**
           * Select back one value
           */
          @WebMethod
          public Object queryForObject(String queryName, HashMap<String, Object> criteria);
      ...
      }

       

      //Remote

       

      @Remote
      public interface TestConnectionInterfaceRemote extends TestConnectionInterface { }

       

      //Implementation

       

      @Stateless
      @WebService(endpointInterface="pfcommon.ejb.library.connect.TestConnectionInterface")
      @XmlSeeAlso({pfcommon.data.User.class})
      public class TestConnection implements TestConnectionInterfaceRemote, TestConnectionInterfaceLocal, TestConnectionInterface {
      ...
          @Override
          public Object queryForObject(String queryName, HashMap<String, Object> criteria) {
              l.info("queryName=" + queryName);

       

              //Simplified sample of something that could happen here
              User ret = new User();

       

              l.info("queryForObject ret="+ret);
              return ret;
          }
      ...
      }

       

      //Client

       

          public void testWebServiceTestConnectionQuery() throws Exception {
              boolean successfulTest = true;

       

              String endpointURI = "http://192.168.1.7:8080/PersonalFinancier-PersonalFinancier/TestConnection?wsdl";

       

              try {
                  URL wsdlURL = new URL(endpointURI);
                  QName serviceName = new QName("http://connect.ejb.pf/", "TestConnectionService");

       

                  Service service = Service.create(wsdlURL, serviceName);
                  TestConnectionInterface tc = service.getPort(TestConnectionInterface.class);
                  assertNotNull(tc);

       

                  HashMap<String, Object> filterCriteria = new HashMap<String, Object>();
                  filterCriteria.put("username", "bob");

       

                  l.info("Attempting to call dummy queryForObject method");
                  User ret = (User) tc.queryForObject(PFConsts.SELECT_USER_BY_ACTIVE, filterCriteria);
                  l.info("User = ["+ret+"]");
              } catch (Exception e) {
                  e.printStackTrace();
                  successfulTest = false;
              }
              assertTrue(successfulTest);
          }

       


      http://192.168.1.7:8080/jbossws/services

       

      Registered Service Endpoints
      Endpoint Name     jboss.ws:context=PersonalFinancier-PersonalFinancier,endpoint=TestConnection
      Endpoint Address     http://192.168.1.7:8080/PersonalFinancier-PersonalFinancier/TestConnection?wsdl
         
      http://192.168.1.7:8080/PersonalFinancier-PersonalFinancier/TestConnection?wsdl

       

      <definitions name="TestConnectionService" targetNamespace="http://connect.ejb.pf/">
        <import location="http://192.168.1.7:8080/PersonalFinancier-PersonalFinancier/TestConnection?wsdl&resource=TestConnectionInterface_PortType2174988315873883329.wsdl" namespace="http://connect.library.ejb.pfcommon/"/>

       

        <service name="TestConnectionService">

       

          <port binding="ns1:TestConnectionInterfaceBinding" name="TestConnectionPort">
            <soap:address location="http://192.168.1.7:8080/PersonalFinancier-PersonalFinancier/TestConnection"/>
          </port>
        </service>
      </definitions>

       

      //Server Exception

       

      ...
      00:40:14,236 INFO  [EJB3EndpointDeployer] Deploy AbstractBeanMetaData@33435a77{name=jboss.j2ee:ear=PersonalFinancier.ear,jar=PersonalFinancier.jar,name=TestConnection,service=EJB3_endpoint bean=org.jboss.ejb3.endpoint.deployers.impl.EndpointImpl properties=[container] constructor=null autowireCandidate=true}
      00:40:14,329 INFO  [SessionSpecContainer] Starting jboss.j2ee:ear=PersonalFinancier.ear,jar=PersonalFinancier.jar,name=TestConnection,service=EJB3
      00:40:14,329 INFO  [EJBContainer] STARTED EJB: pf.ejb.connect.TestConnection ejbName: TestConnection
      00:40:14,365 INFO  [JndiSessionRegistrarBase] Binding the following Entries in Global JNDI:

       

              PersonalFinancier/TestConnection/remote - EJB3.x Default Remote Business Interface
              PersonalFinancier/TestConnection/remote-pfcommon.ejb.library.connect.TestConnectionInterfaceRemote - EJB3.x Remote Business Interface
              PersonalFinancier/TestConnection/local - EJB3.x Default Local Business Interface
              PersonalFinancier/TestConnection/local-pfcommon.ejb.library.connect.TestConnectionInterfaceLocal - EJB3.x Local Business Interface

       

      ...
      00:40:14,670 INFO  [DefaultEndpointRegistry] register: jboss.ws:context=PersonalFinancier-PersonalFinancier,endpoint=TestConnection
      00:40:16,225 INFO  [WSDLFilePublisher] WSDL published to: file:/usr/java/jboss-5.1.0.GA-dev/server/pfdev/data/wsdl/PersonalFinancier.ear/PersonalFinancier.jar/TestConnectionService1705653235957235278.wsdl
      ...
      00:40:20,905 WARN  [StatelessBeanContext] EJBTHREE-1337: do not get WebServiceContext property from stateless bean context, it should already have been injected
      00:40:20,905 INFO  [STDOUT] Parameter constructor!
      00:40:20,905 INFO  [TestConnection] Successful basic connection.  Now returning value [id=null fieldValue=Remote Simple Test].
      00:40:20,905 WARN  [StatelessBeanContext] EJBTHREE-1337: do not get WebServiceContext property from stateless bean context, it should already have been injected
      00:40:26,754 WARN  [StatelessBeanContext] EJBTHREE-1337: do not get WebServiceContext property from stateless bean context, it should already have been injected
      00:40:26,755 INFO  [TestConnection] queryName=selectUserByActive
      00:40:26,770 INFO  [TestConnection] queryForObject ret=
      00:40:26,770 WARN  [StatelessBeanContext] EJBTHREE-1337: do not get WebServiceContext property from stateless bean context, it should already have been injected
      00:40:26,776 ERROR [RequestHandlerImpl] Error processing web service request
      org.jboss.ws.WSException: javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
      - with linked exception:
      [javax.xml.bind.JAXBException: class pfcommon.data.User nor any of its super class is known to this context.]
              at org.jboss.ws.WSException.rethrow(WSException.java:68)
              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:336)
              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:205)
              at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:131)
              at org.jboss.wsf.common.servlet.AbstractEndpointServlet.service(AbstractEndpointServlet.java:85)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
              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:235)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
              at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
              ...

       

      Thanks again!

        • 1. Re: Web Services class not known in context
          mehdi zarei Newbie

          He Friends,

           

          I have the exact same problem. Unfortunately I haven't found any solution for that since the last 5 months. All of my application problems and issues have been solved but this problem is something like a tumor that have existed in every release just for one webservice. others work perfectly.

           

          I use webservice annotations on my ejb classes. It get error "[javax.xml.bind.JAXBException: class [myclass] nor any of its super class is known to this context.]" when  reaches to a method that returns a class that "myclass" is one of its members. I used "XmlSeeAlso{(myclass.class)}" on top of SIE class, Return type DTO class and every other place that I tought maybe help to solve. But all of them were unsuccessful and I have this problem yet.

           

          I am really appreciate that if anybody suggest any any any idea about that.

           

          I use jboss 5.1.0 ga(jdk6), JDK 1.6.0_17. windows 2003 server

           

          Best Regards,

          Mehdi.

          • 2. Re: Web Services class not known in context
            mehdi zarei Newbie

            I found my problem. My relflectors didn't reflect some enitity classes to DTO and my webservices just use DTO classes.