0 Replies Latest reply on Jan 7, 2005 2:59 AM by Dilip Padhee

    SocketTimeoutException while using DatabaseServerLoginModule

    Dilip Padhee Newbie

      Getting the following exception in the client side while accessing a
      stateless bean.And using the DatabaseServerLoginModule for authentication.

      Any comments ??

      javax.security.auth.login.LoginException: javax.naming.CommunicationException: R
      eceive timed out [Root exception is java.net.SocketTimeoutException: Receive tim
      ed out]
       at org.jboss.security.auth.spi.DatabaseServerLoginModule.getUsersPasswor
      d(DatabaseServerLoginModule.java:110)
       at org.jboss.security.auth.spi.UsernamePasswordLoginModule.login(Usernam
      ePasswordLoginModule.java:156)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
       at java.lang.reflect.Method.invoke(Unknown Source)
       at javax.security.auth.login.LoginContext.invoke(Unknown Source)
       at javax.security.auth.login.LoginContext.access$000(Unknown Source)
       at javax.security.auth.login.LoginContext$4.run(Unknown Source)
       at java.security.AccessController.doPrivileged(Native Method)
       at javax.security.auth.login.LoginContext.invokeModule(Unknown Source)
       at javax.security.auth.login.LoginContext.login(Unknown Source)
       at SjJBossExecQuery.run(SjJBossExecQuery.java:115)



      Am using Hypersonic database.
      My ejb-jar.xml is as follows:



      <ejb-jar >
      
       <description><![CDATA[No Description.]]></description>
       <display-name>Generated by XDoclet</display-name>
      
       <enterprise-beans>
      
       <!-- Session Beans -->
       <session >
       <description><![CDATA[Management Session Bean to enable the client to manage the server its is deployed on.]]></description>
       <display-name>JBoss Management EJB (MEJB)</display-name>
      
       <ejb-name>MEJB</ejb-name>
      
       <home>javax.management.j2ee.ManagementHome</home>
       <remote>org.jboss.management.mejb.MEJB</remote>
       <ejb-class>org.jboss.management.mejb.MEJBSession</ejb-class>
       <session-type>Stateless</session-type>
       <transaction-type>Container</transaction-type>
       <resource-ref>
       <description>The default DS</description>
       <res-ref-name>jdbc/DefaultDS</res-ref-name>
       <res-type>javax.sql.DataSource</res-type>
       <res-auth>Container</res-auth>
       </resource-ref>
      
       <security-identity>
       <run-as>
       <role-name>JBossAdmin</role-name>
       </run-as>
       </security-identity>
      
      
       <env-entry>
       <description><![CDATA[JNDI-Name of the MBeanServer to be used to look it up. If 'null' the first of all listed local MBeanServer is taken]]></description>
       <env-entry-name>Server-Name</env-entry-name>
       <env-entry-type>java.lang.String</env-entry-type>
       <env-entry-value><![CDATA[null]]></env-entry-value>
       </env-entry>
      
       </session>
      
       <!--
       To add session beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called session-beans.xml that contains
       the <session></session> markup for those beans.
       -->
      
       <!-- Entity Beans -->
       <!--
       To add entity beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called entity-beans.xml that contains
       the <entity></entity> markup for those beans.
       -->
      
       </enterprise-beans>
      
       <!-- Assembly Descriptor -->
       <assembly-descriptor >
       <!--
       To add additional assembly descriptor info here, add a file to your
       XDoclet merge directory called assembly-descriptor.xml that contains
       the <assembly-descriptor></assembly-descriptor> markup.
       -->
      
       <!-- finder permissions -->
      
       <security-role>
       <role-name>JBossAdmin</role-name>
       </security-role>
      
       <!-- transactions -->
       <container-transaction >
       <method >
       <ejb-name>MEJB</ejb-name>
       <method-name>*</method-name>
       </method>
       <trans-attribute>Supports</trans-attribute>
       </container-transaction>
      
       <!-- finder transactions -->
       <method-permission>
       <role-name>JBossAdmin</role-name>
       <method>
       <ejb-name>MEJB</ejb-name>
       <method-name>*</method-name>
       </method>
      </method-permission>
       </assembly-descriptor>
      
      
      </ejb-jar>
      
      


      And My Jboss.xml file is :
      <jboss>
      <security-domain>java:/jaas/DKP</security-domain>
       <enterprise-beans>
      
       <!--
       To add beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called jboss-beans.xml that contains
       the <session></session>, <entity></entity> and <message-driven></message-driven>
       markup for those beans.
       -->
      
       <session>
       <ejb-name>MEJB</ejb-name>
       <jndi-name>ejb/mgmt/MEJB</jndi-name>
       <local-jndi-name>MEJBLocal</local-jndi-name>
       <resource-ref>
       <res-ref-name>jdbc/DefaultDS</res-ref-name>
       <jndi-name>java:/DefaultDS</jndi-name>
       </resource-ref>
      
      
       </session>
      
       </enterprise-beans>
      
       <resource-managers>
       </resource-managers>
      
      </jboss>
      



      And my client code is :

      Properties props = new Properties();
       props.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       props.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
       props.put(Context.PROVIDER_URL, str[1]);
      
       try {
       System.out.println("Before LoginContext");
       //*javax.security.auth.login.LoginContext context1 = new javax.security.auth.login.LoginContext("dilip");
       AppCallbackHandler handler = new AppCallbackHandler(str[2], str[3].toCharArray());
       javax.security.auth.login.LoginContext lc = new javax.security.auth.login.LoginContext("dilipkumar", handler);
       System.out.println("Created LoginContext");
       lc.login();
      
       InitialContext context = new InitialContext(props);
      
       Object obj = context.lookup( "ejb/mgmt/MEJB" );
       ManagementHome home = (ManagementHome) PortableRemoteObject.narrow(obj,ManagementHome.class);
       server = home.create();