简体   繁体   中英

Glassfish 3.1.2 doesn't contain javax.persistence jar

I'm trying to work with Eclipse Mars 2 and Glassfish 3.1.2, but when I use EclipseLink 2.1 to create the entitites from tables, javax.persistence is not found in the buildpath.

Is this the normal behaviour?

  1. I created the Oracle db connection with eclipse
  2. I installed JEE 6 SDK with Glassfish 3
  3. I started the glassfish server and configured the data source and connection pool.
  4. I created a JPA project and created the entities from the db connection tables.

Something I find curious is that the jee.jar that is inside glassfish/lib only contains a pom.xml

Isn't Glassfish supposed to contain all the jars needed to develop with the jee standard?

Is my project meant to be a Maven project in order to automatically download this jars? Could I fix this by configuring my project as a Maven project?

Isn't Glassfish supposed to contain all the jars needed to develop with the jee standard?

Yes, and it contains all the jars needed but in an indirect way. Even though it is a single jar file with only one file, namely, MANIFEST.MF and a directory maven which contains the pom file you mentioned.

But if you open the MANIFEST.MF file you'll see that it is pointing to a lot of jar files in the Class-Path: entry which you need to be able develop JavaEE applications.

So everything is there and you only need to add this file into your dependency to be able to compile your JavaEE (Servlets, JSF, EJB, JPA, ...) classes and deploy on the server. But this (javaee.jar) must be a compile time dependency, ie, should not be packaged with your application as the jars are already contained in the server.

Is my project meant to be a Maven project in order to automatically download this jars?

No. Your project can be but should not be a maven project. Let us say, for example, you have an Eclipse project where you want to develop an EJB application. Just right click on the project

  • go to the Properties -> Build Path page and change to Libraries tab

  • click on Add External Jars ...

  • go to the Glassfish lib directory and add the javaee.jar , and you are done.
  • now you can use all the JavaEE annotations and classes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM