This content has been marked as final.
Show 3 replies
-
1. Re: Problem by using Tomcat (web) to access JBoss (app)
thomas2008ch May 12, 2008 6:33 AM (in response to thomas2008ch)The JSP looks as follow:
... <%@ page import="javax.naming.*,java.text.*,java.util.*,com.wei.chen.ejbs.stateless.*,com.wei.chen.ejbs.entity.*"%> <%!private Calculator cal = null; private NumberFormat nf = null; public void jspInit() { try { InitialContext ctx = new InitialContext(); cal = (Calculator) ctx.lookup("EntityCalculator/remote"); } catch (Exception e) { e.printStackTrace(); } nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); }%> <% if ("AddFund".equals(request.getParameter("action"))) { cal.addFund(request.getParameter("fundname"), Double .parseDouble(request.getParameter("fundrate"))); } %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Insert title here</title> </head> <body> <p>Add a new Fund:<br /> <form action="addfund.jsp" method="POST">Fund Name : <input type="text" name="fundname" value=""> Growth rate : <input type="text" name="fundrate" value="0.05"><input type="hidden" name="action" value="AddFund"><br /> <input type="submit" value="Add fund"><INPUT type="button" value="Close Window" onClick="window.close()"></form> <br /> <% Collection <Fund> funds = cal.getFunds(); %> ...
I get more info for the exception from the CMD-Console as follow:javax.naming.NameNotFoundException: Name EntityCalculator is not bound in this C ontext at org.apache.naming.NamingContext.lookup(NamingContext.java:770) at org.apache.naming.NamingContext.lookup(NamingContext.java:153) at org.apache.naming.SelectorContext.lookup(SelectorContext.java:137) at javax.naming.InitialContext.lookup(InitialContext.java:351) at org.apache.jsp.calculator_jsp.jspInit(calculator_jsp.java:21) at org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:51) at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrap per.java:159) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper .java:329) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3 20) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV alve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:263) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java :844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce ss(Http11Protocol.java:584) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44 7) at java.lang.Thread.run(Thread.java:595) ...
That means the stateless session bean "EntityCalculator.java" is not bound successfully from Tomcat to JBoss.
Somebody has experience? -
2. Re: Problem by using Tomcat (web) to access JBoss (app)
jaikiran May 12, 2008 11:56 AM (in response to thomas2008ch)InitialContext ctx = new InitialContext();
You will have to change this to pass the context information. That will help Tomcat know that you are looking for an object which resides on JBoss.Properties props = new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); props.put(Context.PROVIDER_URL,"jnp://localhost:1099"); Context ctx = new InitialContext(props);
Also, make sure that you add the jbossall-client.jar file (present in %JBOSS_HOME%/client folder) to the lib folder of your WAR in Tomcat. -
3. Re: Problem by using Tomcat (web) to access JBoss (app)
thomas2008ch May 12, 2008 12:11 PM (in response to thomas2008ch)It helps!
Many thanks!