Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-187

WebService isn't called through ServiceFactory on jdk5

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • jboss-ws4ee-4.0.3
    • jboss-ws4ee-4.0.2
    • jbossws-native
    • None

      Web Service is as follows:

      ---------------
      LSEndpoint.java
      ---------------

      package com.plesk.ka.ejb.webservice;

      import com.plesk.ka.model.account.AccountInfo;

      public interface LSEndpoint extends java.rmi.Remote
      {
      AccountInfo getAccountInfo( int accountId ) throws java.rmi.RemoteException;
      }

      -----------
      LSBean.java
      -----------

      package com.plesk.ka.ejb.webservice;

      import com.plesk.ka.util.log.Log;
      import com.plesk.ka.ejb.account.AccountManagerRemoteHome;
      import com.plesk.ka.ejb.account.AccountManagerRemote;
      import com.plesk.ka.model.account.AccountInfo;

      import javax.naming.NamingException;
      import javax.naming.Context;

      import javax.ejb.EJBException;
      import javax.rmi.PortableRemoteObject;

      import java.rmi.RemoteException;

      public class LSBean implements javax.ejb.SessionBean, LSEndpoint
      {
      public Context jndiContext;

      public AccountInfo getAccountInfo( int accountId )
      {
      Log.debug( "LSBean.getAccountInfo" );

      try

      { Object ref = jndiContext.lookup( "AccountManager" ); AccountManagerRemoteHome home = (AccountManagerRemoteHome) PortableRemoteObject.narrow( ref, AccountManagerRemoteHome.class ); AccountManagerRemote remote = home.create(); AccountInfo accountInfo = remote.getAccount( accountId ); return accountInfo; }

      catch( Exception e )

      { e.printStackTrace(); throw new EJBException( e ); }

      }

      public void ejbCreate()
      {
      }

      public void ejbRemove()
      {
      }

      public void ejbActivate()
      {
      }

      public void ejbPassivate()
      {
      }

      public void setSessionContext( javax.ejb.SessionContext cntx )
      {
      try

      { jndiContext = new javax.naming.InitialContext(); }

      catch( NamingException ne )

      { throw new EJBException( ne ); }

      }

      }

      ----------------
      AccountInfo.java
      ----------------

      package com.plesk.ka.model.account;

      import com.plesk.ka.util.validation.Validator;

      import java.util.Date;

      public class AccountInfo implements java.io.Serializable, Cloneable
      {

      public final static long NO_ID = -1;
      public final static long ROOT_ID = 0;

      public final static String ADMIN = "Admin";
      public final static String RESELLER = "Reseller";
      public final static String CLIENT = "Client";

      private String id = "";
      private String resellerId = "";
      private String resellerName = "";
      private String role = "";
      private Boolean blocked = null;
      private Date creationDate = null;
      private Date modificationDate = null;
      private String name = "";
      private String company = "";
      private String email = "";

      public AccountInfo()
      {
      }

      public String getId()

      { return id; }

      public void setId( String id )

      { this.id = id; }

      public String getResellerId()

      { return resellerId; }

      public void setResellerId( String resellerId )

      { this.resellerId = resellerId; }

      public String getResellerName()

      { return resellerName; }

      public void setResellerName( String resellerName )

      { this.resellerName = resellerName; }

      public String getRole()

      { return role; }

      public void setRole( String role )

      { this.role = role; }

      public boolean isBlocked()

      { return blocked.booleanValue(); }

      public Boolean getBlocked()

      { return blocked; }

      public void setBlocked( boolean blocked )

      { this.blocked = new Boolean( blocked ); }

      public Date getCreationDate()

      { return creationDate; }

      public void setCreationDate( Date creationDate )

      { this.creationDate = creationDate; }

      public Date getModificationDate()

      { return modificationDate; }

      public void setModificationDate( Date modificationDate )

      { this.modificationDate = modificationDate; }

      public String getName()

      { return name; }

      public void setName( String name )

      { this.name = name; }

      public String getCompany()

      { return company; }

      public void setCompany( String company )

      { this.company = company; }

      public String getEmail()

      { return email; }

      public void setEmail( String email )

      { this.email = email; }

      public boolean isFiltered()

      { return id.length() != 0 || resellerId.length() != 0 || resellerName.length() != 0 || role.length() != 0 || blocked != null || creationDate != null || modificationDate != null || name.length() != 0 || company.length() != 0 || email.length() != 0; }

      public boolean isValidData()

      { if( Validator.checkNameNumber( name ) != null ) return false; if( Validator.checkNameNumber( company ) != null ) return false; if( Validator.checkEmail( email ) != null ) return false; return true; }

      public Object clone()
      {
      try

      { return super.clone(); }

      catch( CloneNotSupportedException e )

      { return null; }

      }

      }

      ------------
      ejb-jar.xml:
      ------------

      <?xml version="1.0"?>

      <!-- @version $Id:$ -->

      <ejb-jar
      xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
      http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"
      version="2.1">

      <enterprise-beans>

      <!-- LS -->
      <session>
      <description>LS Web Service</description>
      <ejb-name>LSEjbEndpoint</ejb-name>
      <service-endpoint>com.plesk.ka.ejb.webservice.LSEndpoint</service-endpoint>
      <ejb-class>com.plesk.ka.ejb.webservice.LSBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
      <security-identity><use-caller-identity/></security-identity>
      </session>

      </enterprise-beans>

      <!-- Security area -->

      <assembly-descriptor>

      <security-role>
      <role-name>System</role-name>
      </security-role>

      <security-role>
      <role-name>Admin</role-name>
      </security-role>

      <method-permission>
      <role-name>System</role-name>
      <role-name>Admin</role-name>
      <role-name>Accounts Manager</role-name>
      <method>
      <ejb-name>LSEjbEndpoint</ejb-name>
      <method-name>*</method-name>
      </method>
      </method-permission>

      </assembly-descriptor>

      </ejb-jar>

      ----------
      jboss.xml:
      ----------

      <?xml version="1.0"?>

      <!-- @version $Id:$ -->

      <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">

      <jboss>

      <security-domain>java:/jaas/ka-ls</security-domain>

      </jboss>

      ---------------
      webservices.xml
      ---------------

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

      <webservices
      xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:ka="http://ka.plesk.com/LS"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
      http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"
      version="1.1">

      <webservice-description>
      <webservice-description-name>LSService</webservice-description-name>
      <wsdl-file>META-INF/wsdl/ls.wsdl</wsdl-file>
      <jaxrpc-mapping-file>META-INF/ls_mapping.xml</jaxrpc-mapping-file>
      <port-component>
      <port-component-name>LSEndpoint</port-component-name>
      <wsdl-port>ka:LSEndpoint</wsdl-port>
      <service-endpoint-interface>com.plesk.ka.ejb.webservice.LSEndpoint</service-endpoint-interface>
      <service-impl-bean>
      <ejb-link>LSEjbEndpoint</ejb-link>
      </service-impl-bean>
      </port-component>
      </webservice-description>

      </webservices>

      --------------
      ls_mapping.xml
      --------------

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

      <java-wsdl-mapping
      xmlns="http://java.sun.com/xml/ns/j2ee"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
      http://www.ibm.com/webservices/xsd/j2ee_jaxrpc_mapping_1_1.xsd"
      version="1.1">

      <package-mapping>
      <package-type>com.plesk.ka.ejb.webservice</package-type>
      <namespaceURI>http://webservice.ejb.ka.plesk.com/LSEndpoint</namespaceURI>
      </package-mapping>

      <package-mapping>
      <package-type>com.plesk.ka.model.account</package-type>
      <namespaceURI>http://account.model.ka.plesk.com</namespaceURI>
      </package-mapping>

      </java-wsdl-mapping>

      -------
      ls.wsdl
      -------

      <?xml version="1.0" encoding="UTF-8"?>
      <wsdl:definitions targetNamespace="http://webservice.ejb.ka.plesk.com" xmlns:impl="http://webservice.ejb.ka.plesk.com" xmlns:intf="http://webservice.ejb.ka.plesk.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns2="http://account.model.ka.plesk.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/">
      <wsdl:types>
      <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://account.model.ka.plesk.com">
      <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
      <complexType name="AccountInfo">
      <sequence>
      <element name="blocked" type="xsd:boolean"/>
      <element name="company" nillable="true" type="xsd:string"/>
      <element name="creationDate" nillable="true" type="xsd:dateTime"/>
      <element name="email" nillable="true" type="xsd:string"/>
      <element name="filtered" type="xsd:boolean"/>
      <element name="id" nillable="true" type="xsd:string"/>
      <element name="modificationDate" nillable="true" type="xsd:dateTime"/>
      <element name="name" nillable="true" type="xsd:string"/>
      <element name="resellerId" nillable="true" type="xsd:string"/>
      <element name="resellerName" nillable="true" type="xsd:string"/>
      <element name="role" nillable="true" type="xsd:string"/>
      <element name="validData" type="xsd:boolean"/>
      </sequence>
      </complexType>
      </schema>
      </wsdl:types>

      <wsdl:message name="getAccountInfoResponse">

      <wsdl:part name="getAccountInfoResponse" type="tns2:AccountInfo"/>

      </wsdl:message>

      <wsdl:message name="getAccountInfoRequest">

      <wsdl:part name="in0" type="xsd:int"/>

      </wsdl:message>

      <wsdl:portType name="LSEndpoint">

      <wsdl:operation name="getAccountInfo" parameterOrder="in0">

      <wsdl:input name="getAccountInfoRequest" message="impl:getAccountInfoRequest"/>

      <wsdl:output name="getAccountInfoResponse" message="impl:getAccountInfoResponse"/>

      </wsdl:operation>

      </wsdl:portType>

      <wsdl:binding name="LSEndpointSoapBinding" type="impl:LSEndpoint">

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

      <wsdl:operation name="getAccountInfo">

      <wsdlsoap:operation soapAction=""/>

      <wsdl:input name="getAccountInfoRequest">

      <wsdlsoap:body use="literal" namespace="http://webservice.ejb.ka.plesk.com"/>

      </wsdl:input>

      <wsdl:output name="getAccountInfoResponse">

      <wsdlsoap:body use="literal" namespace="http://webservice.ejb.ka.plesk.com"/>

      </wsdl:output>

      </wsdl:operation>

      </wsdl:binding>

      <wsdl:service name="LSEndpointService">

      <wsdl:port name="LSEndpoint" binding="impl:LSEndpointSoapBinding">

      <wsdlsoap:address location="http://localhost:2000/ka-ls/LSService"/>

      </wsdl:port>

      </wsdl:service>

      </wsdl:definitions>

      -------------------------------------
      A web service is called on client as:

      CallbackHandler handler = new UsernamePasswordHandler( "admin", "password".toCharArray() );
      LoginContext lc = new LoginContext( "other", handler );
      lc.login();

      ServiceFactory serviceFactory = ServiceFactory.newInstance();
      Service service = serviceFactory.createService(
      new URL( "http://localhost:2000/ka-ls/LSService?WSDL" ),
      new QName( "http://webservice.ejb.ka.plesk.com", "LSEndpointService" ) );
      LSEndpoint endpoint = (LSEndpoint) service.getPort( LSEndpoint.class );
      AccountInfo accountInfo = endpoint.getAccountInfo( 0 );
      System.out.println( "AccountInfo: " + accountInfo.getName() );

      lc.logout();

      --------------------------------------------

      So it works fine on jboss-4.0.2RC1+j2sdk1.4.2_05, but on jdk1.5.0_02 it throws:
      (while calling endpoint.getAccountInfo( 0 ))

      run.test:
      [java] KA console test started...
      [java] log4j:WARN No appenders could be found for logger (org.jboss.webservice.EngineConfigurationFinder).
      [java] log4j:WARN Please initialize the log4j system properly.
      [java] java.rmi.RemoteException: null; nested exception is:
      [java] java.lang.NullPointerException
      [java] at org.jboss.webservice.client.PortProxy.invoke(PortProxy.java:176)
      [java] at $Proxy1.getAccountInfo(Unknown Source)
      [java] at com.plesk.ka.util.test.ConsoleTest.testWS(ConsoleTest.java:231)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [java] at java.lang.reflect.Method.invoke(Method.java:585)
      [java] at com.plesk.ka.util.test.ConsoleTest.main(ConsoleTest.java:77)
      [java] Caused by: java.lang.NullPointerException
      [java] at java.util.Hashtable.put(Hashtable.java:396)
      [java] at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.setProperty(SAXParserImpl.java:395)
      [java] at org.jboss.axis.encoding.DeserializationContextImpl.parse(DeserializationContextImpl.java:262)
      [java] at org.jboss.axis.MessagePart.getAsSOAPEnvelope(MessagePart.java:684)
      [java] at org.jboss.axis.Message.getSOAPEnvelope(Message.java:428)
      [java] at org.jboss.axis.Message.getContentType(Message.java:494)
      [java] at org.jboss.axis.transport.http.HTTPSender.writeToSocket(HTTPSender.java:386)
      [java] at org.jboss.axis.transport.http.HTTPSender.invoke(HTTPSender.java:126)
      [java] at org.jboss.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:73)
      [java] at org.jboss.axis.SimpleChain.doVisiting(SimpleChain.java:160)
      [java] at org.jboss.axis.SimpleChain.invoke(SimpleChain.java:123)
      [java] at org.jboss.webservice.client.ClientEngine.invoke(ClientEngine.java:128)
      [java] at org.jboss.axis.client.Call.invokeEngine(Call.java:3054)
      [java] at org.jboss.axis.client.Call.invoke(Call.java:3039)
      [java] at org.jboss.axis.client.Call.invoke(Call.java:2629)
      [java] at org.jboss.axis.client.Call.invoke(Call.java:2538)
      [java] at org.jboss.axis.client.Call.invokeInternal(Call.java:1976)
      [java] at org.jboss.axis.client.Call.invoke(Call.java:1914)
      [java] at org.jboss.webservice.client.CallImpl.invoke(CallImpl.java:265)
      [java] at org.jboss.axis.client.AxisClientProxy.invoke(AxisClientProxy.java:381)
      [java] at $Proxy0.getAccountInfo(Unknown Source)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      [java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      [java] at java.lang.reflect.Method.invoke(Method.java:585)
      [java] at org.jboss.webservice.client.PortProxy.invoke(PortProxy.java:105)
      [java] ... 7 more

      Also, when trying to call WebService from another Bean not thru the ServiceFactory it works fine on both jdk 1.4 and 1.5 (may be it'll help somehow):

      javax.naming.Context jndiContext = new InitialContext();
      Object obj = jndiContext.lookup( "java:comp/env/service/LS" );
      javax.xml.rpc.Service svc = (javax.xml.rpc.Service) obj;
      LSEndpoint endpoint = (LSEndpoint) svc.getPort( LSEndpoint.class );
      return endpoint.getAccountInfo( accountId );

      run.test:
      [java] KA console test started...
      [java] log4j:WARN No appenders could be found for logger (org.jboss.webservice.EngineConfigurationFinder).
      [java] log4j:WARN Please initialize the log4j system properly.
      [java] AccountInfo: SWsoft

        1. JBWS-187-patch.txt
          2 kB
          Darran Lofthouse

              jgreene@redhat.com Jason Greene
              shel_jira Slava Shelestyuk (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: