Hello guy´s.
For a cups of days I´ve been trying to lookup an ejb in a Jboss Server from a
Tomcat 5.x. I tried a lot of solutions, that with the inside a contex too, and
I realized that nothing work at all.
So, I did the obvious...
I unistalled the tomcat from my computer. Instaled Again in a directory called
D:\Tomcat
Put my application inside the webapps.
And called EJB in the normal classic way!... And works for me. The trick is
that in a Windows OS, the tomcat instalation home had a blank spaces in the
name of the path. i.e - c:\Program Files\Apache Software Foundation\Tomcat
5.5\....
so, this blank spaces do not let the initial context to initialized de
properties wrigth.
BoryS
My CODE:
package br.gov.tresp.servlets;
|
| import java.io.IOException;
| import java.io.PrintWriter;
| import java.util.Properties;
|
| import javax.naming.InitialContext;
| import javax.rmi.PortableRemoteObject;
| import javax.servlet.ServletException;
| import javax.servlet.http.HttpServlet;
| import javax.servlet.http.HttpServletRequest;
| import javax.servlet.http.HttpServletResponse;
|
| import com.fiap.hello.ejb.Hello;
| import com.fiap.hello.ejb.HelloHome;
| import com.fiap.hello.ejb.Pessoa;
|
| public class Cliente extends HttpServlet {
|
| /**
| *
| */
| private static final long serialVersionUID = -2896402595743969746L;
|
| protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {
| // TODO Auto-generated method stub
| this.doPost(arg0, arg1);
| }
|
| protected void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException {
| // TODO Auto-generated method stub
|
| Properties props = new Properties();
|
| props.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
| props.setProperty("java.naming.provider.url", "localhost:1099");
| props.setProperty("java.naming.factory.url.pkgs",
"org.jboss.naming");
|
| try {
| InitialContext context = new InitialContext(props);
| Object objref = context.lookup("ejb/HelloHome");
| //Object objref = new
InitialContext().lookup("java:comp/env/bean/Locator");
|
| HelloHome home = (HelloHome)PortableRemoteObject.narrow(objref,
HelloHome.class);
| System.out.println(home);
| Hello hello = home.create();
| Pessoa p = new Pessoa();
| p.setNome("Borys Marcelo");
| p.setIdade(24);
| hello.meMostra(p);
| } catch (Exception e){
| e.printStackTrace();
| PrintWriter out = response.getWriter();
| StackTraceElement[] elements = e.getStackTrace();
| e.printStackTrace(out);
| out.print(e.getMessage());
|
| }
|
| }
|
|
|
|
|
|
|
| }
|
Don´t need nothing more in the WEB.xml neither in a Context.xml
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3931989#3931989
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3931989
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user