NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

I can't use Entity Class (JPA) in Netbeans7.0 .

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
mmc01



Joined: 08 Jun 2009
Posts: 21

PostPosted: Thu Aug 18, 2011 4:22 pm    Post subject: I can't use Entity Class (JPA) in Netbeans7.0 . Reply with quote

I tried to use Entity Class (JPA) in Netbeans7.0 but It doesn't work.

1. I create Enterprise Application name BookApp.

Create Entity Class


2. I right click at BookApp-ejb and select Entity Classes fron Database.
3. In dialog New Entity Class from Database I insert JNDI Name:jdbc/test for connect to test database and select table books. After that ,I click Next for insert Package: entity and click Finish.

Create Session Bean

4. I right click at BookApp-ejb and select Session Beans for Entity Classes and click Next.
5. I click Add All >> and click Next.
6. I insert Package: sb , create Interface:Local and click Finish.

Create Web Application

7. I right click BookApp-war and select HTML insert HTML File Name :findBook and click Finish.
8. I put this code in HTML file
Code:
<form action="ShowBook" method="POST">
<h2>Search Book from ISBN </h2>
Enter ISBN <input type="text" name="isbn" value="" />
<input type="submit" value="Find" />
</form>

9. I right click BookApp-war and select Servlet insert File Name: ShowBook, Package: servlets and click Finish.
10. I right click in editor and select Insert Code… > Call Enterprise Bean…
11. In dialog Call Enterprise Bean I select BooksFacade and click OK.
12. I uncomment html and insert this code between out.println("<body>");
Code:
String isbn = request.getParameter("isbn");
Books book = booksFacade.find(isbn);
out.println("Title: " + book.getTitle()+ "<BR>");
out.println("Author: " + book.getAuthor() + "<BR>");
out.println("Price: " + book.getPrice() + "<BR>");

13. I clean and build BookApp.
14. I run BookApp.
15. I go to this URL http://localhost:8080/BookApp-war/findBook.html and insert isbn from books table but when I click Find button It show error like this.

Quote:
HTTP Status 500 -

type Exception report

message

descriptionThe server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.ejb.EJBException


I don't know what I mistake. I delete Session Beans and create Session beans again but no create Interface. when I run BookApp it show same error. I'm new for EJB. please help me.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo