The javax.persistence package does not exist even though Netbeans adds the Eclipselink module

Question with two parts:

Part One: Which JAR is required? Does javax.persistence-2.0.0.jar have the required classes, in particular javax.persistence. *?

enter image description here

stack trace as such:

init: deps-jar: Created dir: /home/thufir/NetBeansProjects/JavaApplication12/build Updating property file: /home/thufir/NetBeansProjects/JavaApplication12/build/built-jar.properties Created dir: /home/thufir/NetBeansProjects/JavaApplication12/build/classes Created dir: /home/thufir/NetBeansProjects/JavaApplication12/build/classes/META-INF Copying 1 file to /home/thufir/NetBeansProjects/JavaApplication12/build/classes/META-INF Created dir: /home/thufir/NetBeansProjects/JavaApplication12/build/empty Created dir: /home/thufir/NetBeansProjects/JavaApplication12/build/generated-sources/ap-source-output Compiling 2 source files to /home/thufir/NetBeansProjects/JavaApplication12/build/classes /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:8: error: package javax.persistence does not exist import javax.persistence.*; /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:15: error: cannot find symbol @Entity symbol: class Entity /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:16: error: cannot find symbol @Table(name = "fud30_groups", catalog = "fudforum", schema = "") symbol: class Table /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:18: error: cannot find symbol @NamedQueries({ symbol: class NamedQueries /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:28: error: cannot find symbol @Id symbol: class Id location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:29: error: cannot find symbol @GeneratedValue(strategy = GenerationType.IDENTITY) symbol: class GeneratedValue location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:30: error: cannot find symbol @Basic(optional = false) symbol: class Basic location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:31: error: cannot find symbol @Column(name = "id") symbol: class Column location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:33: error: cannot find symbol @Basic(optional = false) symbol: class Basic location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:34: error: cannot find symbol @Column(name = "name") symbol: class Column location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:36: error: cannot find symbol @Basic(optional = false) symbol: class Basic location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:37: error: cannot find symbol @Column(name = "inherit_id") symbol: class Column location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:39: error: cannot find symbol @Basic(optional = false) symbol: class Basic location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:40: error: cannot find symbol @Column(name = "forum_id") symbol: class Column location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:42: error: cannot find symbol @Basic(optional = false) symbol: class Basic location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:43: error: cannot find symbol @Column(name = "groups_opt") symbol: class Column location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:45: error: cannot find symbol @Basic(optional = false) symbol: class Basic location: class Fud30Groups /home/thufir/NetBeansProjects/JavaApplication12/src/javaapplication12/Fud30Groups.java:46: error: cannot find symbol @Column(name = "groups_opti") symbol: class Column location: class Fud30Groups 18 errors /home/thufir/NetBeansProjects/JavaApplication12/nbproject/build-impl.xml:605: The following error occurred while executing this line: /home/thufir/NetBeansProjects/JavaApplication12/nbproject/build-impl.xml:246: Compile failed; see the compiler error output for details. BUILD FAILED (total time: 0 seconds) 

Second part of the question: what is (potentially) wrong with Netbeans? Until yesterday, it seemed like the IDE would automatically add the required classes to the class path when, as here, it generates the @Entity class from an existing database. In this particular case, Netbeans added a JAR.

However, since they are added externally to the project, there is no lib folder. Unfortunately, I'm not good enough yet to really dive into build.xml to see what happens, but from the Library Manager it looks like this:

 thufir@dur :~$ tree netbeans-7.1.1/java/modules/ext/eclipselink/ netbeans-7.1.1/java/modules/ext/eclipselink/ β”œβ”€β”€ eclipselink-2.3.0.jar β”œβ”€β”€ eclipselink-jpa-modelgen-2.3.0.jar β”œβ”€β”€ javax.persistence-2.0.jar └── org.eclipse.persistence.jpa.jpql_1.0.0.jar 0 directories, 4 files thufir@dur :~$ 

It seems that my recollection of the fact that in the past additional steps were required to load any JAR did not suit me. Can an incorrect or corrupt setting in Netbeans?

+4
source share
1 answer

Lucky number 13, Netbeans project 13, which is as identical as possible to Netbeans project 12, builds perfectly (well, not very well, but it does):

clean and build:

 init: deps-clean: Updating property file: /home/thufir/NetBeansProjects/JavaApplication13/build/built-clean.properties Deleting directory /home/thufir/NetBeansProjects/JavaApplication13/build clean: init: deps-jar: Created dir: /home/thufir/NetBeansProjects/JavaApplication13/build Updating property file: /home/thufir/NetBeansProjects/JavaApplication13/build/built-jar.properties Created dir: /home/thufir/NetBeansProjects/JavaApplication13/build/classes Created dir: /home/thufir/NetBeansProjects/JavaApplication13/build/classes/META-INF Copying 1 file to /home/thufir/NetBeansProjects/JavaApplication13/build/classes/META-INF Created dir: /home/thufir/NetBeansProjects/JavaApplication13/build/empty Created dir: /home/thufir/NetBeansProjects/JavaApplication13/build/generated-sources/ap-source-output Compiling 2 source files to /home/thufir/NetBeansProjects/JavaApplication13/build/classes warning: Supported source version 'RELEASE_6' from annotation processor 'org.eclipse.persistence.internal.jpa.modelgen.CanonicalModelProcessor' less than -source '1.7' Note: Creating non-static metadata factory ... Note: Found Option : eclipselink.canonicalmodel.use_static_factory, with value: false Note: Optional file was not found: META-INF/orm.xml continuing with generation. Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation. Note: Found Option : eclipselink.canonicalmodel.use_static_factory, with value: false Note: Optional file was not found: META-INF/orm.xml continuing with generation. Note: Optional file was not found: META-INF/eclipselink-orm.xml continuing with generation. warning: The following options were not recognized by any processor: '[eclipselink.canonicalmodel.use_static_factory]' 1 warning Copying 2 files to /home/thufir/NetBeansProjects/JavaApplication13/build/classes compile: BUILD SUCCESSFUL (total time: 6 seconds) 

Two projects:

 thufir@dur :~/NetBeansProjects$ thufir@dur :~/NetBeansProjects$ tree JavaApplication12 JavaApplication12 β”œβ”€β”€ build β”‚  β”œβ”€β”€ built-jar.properties β”‚  β”œβ”€β”€ classes β”‚  β”‚  └── META-INF β”‚  β”‚  └── persistence.xml β”‚  β”œβ”€β”€ empty β”‚  └── generated-sources β”‚  └── ap-source-output β”œβ”€β”€ build.xml β”œβ”€β”€ manifest.mf β”œβ”€β”€ nbproject β”‚  β”œβ”€β”€ build-impl.xml β”‚  β”œβ”€β”€ genfiles.properties β”‚  β”œβ”€β”€ private β”‚  β”‚  └── private.properties β”‚  β”œβ”€β”€ project.properties β”‚  └── project.xml └── src β”œβ”€β”€ javaapplication12 β”‚  β”œβ”€β”€ Fud30Groups.java β”‚  └── JavaApplication12.java └── META-INF └── persistence.xml 11 directories, 12 files thufir@dur :~/NetBeansProjects$ thufir@dur :~/NetBeansProjects$ tree JavaApplication13 JavaApplication13 β”œβ”€β”€ build β”‚  β”œβ”€β”€ built-jar.properties β”‚  β”œβ”€β”€ classes β”‚  β”‚  β”œβ”€β”€ javaapplication13 β”‚  β”‚  β”‚  β”œβ”€β”€ Fud30Groups_.class β”‚  β”‚  β”‚  β”œβ”€β”€ Fud30Groups.class β”‚  β”‚  β”‚  β”œβ”€β”€ Fud30Groups.java β”‚  β”‚  β”‚  β”œβ”€β”€ JavaApplication13.class β”‚  β”‚  β”‚  └── JavaApplication13.java β”‚  β”‚  └── META-INF β”‚  β”‚  └── persistence.xml β”‚  β”œβ”€β”€ empty β”‚  └── generated-sources β”‚  └── ap-source-output β”‚  └── javaapplication13 β”‚  └── Fud30Groups_.java β”œβ”€β”€ build.xml β”œβ”€β”€ lib β”‚  β”œβ”€β”€ CopyLibs β”‚  β”‚  └── org-netbeans-modules-java-j2seproject-copylibstask.jar β”‚  β”œβ”€β”€ eclipselink β”‚  β”‚  β”œβ”€β”€ eclipselink-2.3.0.jar β”‚  β”‚  β”œβ”€β”€ javax.persistence-2.0.jar β”‚  β”‚  └── org.eclipse.persistence.jpa.jpql_1.0.0.jar β”‚  β”œβ”€β”€ eclipselinkmodelgen β”‚  β”‚  └── eclipselink-jpa-modelgen-2.3.0.jar β”‚  └── nblibraries.properties β”œβ”€β”€ manifest.mf β”œβ”€β”€ nbproject β”‚  β”œβ”€β”€ build-impl.xml β”‚  β”œβ”€β”€ genfiles.properties β”‚  β”œβ”€β”€ private β”‚  β”‚  β”œβ”€β”€ config.properties β”‚  β”‚  └── private.properties β”‚  β”œβ”€β”€ project.properties β”‚  └── project.xml └── src β”œβ”€β”€ javaapplication13 β”‚  β”œβ”€β”€ Fud30Groups.java β”‚  └── JavaApplication13.java └── META-INF └── persistence.xml 17 directories, 25 files thufir@dur :~/NetBeansProjects$ 

The difference, apparently, is that project 13 has. / lib folder, and project 12 uses an "external" JAR.

Is it possible that my Netbeans installation is corrupted or incorrect, or I have the wrong approach to project 12? I would like to do this using external JARs, as project 12 does, because various functions, such as the library manager, work better.

0
source

Source: https://habr.com/ru/post/1411274/


All Articles