1 Reply Latest reply on Sep 29, 2007 2:52 PM by reckless_jack

    why ? - exception: error during JRMP connection establishmen

    reckless_jack

      hi can nyone tell me why problem mentioned in subject line is occuring
      below here my code;

      package example;

      import javax.naming.Context;
      import javax.naming.InitialContext;
      import java.util.Properties;

      public class HelloClient {

      public static void main(String[ ] args) throws Exception {



      System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      System.setProperty("java.naming.provider.url","jnp://localhost:1099");
      System.setProperty("java.naming.factory.url.pkgs","org.jboss.namimg:org.jboss.jnp.interfaces");
      System.setProperty("jnp.socketFactory","org.jnp.interfaces.TimedSocketFactory");
      System.setProperty("jnp.timeout","10000");

      Properties prop=System.getProperties( );

      Context ctx=new InitialContext( prop );

      Object obj=ctx.lookup("Hello");

      HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow( obj, HelloHome.class);

      Hello hello=home.create( );

      System.out.println( hello.hello() );

      hello.remove( );
      }
      }

        • 1. Details---along with code
          reckless_jack

          I am getting exception-
          error during JRMP connection establishment : nested exception
          java.net.SocketException- Connection Reset


          chek out my ejb -------------

          -----Hello.java---------
          package example;

          import javax.ejb.*;
          import java.rmi.RemoteException;

          public interface Hello extends EJBObject {

          public String hello() throws RemoteException;

          }

          ----------------HelloBean.java------------------
          package example;

          import javax.ejb.*;

          public class HelloBean implements SessionBean {

          private SessionContext ctx;

          // ejbRequiredmethod

          public void ejbCreate( ) {
          System.out.println("ejbCreate() ");
          }

          public void ejbRemove( ) {
          System.out.println("ejbRemove() " );
          }

          public void ejbActivate( ) {
          System.out.println(" ejbActivate() " );
          }

          public void ejbPassivate( ) {
          System.out.println(" ejbPassivate() " );
          }

          public void setSessionContext(SessionContext ctx ) {
          this.ctx=ctx;
          }

          // business methods

          public String hello() {
          System.out.println(" hello() " );
          return "----Hello, World !---" ;
          }
          }

          --------------------HelloHome.java-----------------
          package example;

          import javax.ejb.*;
          import java.rmi.RemoteException;

          public interface HelloHome extends EJBHome {

          Hello create() throws RemoteException,CreateException;

          }

          --------------HelloLocal.java-------------------

          package example;

          import javax.ejb.*;

          public interface HelloLocal extends EJBLocalObject {

          public String hello();

          }
          --------------------HelloLocalHome------------

          package example;

          import javax.ejb.*;

          public interface HelloLocalHome extends EJBLocalHome {

          HelloLocal create( ) throws CreateException;
          }

          ----------Client code which access above bean-------------

          package example;

          import javax.naming.Context;
          import javax.naming.InitialContext;
          import java.util.Properties;

          public class HelloClient {

          public static void main(String[ ] args) throws Exception {



          System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
          System.setProperty("java.naming.provider.url","jnp://localhost:1099");
          System.setProperty("java.naming.factory.url.pkgs","org.jboss.namimg:org.jboss.jnp.interfaces");
          System.setProperty("jnp.socketFactory","org.jnp.interfaces.TimedSocketFactory");
          System.setProperty("jnp.timeout","10000");

          Properties prop=System.getProperties( );

          Context ctx=new InitialContext( prop );

          Object obj=ctx.lookup("Hello");

          HelloHome home = (HelloHome) javax.rmi.PortableRemoteObject.narrow( obj, HelloHome.class);

          Hello hello=home.create( );

          System.out.println( hello.hello() );

          hello.remove( );
          }
          }

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


          <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1"
          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">

          <enterprise-beans>

          <ejb-name>Hello</ejb-name>
          example.HelloHome
          example.Hello
          <local-home>example.HelloLocalHome</local-home>
          example.HelloLocal
          <ejb-class>example.HelloBean</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>

          </enterprise-beans>

          </ejb-jar>


          ------------------------------------------
          do i need to use username and password from client code
          ,when jboss is already running