Hi Guys,
I deployed successfully HelloRamEJB with lookup name "HelloRam".When i called this bean from hello.jsp
using the following code,
<%
String retval = "";
String r = "rvrk";
try{
Context ctx = new InitialContext();
HelloRamHome home=(HelloRamHome) ctx.lookup("HelloRam");
HelloRam hel = (HelloRam)home.create();
retval = hel.sayHello(r);
}
catch (Exception e) {
System.out.println("exception in try-stacktrace: " + e.printStackTrace());}
%>
it's following error on browser..
C:\weblogic\myserver\classfiles\jsp_servlet\_hello.java:91: Incompatible type for +. Can't convert java.lang.String to int.
probably occurred due to an error in /hello.jsp line 18:
HelloRamHome home = (HelloRamHome) ctx.lookup("HelloRam");
C:\weblogic\myserver\classfiles\jsp_servlet\_hello.java:91: Incompatible type for +. Can't convert void to int.
probably occurred due to an error in /hello.jsp line 18:
HelloRamHome home = (HelloRamHome) ctx.lookup("HelloRam");
What are the various reasons for this.
Can any body give proper solution.
Thanks.
-
Calling EJB from JSP (6 messages)
- Posted by: ramki reddy
- Posted on: April 05 2001 10:36 EDT
Threaded Messages (6)
- Calling EJB from JSP by karthik sa on April 05 2001 12:15 EDT
- Calling EJB from JSP by Kapil Israni on April 05 2001 12:22 EDT
- Calling EJB from JSP by gautam gupta on April 05 2001 14:55 EDT
- Calling EJB from JSP by Stephen Davies on April 05 2001 21:56 EDT
- Calling EJB from JSP by Stephen Davies on April 05 2001 10:03 EDT
- Calling EJB from JSP by Stephen Davies on April 05 2001 21:56 EDT
- Calling EJB from JSP by Tony Brookes on April 10 2001 23:47 EDT
-
Calling EJB from JSP[ Go to top ]
- Posted by: karthik sa
- Posted on: April 05 2001 12:15 EDT
- in response to ramki reddy
hi,
just comment ur system.out.println inside the catch block..or use only e.printstackTrace()..it will print out the errors..else use e.toString() inside syate.out.println..it will work.. -
Calling EJB from JSP[ Go to top ]
- Posted by: Kapil Israni
- Posted on: April 05 2001 12:22 EDT
- in response to ramki reddy
lookin at ur code, it seems u r not passin the correct parameters while constructing the InitialContext object. the initial context needs to know server, port, JNDI implemention class which will actually do the look up for u.
all tho this entirely depends on ur EJB server u r using -
Calling EJB from JSP[ Go to top ]
- Posted by: gautam gupta
- Posted on: April 05 2001 14:55 EDT
- in response to ramki reddy
Hi,
Are you passing the right environment variable while getting the initial context?
Context ctx = new InitialContext(ENV) ...
gautam -
Calling EJB from JSP[ Go to top ]
- Posted by: Stephen Davies
- Posted on: April 05 2001 21:56 EDT
- in response to gautam gupta
Actually, when code is running inside Weblogic you do not need to specify any environment to create the initial context. That means that EJBs, servlets and JSPs can invoke the InitialContext constructor without parameters.
e.g. Context ctx = new InitialContext();
The original problem is a compile error. Modify the code to:
try {
// create context
// lookup home & create object
// use object
}
catch(Exception e) {
e.printStackTrace();
}
This will fix the compile error and let you progress.
-
Calling EJB from JSP[ Go to top ]
- Posted by: Stephen Davies
- Posted on: April 05 2001 22:03 EDT
- in response to Stephen Davies
BTW, don't forget to include the package containing the home & remote interfaces in your JSP.
e.g. <%@ page import="my.package.name" %>
-
Calling EJB from JSP[ Go to top ]
- Posted by: Tony Brookes
- Posted on: April 10 2001 23:47 EDT
- in response to ramki reddy
If using WebLogic ever taught me one thing it's this.
NEVER trust the compile time error message in the browser to help you solve the problem.
WebLogic will:
1) Get the line number in the JSP wrong, with monotonous regularity.
2) Provide the REAL compile error in weblogic.log. This is the out put of the javac command and will actually tell you the problem.
A two hour period of tearing my hair out before I looked at the log was as much convincing as I needed. :-)
Basically, read the logs, they are much more helpful.
Chz
Tony