4 Replies Latest reply on May 1, 2006 7:06 AM by James Brown

    4.0.4.CR2 Namespace issue with Session EJB-based WS

    James Brown Newbie

      I have encountered an issue regarding namespaces with a web service based on a stateless sesssion bean. First, my environment:
      * JBoss 4.0.4 CR2
      * JBuilder 2006
      * Windows XP
      * JDK 1.5 update 6

      The issue is that it appears that all classes must reside in the same package/namespace; otherwise, exceptions such as the following occur:

      javax.xml.rpc.JAXRPCException: org.jboss.ws.binding.BindingException: javax.xml.bind.JAXBException: Failed to parse source: Failed to resolve class name for request: No ClassLoaders found for: sample.Request


      The problem is that Request resides in sample.data not sample as you can see from the following directory structure listing:

      +---src
      | +---sample
      | | | SampleBean.java
      | | | SampleLocal.java
      | | | SampleLocalHome.java
      | | | SampleWebService.java
      | | |
      | | \---data
      | | BusinessRequest.java
      | | BusinessResponse.java
      | | PaymentRequest.java
      | | PaymentResponse.java
      | | Request.java
      | | Response.java
      



      If collapsed to a single package/namespace, no errors are encountered.

      The classes in sample.data nothing more than shells - for example:
      package sample.data;
      
      public class BusinessRequest {
       private String policyNumber;
      
       public BusinessRequest() {
       policyNumber = null;
       }
      
       public BusinessRequest(String policyNumber) {
       this.policyNumber = policyNumber;
       }
       public String getPolicyNumber() {
       return policyNumber;
       }
      
       public void setPolicyNumber(String policyNumber) {
       this.policyNumber = policyNumber;
       }
      
      }
      


      The EJB is even simpler:
      package sample;
      
      import javax.ejb.SessionBean;
      import javax.ejb.SessionContext;
      import javax.ejb.CreateException;
      import sample.data.Response;
      import sample.data.Request;
      
      public class SampleBean implements SessionBean {
       SessionContext sessionContext;
       public void ejbCreate() throws CreateException {
       }
      
       public void ejbRemove() {
       }
      
       public void ejbActivate() {
       }
      
       public void ejbPassivate() {
       }
      
      
       public void setSessionContext(SessionContext sessionContext) {
       this.sessionContext = sessionContext;
       }
      
       public Response test(Request request) {
       // do nothing
       return new Response();
       }
      }
      



      And the WSDL looks correct as well:
      <wsdl:definitions targetNamespace='http://sample' xmlns:apachesoap='http://xml.apache.org/xml-soap' xmlns:impl='http://sample' xmlns:intf='http://sample' xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/' xmlns:tns2='http://data.sample' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns:wsdlsoap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
       <wsdl:types>
       <schema targetNamespace='http://data.sample' xmlns='http://www.w3.org/2001/XMLSchema'>
       <import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
       <complexType name='BusinessRequest'>
       <sequence>
       <element name='policyNumber' nillable='true' type='xsd:string'/>
       </sequence>
       </complexType>
       <complexType name='PaymentRequest'>
       <sequence>
       <element name='account' nillable='true' type='xsd:string'/>
       </sequence>
       </complexType>
       <complexType name='Request'>
       <sequence>
       <element name='businessRequest' nillable='true' type='tns2:BusinessRequest'/>
       <element name='paymentRequest' nillable='true' type='tns2:PaymentRequest'/>
       </sequence>
       </complexType>
       <complexType name='BusinessResponse'>
       <sequence/>
       </complexType>
       <complexType name='PaymentResponse'>
       <sequence>
       <element name='transactionID' nillable='true' type='xsd:string'/>
       </sequence>
       </complexType>
       <complexType name='Response'>
       <sequence>
       <element name='businessResponse' nillable='true' type='tns2:BusinessResponse'/>
       <element name='paymentResponse' nillable='true' type='tns2:PaymentResponse'/>
       </sequence>
       </complexType>
       </schema>
       </wsdl:types>
       <wsdl:message name='testRequest'>
       <wsdl:part name='request' type='tns2:Request'/>
       </wsdl:message>
       <wsdl:message name='testResponse'>
       <wsdl:part name='testReturn' type='tns2:Response'/>
       </wsdl:message>
       <wsdl:portType name='SampleLocal'>
       <wsdl:operation name='test' parameterOrder='request'>
       <wsdl:input message='impl:testRequest' name='testRequest'/>
       <wsdl:output message='impl:testResponse' name='testResponse'/>
       </wsdl:operation>
       </wsdl:portType>
       <wsdl:binding name='SampleLocalSoapBinding' type='impl:SampleLocal'>
       <wsdlsoap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
       <wsdl:operation name='test'>
       <wsdlsoap:operation soapAction=''/>
       <wsdl:input name='testRequest'>
       <wsdlsoap:body encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' namespace='http://sample' use='encoded'/>
       </wsdl:input>
       <wsdl:output name='testResponse'>
       <wsdlsoap:body encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' namespace='http://sample' use='encoded'/>
       </wsdl:output>
       </wsdl:operation>
       </wsdl:binding>
       <wsdl:service name='SampleLocalService'>
       <wsdl:port binding='impl:SampleLocalSoapBinding' name='SamplePort'>
       <wsdlsoap:address location='http://CAHAL-BROWNJ61:8080/SampleEJB/Enterprise1Service'/>
       </wsdl:port>
       </wsdl:service>
      </wsdl:definitions>
      


      What is causing this issue? I can rectify by collapsing all classes to once package/namespace; however, that seems like an architectural cop-out.

      -- James

        • 1. Re: 4.0.4.CR2 Namespace issue with Session EJB-based WS
          James Brown Newbie

          Ok. So I have taken the easy approach and collapsed all necessary classes to a single package - a little bit of an architectural cop-out, but I need to move things along.

          My next issue is surrounding security. I have enabled declarative security in the stateless session been which works when accessed from a standard web app; however when accessed via the web service, I receive the following:

          javax.security.auth.login.FailedLoginException: Password Incorrect/Password Required


          With trace level enabled on the jboss classes, I see that the username is not being picked up, thus the resulting password failure. The following is a listing of the trace output:

          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.login.XMLLoginConfigImpl] Begin getAppConfigurationEntry(dia-policy), size=10
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.login.XMLLoginConfigImpl] End getAppConfigurationEntry(dia-policy), authInfo=AppConfigurationEntry[]:
          [0]
          LoginModule Class: org.jboss.security.auth.spi.UsersRolesLoginModule
          ControlFlag: LoginModuleControlFlag: required
          Options:name=rolesProperties, value=props/jbossws-roles.properties
          name=usersProperties, value=props/jbossws-users.properties
          [1]
          LoginModule Class: org.jboss.security.ClientLoginModule
          ControlFlag: LoginModuleControlFlag: required
          Options:
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] initialize, instance=@30331536
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] findResource: null
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] Properties file=file:/C:/java/jboss-4.0.4.CR2/server/dias/conf/props/jbossws-users.properties, defaults=null
          2006-04-26 12:13:57,821 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Loaded properties, users=[jamesbr, kermit]
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] findResource: null
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] Properties file=file:/C:/java/jboss-4.0.4.CR2/server/dias/conf/props/jbossws-roles.properties, defaults=null
          2006-04-26 12:13:57,821 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Loaded properties, users=[jamesbr, kermit]
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] login
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] Authenticating as unauthenticatedIdentity=null
          2006-04-26 12:13:57,821 DEBUG [org.jboss.security.auth.spi.UsersRolesLoginModule] Bad password for username=null
          2006-04-26 12:13:57,821 TRACE [org.jboss.security.auth.spi.UsersRolesLoginModule] abort


          My login-config.xml entry is as follows (and works from a web app):
           <application-policy name="myapp-policy">
           <authentication>
          
           <login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule" flag="required">
           <module-option name="usersProperties">props/jbossws-users.properties</module-option>
           <module-option name="rolesProperties">props/jbossws-roles.properties</module-option>
           </login-module>
           <login-module code="org.jboss.security.ClientLoginModule" flag="required" />
           </authentication>
           </application-policy>
          


          Can anyone provide insight into why this is occuring?

          -- James

          • 2. Re: 4.0.4.CR2 Namespace issue with Session EJB-based WS
            Thomas Diesler Master

            Could you please verify the package/namespace issue with jbossws-1.0.0.GA.

            Also have a look at

            http://labs.jboss.com/portal/jbossws/user-guide/en/html/secure-ejb.html

            • 3. Re: 4.0.4.CR2 Namespace issue with Session EJB-based WS
              James Brown Newbie

              I have resolved the issue.

              It appears, in JBuilder, that I needed to add the classes (via the Extra Classes tab) that were not the explicit parameters to the operation, but were members of those classes. If these additional classes were not added, the wsdd file did not contain the necessary typeMapping entries. So it apears to be an issue with JBuilder.

              I have since reworked as a POJO web service since I needed to be able to grab information from the HTTP request that appears not to be available when enabling a service endpoint on an EJB.

              -- James

              • 4. Re: 4.0.4.CR2 Namespace issue with Session EJB-based WS
                James Brown Newbie

                Further, the issue regarding JAAS authentication appears to be related to the fact that I could not require authentication to the web service. Since moving to a POJO-based web service, deployed in its own war, I was able to successfully enable required security configuration in web.xml and jboss-web.xml.

                -- James