I have successfully deployed a session bean, but cannot connect.  Here is
the code to connect:

import java.io.*;
import java.rmi.*;
import java.rmi.server.*;
import java.util.*;
import javax.ejb.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.*;
import allaire.ejipt.*;

public class bobServlet extends HttpServlet {

  private static final String CONTENT_TYPE = "text/html";

  //  bobHome homebob = null;
  //  bob thebob = null;
 // Context ctx = null;

  public void init(ServletConfig config) throws ServletException {
          super.init(config);
  }

  public void doGet(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
    response.setContentType(CONTENT_TYPE);
    PrintWriter out = response.getWriter();
  //  String returned = "oh.....no";
    String returned2;
    boolean exception=false;

    System.setSecurityManager(new RMISecurityManager());
    out.println("<html>");
    out.println("<head><title>bobServlet</title></head>");
    out.println("<body>");
    try {
      final Properties properties = new Properties();
      properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
"allaire.ejipt.ContextFactory");
      properties.setProperty(Context.PROVIDER_URL,
"ejipt://127.0.0.1:2323");
    //  properties.setProperty(Context.SECURITY_PRINCIPAL, "spender1");
    //  properties.setProperty(Context.SECURITY_CREDENTIALS, "pass");

      Context ctx = new InitialContext(properties);
      final bobHome homebob = (bobHome)ctx.lookup("test.bobBean");
      final bob thebob = homebob.create();
       returned2 = thebob.returnString("This is a Bean.  I am no longer a
flunky.");
       out.println(returned2.toString());

        if(returned2 != null) {
          out.println("returned2 is not null.");
        }
        else {
          out.println("returned2 is null.");
        }
      // out.println(thebob.returnString("This is a Bean.  I am no longer a
flunky.").toString());


/*
Properties p = new Properties();
ContextProperties.setProperty("java.naming.factory.initial","allaire.ejipt.C
ontextFactory" );
ContextProperties.setProperty("java.naming.provider.url",
"ejipt://127.0.0.1:2323" );
InitialContext ctx=new InitialContext(p);
bobHome homebob=(bobHome)ctx.lookup("test.bobBean");
*/
    }
    catch(Exception e) {
      out.println("Exception was thrown.");
      out.println(e.toString());
    }

  //  out.println("This is new");

  //  if(ctx == null) {
  //    out.println("<p>ctx is null</p>");
 //   }
//    else {
//      out.println("<p>ctx is not null</p>");



//    } // end of else
    out.println("</body>");
    out.println("</html>");
  }

  /**Clean up resources*/
  public void destroy() {
  }
}
*******************************************************HERE IS THE
DEPLOYMENT
DESCRIPTOR******************************************************************
****************************
<?xml version="1.0"?>

<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd";>

<ejb-jar>
  <display-name>bobEJB</display-name>
  <enterprise-beans>
    <session>
      <description>First EJB</description>
      <ejb-name>test.bobBean</ejb-name>
      <home>bobHome</home>
      <remote>bob</remote>
      <ejb-class>bobBean</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
    </session>
  </enterprise-beans>

  <assembly-descriptor>
    <security-role>
        <description>
          Hark, this is a description.
        </description>
       <role-name>all</role-name>
    </security-role>

     <method-permission>
       <role-name>all</role-name>
         <method>
            <ejb-name>bobBean</ejb-name>
               <method-name>*</method-name>
         </method>
      </method-permission>

    <container-transaction>
        <method>
           <ejb-name>test.bobBean</ejb-name>
           <method-name>*</method-name>
        </method>
        <trans-attribute>Required</trans-attribute>
    </container-transaction>
  </assembly-descriptor>
</ejb-jar>

****************************************************************************
******HERE IS THE deployment.properties
FILE************************************************************************
*************
#
#Fri Jun 22 11:38:17 EDT 2001
ejipt.classServer.host=localhost
ejipt.ejbJars=bob_new.jar
ejipt.userHomeName=default.UserName
ejipt.roleHomeName=default.RoleName
ejipt.loginSessionHomeName=default.LoginSessionHome
ejipt.users=spender1:pass;spender2:pass;saver1:pass;saver2:pass;chief:pass
ejipt.roles=all:spender1,spender2,chief,saver:saver1,saver2,chief





I have looked at all of the articles on Allaire's site and have referred to
the samples many times but have been unable to get a bean running.  Any help
would be most appreciated.

Thanks,
Bob


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to