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:

      | +---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'>
       <schema targetNamespace='http://data.sample' xmlns='http://www.w3.org/2001/XMLSchema'>
       <import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
       <complexType name='BusinessRequest'>
       <element name='policyNumber' nillable='true' type='xsd:string'/>
       <complexType name='PaymentRequest'>
       <element name='account' nillable='true' type='xsd:string'/>
       <complexType name='Request'>
       <element name='businessRequest' nillable='true' type='tns2:BusinessRequest'/>
       <element name='paymentRequest' nillable='true' type='tns2:PaymentRequest'/>
       <complexType name='BusinessResponse'>
       <complexType name='PaymentResponse'>
       <element name='transactionID' nillable='true' type='xsd:string'/>
       <complexType name='Response'>
       <element name='businessResponse' nillable='true' type='tns2:BusinessResponse'/>
       <element name='paymentResponse' nillable='true' type='tns2:PaymentResponse'/>
       <wsdl:message name='testRequest'>
       <wsdl:part name='request' type='tns2:Request'/>
       <wsdl:message name='testResponse'>
       <wsdl:part name='testReturn' type='tns2:Response'/>
       <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: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:output name='testResponse'>
       <wsdlsoap:body encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' namespace='http://sample' use='encoded'/>
       <wsdl:service name='SampleLocalService'>
       <wsdl:port binding='impl:SampleLocalSoapBinding' name='SamplePort'>
       <wsdlsoap:address location='http://CAHAL-BROWNJ61:8080/SampleEJB/Enterprise1Service'/>

      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[]:
          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
          LoginModule Class: org.jboss.security.ClientLoginModule
          ControlFlag: LoginModuleControlFlag: required
          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">
           <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 code="org.jboss.security.ClientLoginModule" flag="required" />

          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


            • 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