I have attached my servlet code, ejb-jar.xml and my web.xml.
 
Thanks
Arup

__matthewHawthorne <[EMAIL PROTECTED]> wrote:
Arup Sarkar wrote:
> It would be great if anyone can help. I am trying to build a stateless
> session bean with DAO and a servlet accessing the session bean,
> compilation, packaging and deployment is working fine, but when I am
> hitting the url for the servlet I am getting the following error.My
> environment is JBoss 3.2.1, XDoclet1.2
>
> /************************************************/
>
> 2004-01-24 13:23:28,078 INFO [STDOUT] Entering
> AccessControllerServlet.init()
> 2004-01-24 13:23:28,125 ERROR [STDERR] java.lang.ClassCastException
> 2004-01-24 13:23:28,125 ERROR [STDERR] at
> com.sun.corba.se.internal.javax.rmi.PortableRemoteObject.narrow


I don't find the build files to be very useful in debugging this problem.

What about the code in your servlet?

And your deployment descriptors? Are you using ejb-refs in your web.xml
-- if so, maybe the JNDI names and classes don't match?

There are too many variables in this situation, you need to eliminate
them one by one.

Can you lookup the EJB outside of the servlet container?


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user


Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
/*
 * SessionTestServlet.java
 *
 */
package com.zen.store.servlet;

//import custom packages
import com.zen.store.session.*;


import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import javax.naming.*;
import javax.rmi.PortableRemoteObject;

import java.rmi.RemoteException;
import java.util.Hashtable;
import javax.ejb.CreateException;

/**
 * @web.servlet
 *     name="AccessController"
 *
 * @web.servlet-mapping
 *     url-pattern="/access"
 * 
 * @web.ejb-ref 
 *     name="session/StoreAccess"
 *     type="session"
 *     home="com.zen.store.session.StoreAccessHome"
 *     remote="com.zen.store.session.StoreAccess"
 *         link="StoreAccess"
 */

public class AccessControllerServlet extends HttpServlet {
        
   private com.zen.store.session.StoreAccessHome storeAccessHome = null;
   private com.zen.store.session.StoreAccess storeAccess = null;

   public void init(ServletConfig config) throws ServletException{
      System.out.println("Entering AccessControllerServlet.init()");
      super.init(config);
           /*
           try {
              InitialContext ctx = new InitialContext();
                  Object objref = ctx.lookup("com/zen/store/session/StoreAccessBean");
                  storeAccessHome = 
(StoreAccessHome)PortableRemoteObject.narrow(objref, StoreAccessHome.class);
           } catch (Exception NamingException) {
                NamingException.printStackTrace();
           }
           */
          try{
         storeAccessHome = getHome();
          }catch(Exception e){
                  e.printStackTrace();
         System.out.println("Exception AccessControllerServlet.init()" + e.toString());
          }
        
      System.out.println("Leaving AccessControllerServlet.init()");
   }
   
   private com.zen.store.session.StoreAccessHome getHome() throws NamingException{

         Object result = 
getContext().lookup(com.zen.store.session.StoreAccessHome.JNDI_NAME);
             
return((com.zen.store.session.StoreAccessHome)PortableRemoteObject.narrow(result, 
com.zen.store.session.StoreAccessHome.class));
             //return((StoreAccessHome)result);
   }


   private InitialContext getContext() throws NamingException{
          Hashtable props = new Hashtable();
          props.put(InitialContext.INITIAL_CONTEXT_FACTORY, 
"org.jnp.interfaces.NamingContextFactory");
          props.put(InitialContext.PROVIDER_URL, "jnp://127.0.0.1:1099");

          InitialContext initialContext = new InitialContext(props);
      return initialContext;       
   }

   public void destroy(){
   }
   
   protected void doGet(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, IOException{
          try{
         storeAccess = storeAccessHome.create();
             String userID = storeAccess.loginUser("ANDY","PASSWD");
             System.out.println(userID);
         storeAccess.remove();
          }catch(Exception e){
         System.out.println("Exception AccessControllerServlet.doGet()" + 
e.toString());
          }

   }

   protected void doPost(HttpServletRequest request, HttpServletResponse response) 
throws ServletException, IOException{
          try{
                  doGet(request, response);
          }catch(Exception e){
         System.out.println("Exception AccessControllerServlet.doPost()" + 
e.toString());
          }

   }

  /*
  public void service(HttpServletRequest request, HttpServletResponse response) throws 
ServletException, IOException {

    try {
  
      StoreAccessHome home = StoreAccessUtil.getHome();
      StoreAccess facade = home.create();
      
          String userID = facade.loginUser("ANDY","PASSWD");
          System.out.println("User Id : " + userID);      
    } catch (Exception e) {
      e.printStackTrace();
          System.out.println("Error in AccessControllerServlet." + e.toString());
    }
  }
   */


}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd";>

<ejb-jar >

   <description><![CDATA[No Description.]]></description>
   <display-name>Generated by XDoclet</display-name>

   <enterprise-beans>

      <!-- Session Beans -->
      <session >
         <description><![CDATA[]]></description>

         <ejb-name>StoreAccess</ejb-name>

         <home>com.zen.store.session.StoreAccessHome</home>
         <remote>com.zen.store.session.StoreAccess</remote>
         <local-home>com.zen.store.session.StoreAccessLocalHome</local-home>
         <local>com.zen.store.session.StoreAccessLocal</local>
         <ejb-class>com.zen.store.session.StoreAccessSession</ejb-class>
         <session-type>Stateless</session-type>
         <transaction-type>Container</transaction-type>

         <resource-ref >
            <res-ref-name>jdbc/MySqlDS</res-ref-name>
            <res-type>javax.sql.Datasource</res-type>
            <res-auth>Container</res-auth>
         </resource-ref>

      </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.
     -->

      <!-- Message Driven Beans -->
     <!--
       To add message driven beans that you have deployment descriptor info for, add
       a file to your XDoclet merge directory called message-driven-beans.xml that contains
       the <message-driven></message-driven> markup for those beans.
     -->

   </enterprise-beans>

   <!-- Relationships -->

   <!-- 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 -->

   <!-- transactions -->

   <!-- finder transactions -->
   </assembly-descriptor>

</ejb-jar>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd";>

<web-app >

    <!--
    To use non XDoclet filters, create a filters.xml file that
    contains the additional filters (eg Sitemesh) and place it in your
    project's merge dir.  Don't include filter-mappings in this file,
    include them in a file called filter-mappings.xml and put that in
    the same directory.
    -->

    <!--
    To use non XDoclet filter-mappings, create a filter-mappings.xml file that
    contains the additional filter-mappings and place it in your
    project's merge dir.
    -->

    <!--
    To use non XDoclet listeners, create a listeners.xml file that
    contains the additional listeners and place it in your
    project's merge dir.
    -->

  <!--
  To use non XDoclet servlets, create a servlets.xml file that
  contains the additional servlets (eg Struts) and place it in your
  project's merge dir.  Don't include servlet-mappings in this file,
  include them in a file called servlet-mappings.xml and put that in
  the same directory.
  -->

   <servlet>
      <servlet-name>AccessController</servlet-name>
     <servlet-class>com.zen.store.servlet.AccessControllerServlet</servlet-class>

   </servlet>

   <servlet-mapping>
      <servlet-name>AccessController</servlet-name>
      <url-pattern>/access</url-pattern>
   </servlet-mapping>

   <!--
   To specify mime mappings, create a file named mime-mappings.xml, put it in your project's mergedir.
   Organize mime-mappings.xml following this DTD slice:

   <!ELEMENT mime-mapping (extension, mime-type)>
   -->

   <!--
   To specify error pages, create a file named error-pages.xml, put it in your project's mergedir.
   Organize error-pages.xml following this DTD slice:

   <!ELEMENT error-page ((error-code | exception-type), location)>
   -->

  <!--
  To add taglibs by xml, create a file called taglibs.xml and place it
  in your merge dir.
  -->

   <!--
   To set up security settings for your web app, create a file named web-security.xml, put it in your project's mergedir.
   Organize web-security.xml following this DTD slice:

   <!ELEMENT security-constraint (display-name?, web-resource-collection+, auth-constraint?, user-data-constraint?)>
   <!ELEMENT web-resource-collection (web-resource-name, description?, url-pattern*, http-method*)>
   <!ELEMENT web-resource-name (#PCDATA)>
   <!ELEMENT url-pattern (#PCDATA)>
   <!ELEMENT http-method (#PCDATA)>
   <!ELEMENT user-data-constraint (description?, transport-guarantee)>
   <!ELEMENT transport-guarantee (#PCDATA)>

   <!ELEMENT login-config (auth-method?, realm-name?, form-login-config?)>
   <!ELEMENT auth-method (#PCDATA)>
   <!ELEMENT realm-name (#PCDATA)>
   <!ELEMENT form-login-config (form-login-page, form-error-page)>
   <!ELEMENT form-login-page (#PCDATA)>
   <!ELEMENT form-error-page (#PCDATA)>
   -->

   <ejb-ref >
      <ejb-ref-name>session/StoreAccess</ejb-ref-name>
      <ejb-ref-type>session</ejb-ref-type>
      <home>com.zen.store.session.StoreAccessHome</home>
      <remote>com.zen.store.session.StoreAccess</remote>
      <ejb-link>StoreAccess</ejb-link>
   </ejb-ref>

</web-app>

Reply via email to