Hi everybody!
I'm new at JBoss so I'm created a simply web application to begin, but I've 
encountered a strange Exception: 
javax.servlet.ServletException: Lookup of java:/comp/env/ failed -- 
java.lang.ClassCastException
        saluti.web.HolaServlet.init(HolaServlet.java:49)
        
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:175)
        
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:74)
        
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
        
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
        
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        
org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        java.lang.Thread.run(Unknown Source)


My application asks for a sentence and display it on the screen with some 
changes. Here is the code.
HOLABEAN.JAVA:
package saluti.ejb;

import java.rmi.RemoteException;

import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

import javax.ejb.CreateException;

/**
 * @ejb.bean name="Hola"
 *           display-name="Name for Hola"
 *           description="Description for Hola"
 *           jndi-name="ejb/Hola"
 *           type="Stateless"
 *           view-type="remote"
 */
public class HolaBean implements SessionBean {

        public HolaBean() {
                super();
                // TODO Auto-generated constructor stub
        }

        public void setSessionContext(SessionContext ctx)
                throws EJBException,
                RemoteException {
                // TODO Auto-generated method stub

        }

        public void ejbRemove() throws EJBException, RemoteException {
                // TODO Auto-generated method stub

        }

        public void ejbActivate() throws EJBException, RemoteException {
                // TODO Auto-generated method stub

        }

        public void ejbPassivate() throws EJBException, RemoteException {
                // TODO Auto-generated method stub

        }

        /**
         * Default create method
         * 
         * @throws CreateException
         * @ejb.create-method
         */
        public void ejbCreate() throws CreateException {
                // TODO Auto-generated method stub
        }

        /**
         * Business method
         * @ejb.interface-method  view-type = "remote"
         */
        public String passer(String fraseInit) {
                fraseInit=fraseInit+" + 'Never give up!!'";
                return fraseInit;
        }
}

HOLASERVLET.JAVA:
package saluti.web;

import javax.servlet.http.HttpServlet;

import javax.servlet.ServletException;
import javax.servlet.ServletConfig;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import saluti.interfaces.*;
import javax.rmi.*;
import java.util.*;
import javax.naming.*;

/**
 *
 * @web.servlet              name="Hola"
 *                           display-name="Hola Servlet"
 *                           description="It's change the sentence"
 * @web.servlet-mapping      url-pattern="/Hola"
 * 
 * @web.ejb-ref
 *                      name="ejb/Hola"
 *                              type="Session"
 *                              home="saluti.interfaces.HolaHome"
 *                              remote="saluti.interfaces.Hola"
 *                              description="Reference to the Hola EJB"
 * 
 * @jboss.ejb-ref-jndi
 *                              ref-name="ejb/Hola"
 *                              ndi-name="ejb/Hola"
 * 
 */
public class HolaServlet extends HttpServlet {

        private HolaHome home;  
        
        public HolaServlet() {
                super();
                // TODO Auto-generated constructor stub
        }

        public void init(ServletConfig config) throws ServletException {
                try {
                        Context context = new InitialContext();
                        Object ref = context.lookup("java:/comp/env/ejb/Hola");
                        home = (HolaHome) PortableRemoteObject.narrow(ref, 
HolaHome.class);
                        } catch (Exception e) {
                        throw new ServletException("Lookup of java:/comp/env/ 
failed -- "+e);
                        }               
        }

        protected void doPost(HttpServletRequest request, HttpServletResponse 
response)
                throws ServletException,
                IOException {
                response.setContentType("text/html");
                PrintWriter out = response.getWriter();
                
                out.println("");
                out.println("E divenne...");
                out.println("");
                out.println("");
                out.println("<h1>");
                out.println("Magggggia");
                out.println("</h1>");
                
                try {
                        Hola bean = home.create();
                        String value = request.getParameter("inizio");
                        String newValue = null;
                        if (value!=null)
                                newValue = bean.passer(value);
                        bean.remove();
                        out.println("");
                        out.print("Ed ecco il risultato: ");
                        out.println(newValue);
                        out.println("");
                        } catch (Exception e) {
                        out.println(e.getMessage());
                        e.printStackTrace(out);
                        } finally {
                        out.println("");
                        out.close();
                }
        }//doPost

}//HolaServlet

INDEX.HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


Inizi di Web Service




  QUESTO E' L'INDEX DEL MIO 
    PICCOLO WEB SERVICE....DA QUI...COMINCIA TUTTO........ 
  &nbsp;
  Inserisci la frase
  
  
     
     
         
  




Thanks in advance for everything!!

Luke

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976757#3976757

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976757
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to