Reputation: 59
New to EJB, please help:
To verify my EJB on local, I tried create a test.jsp that calls the EJB like this:
<%@ page import="com.web.ejb.service.ContentInfo" %>
<% ContentInfo ci = ContentInfo.getContentById("123"); %>
When run the jsp, got error "Only a type can be imported. com.web.ejb.service.ContentInfo resolves to a package".
Then I replaced the import with
<jsp:useBean id="ContentInfo" class="com.web.ejb.service.ContentInfo" />
but got "ContentInfo cannot be resolved to a type."
Thanks for your help.
Upvotes: 0
Views: 587
Reputation: 1446
First check whether the class name is correct and it is available in the above mentioned package. After that try this:
<%@ page import="<package>.<YourBusinessInterface>, javax.naming.*"%>
<%!
try {
InitialContext ic = new InitialContext();
<YourBusinessInterface> obj = (<YourBusinessInterface>)
ic.lookup(<YourBusinessInterface>.class.getName());
} catch (Exception ex) {
// exception code here
}
%>
<html>
<body>
<% obj.callBusinessMethod(); %>
</body>
</html>
This link http://docs.oracle.com/javaee/5/tutorial/doc/bnbnp.html might help you. :)
Upvotes: 0
Reputation: 11669
From the error message, seems like com.web.ejb.service.ContentInfo
is not your class name. Maybe you made a typo ?
If you want to test an EJB more thoroughly, you can use OpenEJB to replicate the functionalities of an EJB server, in case of units tests for example.
Upvotes: 1