javax.persistence.* not found

1,121 views
Skip to first unread message

Kristanto Oetomo

unread,
Feb 5, 2009, 3:42:50 PM2/5/09
to java-ee-j2ee-progr...@googlegroups.com
Hi

I have a problem compiling bookstore1 sample in the j2ee tutorial. Below is the error message:

Compiling 11 source files to D:\Experiment\JEE\javaeetutorial5\examples\web\bookstore\build\classes
D:\Experiment\JEE\javaeetutorial5\examples\web\bookstore\src\com\sun\bookstore\database\Book.java:13: package javax.persistence does not exist
import javax.persistence.Entity;
D:\Experiment\JEE\javaeetutorial5\examples\web\bookstore\src\com\sun\bookstore\database\Book.java:14: package javax.persistence does not exist
import javax.persistence.Id;
D:\Experiment\JEE\javaeetutorial5\examples\web\bookstore\src\com\sun\bookstore\database\Book.java:15: package javax.persistence does not exist
import javax.persistence.Table;
D:\Experiment\JEE\javaeetutorial5\examples\web\bookstore\src\com\sun\bookstore\database\Book.java:18: cannot find symbol
symbol: class Entity
@Entity
D:\Experiment\JEE\javaeetutorial5\examples\web\bookstore\src\com\sun\bookstore\database\Book.java:19: cannot find symbol
symbol: class Table
@Table(name = "WEB_BOOKSTORE_BOOKS")
D:\Experiment\JEE\javaeetutorial5\examples\web\bookstore\src\com\sun\bookstore\database\Book.java:55: cannot find symbol
symbol  : class Id
location: class com.sun.bookstore.database.Book
    @Id
6 errors
BUILD FAILED (total time: 3 seconds)


I have tried to add toplink library, and populate the database, but still fail to build successfully. Any help appreciated.

Cheers
Kris

Kerry Randolph

unread,
Feb 5, 2009, 4:58:11 PM2/5/09
to kristanto....@gmail.com, java-ee-j2ee-progr...@googlegroups.com
I had the same error when using JBoss as server in Netbeans.
If using Glassfish server I didn't get the error.

Kristanto Oetomo

unread,
Feb 5, 2009, 5:25:51 PM2/5/09
to Kerry Randolph, java-ee-j2ee-progr...@googlegroups.com
Hi

It works now. I read this solution on a forum:


It seems that "bookstore1" project (web application), is importing the "dist/bookstore.jar" from another project (persistence unit?). In this case, NetBeans will also try to recompile the project's dependencies (other projects that may also require "TopLink Essential" library in the compiler's CLASSPATH).

I think you should open the other project (manually or right click the web project, and select "open required projects" option), and edit its properties to also add the "TopLink Essentials" library to the compile-time libraries (in the "libraries" category).

Cheers
Kris
Reply all
Reply to author
Forward
0 new messages