• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB 3.0 and jsp

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have created an EJB 3.0 stateless bean and a WebContent project in Eclipse Ganymede and deployed them successfully to a Glassfish server. When I try to go to the url for which it was deployed my jsp is unable to compile because it states that my ejb package doesn't exist. Where am I missing my reference to my package for my stateless bean??? should my ejb.xml so a reference to my package ejb.mybean???

thanks for any help.
ajl
 
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well if you are using annotations, you don't need to use any XML files here. And please provide the client code you used so we can figure out your problem more accurately. For best practice, it is recommended to use an intermediate servlet between the JSP and EJB, instead of directly accessing the business tier EJB from a JSP.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<%@ page import="javax.ejb.*, javax.naming.*"%>
<%@ page import="ejb.*"%>
<%@ page import="java.util.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Deal</title>

</head>
<body bgcolor="blue">

<p><font size="10" color="Yellow">
Changes
</font></p>


<%!
private CardDeckRemote cd;

public void jspInit() {
try {

InitialContext ic = new InitialContext();
cd = (CardDeckRemote) ic.lookup("CardDeck/remote");
} catch (Exception ex) {
System.out.println("Error:"+
ex.getMessage());
}
}

public void jspDestroy() {
cd = null;
}
%>

<p><font size="10" color="red">
<%
String result;
Card c = new Card();
Vector <Card> v = cd.getHand();
for (int x=0;x<5;x++)
c = (Card)v.elementAt(x);
result = c.printCard();
%>
<%=result%>

</font></p>

</body>

</html>
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is "CardDeck/remote"? Have you tested this with the @EJB annotation? Since these annotations are new to EJB 3.0, it is better to use them, if you are working with a EJB 3.0 container.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the JNDI version would be simpler to begin. I had planned to move to the annotation after I got the JNDI working. I will try the annotation. have you gotten a jsp connecting to an ejb 3 object using glassfish? what about archiving? is it necessary?
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't find an example of annotation inside of a jsp? can you post the code for this?

thanks
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need to archive explicitly here. The problem may be with the JNDI name that you used for the lookup. Please check it in your ejb-jar descriptor. I did never attempt to access an EJB object directly from a JSP, since it is not a good practice. As I said before, you should use an intermediate servlet to implement your connection logic.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you point me to some code for making the code in the jsp? <%@EJB%> then just reference my remote session bean object.method??? I think I am missing something?
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

is sufficient.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the exact same error















<%@ page import="javax.ejb.*, javax.naming.*"%>
<%@ page import="ejb.*"%>
<%@ page import="java.util.*"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Deal</title>

</head>
<body bgcolor="blue">

<p><font size="10" color="Yellow">
Changes
</font></p>


<%!
@EJB
private CardDeckRemote cd;

public void jspInit() {
try {

//InitialContext ic = new InitialContext();
// cd = (CardDeckRemote) ic.lookup("CardDeck/remote");
} catch (Exception ex) {
System.out.println("Error:"+
ex.getMessage());
}
}

public void jspDestroy() {
cd = null;
}
%>

<p><font size="10" color="red">
<%
String result;
Card c = new Card();
Vector <Card> v = cd.getHand();
for (int x=0;x<5;x++)
c = (Card)v.elementAt(x);
result = c.printCard();
%>
<%=result%>

</font></p>

</body>

</html>
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You said that it is a compile time error, so which statement gives that error?
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
run time error



org.apache.jasper.JasperException: PWC6033: Unable to compile class for JSP

PWC6199: Generated servlet error:
string:///index_jsp.java:8: package ejb does not exist

PWC6197: An error occurred at line: 22 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:16: cannot find symbol
symbol : class CardDeckRemote
location: class org.apache.jsp.index_jsp

PWC6197: An error occurred at line: 43 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:96: cannot find symbol
symbol : class Card
location: class org.apache.jsp.index_jsp

PWC6197: An error occurred at line: 43 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:96: cannot find symbol
symbol : class Card
location: class org.apache.jsp.index_jsp

PWC6197: An error occurred at line: 43 in the jsp file: /index.jsp
PWC6199: Generated servlet error:
string:///index_jsp.java:97: cannot find symbol
symbol : class Card
location: class org.apache.jsp.index_jsp
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is a compile time error, JasperException is thrown when the container attempt to 'compile' your JSP file. It says that the package ejb is not exist. Are you sure that you appropriately packaged your EJB components to the 'ejb' package?
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are correct. I wasn't thinking jsp compile. my classes are in the ejb package which I declared when creating the classes. is there a project file I should be looking at in order to see if I have mapped something incorrectly?




 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[quote=Adam LaFaye]you are correct. I wasn't thinking jsp compile. my classes are in the ejb package which I declared when creating the classes. is there a project file I should be looking at in order to see if I have mapped something incorrectly?


i have two projects created in eclipse. one is the dynamic web page the other an ejb project.
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Adam LaFaye wrote:is there a project file I should be looking at in order to see if I have mapped something incorrectly?


Duhhh! The question now turns into an eclipse related question. Please feel kind to post a new topic on our IDE Forum, by explicitly specifying your eclipse problem.
 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mentioned in my first posting that I was using eclipse with a dynamic web content project. I am guessing you haven't worked with eclipse???
 
Devaka Cooray
Sheriff
Posts: 7134
1360
IntelliJ IDE jQuery Eclipse IDE Postgres Database Tomcat Server Chrome Google App Engine
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I don't. And this forum is for EJB and Java EE related questions only. Since we recognized that this problem is about Eclipse, and it is NOT about general EJB, it is good to post a more specific topic on the IDE forum.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Adam,

check your gmail account, I sent an example.

 
Adam LaFaye
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I finally got my ejb 3 / struts / jsp test application to work using glassfish. If you call working by putting my ejb.jar file into the jre/lib directory and deploying my web client as a war!!!

so how will I get my ejb code to work on a remote server under this deployment plan??? can someone tell me if they have deployed an ejb module on a separate server from their web client???

also as a side note Java Server Faces are for Secretary applications not for real code work right???


cheers

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic