Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Jsp and EJB

 
Aparna D
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write a simple Session Bean. I have copied the bean ,home and interface class files into WEB-INF/classes/ of the web-app.
My JSP file looks like
-------------------------------------------
<%@ page import="javax.ejb.*, java.math.*, javax.naming.*, javax.rmi.PortableRemoteObject, java.rmi.RemoteException" %>
<%!
private aparnaSesion aparnasession = null;
public void jspInit() {
try {
InitialContext ic = new InitialContext();
Object objRef = ic.lookup("java:comp/env/ejb/aparnaSession");
aparnaSessionHome home = (aparnaSessionHome)PortableRemoteObject.narrow(objRef, aparnaSessionHome.class);
aparnasession = home.create();
} catch (RemoteException ex) {
System.out.println("Couldn't create aparnasession bean."+ ex.getMessage());
} catch (CreateException ex) {
System.out.println("Couldn't create aparnasession bean."+ ex.getMessage());
} catch (NamingException ex) {
System.out.println("Unable to lookup home: "+ "aparnasession "+ ex.getMessage());
}
}
public void jspDestroy() {
aparnasession = null;
}
%>
------------------------------------
On running weblogic gives error as unable to resolve aparnaSession ,aparnaSessionHome .
How to make this compile ?
Thanks
Aparna
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see you importing the package for your ejb in the JSP. That leads me to make 1 of 2 conclusions.
1. You forgot to import the package. Obviously the solution is to import the package or fully qualify your class names.
2. The ejb is in the default package. The problem here is that the JSP Specification does not allow access to classes in the default package from within a JSP. The solution is to move your ejb into a named package and then import that package in your JSP.
FYI, in your post you misspelled aparnaSession as aparnaSesion in the JSP. I am assuming is was a simple typo. Otherwise, you will need to correct this as well. Also, try to keep your class names capitalized.
[ September 25, 2002: Message edited by: Chris Mathews ]
 
Aparna D
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
If the structure of my the application in expanded form is as below what what should I include ?
Test
index.jsp
META-INF
aparnaSessionHome.class
aparnaSessionBean.class
aparnaSession.class
WEB-INF
web.xml (in WEB-INF)
classes (in WEB-INF)
aparnaSessionHome.class (in classes)
aparnaSessionBean.class (in classes)
aparnaSession.class (in classes)

As you see I am not using any package here. What should I include?

Thanks
[ September 26, 2002: Message edited by: Aparna D ]
 
Beware the other head of science - it bites! Nibble on this message:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!