I'm in the midst of setting up a JavaFX project with Datanucleu + JDO + JDOQL. I've got the first two parts working without issue, I've got a connection to the database, I can read and write no issues. When I go to add the JDOQL step, along with the maven plugin the compile fails with the following error.
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project projectName: Fatal error compiling: java.lang.NoClassDefFoundError: javax/jdo/annotations/PersistenceCapable: javax.jdo.annotations.PersistenceCapable -> [Help 1]
I'm running OpenJDK 13, JavaFX 14 and the latest version of most datanucleus plugins/dependencies. I've got the persistence XML configured and that picks up alright, I'm setting properties inside that file as well.
I'm at a complete loss as to what the issue might be, I've compared my code to the examples and it seems basically identical. It seems like it can't find the dependencies for the JDO annotations, which doesn't make sense because it worked before adding this plugin. At this point, I'm thinking it is possibly a bug in the latest version(I have tried a few of the older versions as well)
Any guidance would be great!
Here is my POM.XML
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.redacted</groupId>
<artifactId>redacted</artifactId>
<version>1.0.0-SNAPSHOT</version>
<properties>
<config.files.dir>${basedir}/src/main/resources</config.files.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<openjfx.Version>14</openjfx.Version>
<openjfx.Maven.Version>0.0.4</openjfx.Maven.Version>
</properties>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>[5.1.6, 5.9)</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>5.2.3</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>[5.1.6, 5.9)</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>javax.jdo</artifactId>
<version>3.2.0-m13</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-jdo-query</artifactId>
<version>[5.0.9, )</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>[1.2.17, )</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.30.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${openjfx.Version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${openjfx.Version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testfx</groupId>
<artifactId>testfx-junit5</artifactId>
<version>4.0.16-alpha</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.13.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-maven-plugin</artifactId>
<version>5.2.1</version>
<configuration>
<persistenceUnitName>CentralUnit</persistenceUnitName>
<api>JDO</api>
<!-- <props>${config.files.dir}/datanucleus.properties</props>-->
<log4jConfiguration>${config.files.dir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.redacted.App.Main</mainClass>
<systemProperties>
<systemProperty>
<key>log4j.configuration</key>
<value>file:${config.files.dir}/log4j.properties</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
<compilerArgument>-AqueryMode=FIELD</compilerArgument>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>${basedir}</directory>
<includes>
<include>*.log</include>
<include>*.ods</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${openjfx.Maven.Version}</version>
<configuration>
<mainClass>es.deusto.App</mainClass>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
</project>
My persistnce.XML
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd" version="2.1">
<!-- JDO tutorial "unit" -->
<persistence-unit name="CentralUnit">
<class>es.deusto.User</class>
<exclude-unlisted-classes/>
<properties>
<property name="javax.jdo.option.ConnectionURL" value="jdbc:sqlite:src/main/resources/database.db"/>
<property name="javax.jdo.PersistenceManagerFactoryClass" value="org.datanucleus.api.jdo.JDOPersistenceManagerFactory"/>
<property name="datanucleus.schema.autoCreateAll" value="true"/>
<property name="datanucleus.validateTables" value="true"/>
<property name="datanucleus.validateConstraints" value="true"/>
<property name="datanucleus.metadata.validate" value="false"/>
</properties>
</persistence-unit>
</persistence>
My User class
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import java.util.Date;
@PersistenceCapable
//@Inheritance(strategy= InheritanceStrategy.NEW_TABLE)
public class User {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.INCREMENT)
protected long id;
protected String firstName;
protected String lastName;
protected String notes;
protected String phoneNumber;
protected Date birthDate;
protected Date dateJoined;
protected Date createdAt;
protected Date updatedAt;
protected User(){};
//Omitted all the getters and setters```