jOOQ can't auto generate classes - maven

I'm trying to auto generate the jOOQ java code for my MySql database, but it's not working. I'm using jOOQ for my JSP project from maven.
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyHomeProject</groupId>
<artifactId>MyHomeProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>13</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<executions>
<execution>
<id>generate-mysql</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<jdbc>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://localhost:3306/myprojectdb?useSSL=false&serverTimezone=UTC</url>
<user>webuser</user>
<password>webuserP#$$*oR6</password>
</jdbc>
<generator>
<database>
<name>org.jooq.meta.mysql.MySQLDatabase</name>
<includes>.*</includes>
<excludes></excludes>
<inputSchema>public</inputSchema>
</database>
<target>
<packageName>com.myproject.home.jooq</packageName>
<directory>${basedir}\src</directory>
</target>
</generator>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
<!-- jOOQ -->
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.13.2</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>3.13.2</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>3.13.2</version>
</dependency>
<!-- Other dependencies here -->
<!-- ... -->
<!-- ... -->
<!-- ... -->
</dependencies>
</project>
I'm running this project on eclipse with Tomcat. When I want to run the web application, I clean the project, then Project>properties>Deployment Assembly>Add>Java Build Path Entries>Maven Dependencies.
When I run the project, no java code for database is generated.
As it says in the documentation, since I'm using maven with jOOQ, I can auto generate the JAVA code without need to use cli. And without the need to create a library.xml file.
My issue is that jOOQ doesn't auto generate JAVA files with this pom.xml file. What am I doing wrong? Is there another configurations I need to make?

You specified:
<inputSchema>public</inputSchema>
MySQL doesn't have such a schema by default. Please use the schema of your actual database instead (case sensitive), or omit the inputSchema to generate code for all schemas.

Related

IntelliJ not running jOOQ codegen plugin on build of maven imported project

I have a maven multiple module project and I use IntelliJ for development (importing the POM). The project structure is:
project
entities-module (JPA entities)
query-module (jOOP codegen maven plugin using JPADatabase)
app-module(app logic module)
The problem I'm having is that IntelliJ is not running jOOQ codegen plugin (I'm using Intellij build logic, not delegating to Maven goals).
What I'm doing right now is to do a build from Maven, to force jOOQ code gen and then work from IntelliJ. But this is error prone and I would like to avoid it.
Following the corresponding snippets of my POM:
pom.xml/project/build/pluginManagement/plugins:
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>${spring-boot.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta-extensions-hibernate</artifactId>
<version>${jooq.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>jooq-codegen</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<generator>
<database>
<name>org.jooq.meta.extensions.jpa.JPADatabase</name>
<properties>
</properties>
</database>
</generator>
</configuration>
</plugin>
pom.xml/project/build/plugins:
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<dependencies>
<dependency>
<groupId>org.foo</groupId>
<artifactId>foo-lib</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<configuration>
<generator>
<database>
<properties>
<property>
<key>packages</key>
<value>
org.foo.data
</value>
</property>
</properties>
</database>
<target>
<packageName>org.foo.data</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</plugin>

Appengine maven plugin exclude node_modules

In my GoogleAppEngine project I currently installed a lot of node-modules that are now placed in my project at the location src/main/webapp/node_modules. Now when I try to test that project locally with the appengine-maven-plugin (mvn appengine:run), it takes up to 10 Minutes to create that project. I figured out, that it takes so much time to copy all files from the node_modules folder to the target folder.
Since I only need these files for developing, I tried to skip this folder when building the project. But I'm not that sure where to configure that behavior. In my appengine-web.xml I already excludes that folder from static-files and resource-files:
<static-files>
<include path="/build/build/favicon.ico" />
<include path="/build/build/node_modules/**" />
<include path="/build/build/images/**" />
<include path="/build/build/src/**" />
<include path="/build/build/robots.txt" />
<include path="/build/build/sitemap.xml" />
<exclude path="/node_modules/**/*" />
</static-files>
<resource-files>
<include path="/build/build/index.html" />
<exclude path="/node_modules/**/*" />
</resource-files>
Where may I exclude that folder from beeing copied to target/backend-1.0-snapshot?
I'm using the appengine standard environment (1.9.63) with the appengine-maven-plugin (1.3.2)
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<groupId>com.xxx.xxx</groupId>
<artifactId>backend</artifactId>
<properties>
<endpoints.framework.version>2.0.14</endpoints.framework.version>
<endpoints.management.version>1.0.4</endpoints.management.version>
<endpoints.project.id>XXX PROJECT XXX</endpoints.project.id>
<appengine.maven.plugin.version>1.3.2</appengine.maven.plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
</properties>
<prerequisites>
<maven>3.5.0</maven>
</prerequisites>
<dependencies>
<!-- Compile/runtime dependencies -->
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-framework</artifactId>
<version>${endpoints.framework.version}</version>
</dependency>
<dependency>
<groupId>com.google.endpoints</groupId>
<artifactId>endpoints-management-control-appengine-all</artifactId>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>1.9.63</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies>
<build>
<!-- for hot reload of the web application -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.maven.plugin.version}</version>
<configuration>
<deploy.project>XXX PROJECT XXX</deploy.project>
<deploy.version>XXX VERSION XXX</deploy.version>
<deploy.stopPreviousVersion>false</deploy.stopPreviousVersion>
<deploy.promote>false</deploy.promote>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>endpoints-framework-maven-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<!-- plugin configuration -->
<hostname>${endpoints.project.id}.appspot.com</hostname>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I just found out that I have to add the maven-war-plugin with the warSourceExcludes-configuration to the build part of the pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<warSourceExcludes>node_modules/**</warSourceExcludes>
</configuration>
</plugin>
That way the folder won't be copied to the exploded war folder.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<packagingExcludes>assets/node_modules/**</packagingExcludes>
</configuration>
</plugin>
Where assets is a folder inside of src/main/webapp directory. When you run mvn install , it will create a war and source directory in your target folder. Although node_modules will be visible in source directory inside of target but when you extract war file, these will be excluded. You can see this by extracting war file.

External jar found in Maven Web Application but not when being deployed

I recently created a Maven Web Application through Netbeans 7.3, using GlassFish 3.1.2. In this I use an external jar, so I added it in pom.xml:
<dependencies>
...
<dependency>
<groupId>be-fedict-eid-trust-service-client</groupId>
<artifactId>eid-trust-service-client</artifactId>
<version>1.0.1.RC5</version>
</dependency>
...
</dependencies>
It shows up correctly and I can refer it in my Bean. BUT when I deploy the application, I get an error that the class in the jar (which I referred to without problems before) can not be found.
java.lang.NoClassDefFoundError: be/fedict/trust/xkms2/XKMSServiceFactory
Since I'm not that familiar with Maven, I don't know how and where I can fix this. Looking at the generated WAR file, the jar is there correctly. I set addClasspath to true so it is in the Classpath of the Manifest, but this doesn't seem to help.
My libraries are in WEB-INF/lib and my Bean is in WEB-INF/classes.
Any thoughts or general directions to what this problem may be? I found this topic: Spring Web App with Maven dependency - class not found during deploy
but I don't see how I can make it work for me (assuming he found a solution).
Thanks in advance!
My full 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ISB</groupId>
<artifactId>eID</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>eID</name>
<repositories>
<repository>
<id>e-contract</id>
<url>https://www.e-contract.be/maven2</url>
</repository>
</repositories>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>be-fedict-eid-applet</groupId>
<artifactId>eid-applet-shared</artifactId>
<version>1.1.0.RC2</version>
</dependency>
<dependency>
<groupId>be.fedict.eid-applet</groupId>
<artifactId>eid-applet-service</artifactId>
<version>1.1.0.RC2</version>
</dependency>
<dependency>
<groupId>be-fedict-eid-applet</groupId>
<artifactId>eid-applet-service-spi</artifactId>
<version>1.1.0.RC2</version>
</dependency>
<dependency>
<groupId>be-fedict-eid-applet</groupId>
<artifactId>eid-applet-package</artifactId>
<version>1.1.0.RC2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>be-fedict-eid-trust-service-client</groupId>
<artifactId>eid-trust-service-client</artifactId>
<version>1.0.1.RC5</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>copy</id>
<phase>process-resources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>be-fedict-eid-applet</groupId>
<artifactId>eid-applet-package</artifactId>
<version>1.1.0.RC2</version>
<type>jar</type>
<outputDirectory>${project.build.directory}/${project.artifactID}</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I'm not sure it has anything to do with your POM. I suspect it's the libraries used in the target container (Glassfish) -- a classpath issue. Each container does classloading a little differently. This question & answer might give you some ideas. If there are two, different versions of this artifact, one in container, one in your POM, you will have to tell the container which to use. WebLogic uses a weblogic.xml file for this.

Using Liquibase extensions with Maven

I am trying to use Liquibase Oracle extensions from maven-liquibase-plugin but I'm not able to get it working. I have no issue with the same changeLog file from the command line, but in Maven I get the following error message
SEVERE 21/11/11 14:49:liquibase: Error thrown as a SAXException: Unknown Liquibase extension: dropTrigger. Are you missing a jar from your classpath?
The changelog file I'm using
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ora="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet author="PE1926" id="ONCHANGE" runOnChange="true">
<ora:dropTrigger schemaName="" triggerName="TRIGGER_01"/>
<rollback>
<sqlFile path="latest/trg/TRIGGER_01.sql" endDelimiter="$"/>
</rollback>
</changeSet>
Here is a pom.xml extract
[...]
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-oracle</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals><goal>status</goal></goals>
</execution>
</executions>
<configuration>
<changeLogFile>src/main/resources/update.xml</changeLogFile>
<propertyFile>${db-resources.dir}/liquibase.properties</propertyFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>
I've also tried to add liquibase-oracle as plugin dependency but I get the same error message.
Is this the correct way of using Liquibase extensions from Maven? Am I missing something?
Add all liquibase dependencies as plugin dependencies.
I didn't need to add any other dependencies - this did it for me:
<pluginManagement>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>${version.liquibase}</version>
<configuration>
<propertyFileWillOverride>true</propertyFileWillOverride>
<driver>oracle.jdbc.OracleDriver</driver>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
<changeLogFile>liquibase-master-changelog.xml</changeLogFile>
<!-- ensure a liquibase.properties is available in each module that runs liquibase -->
<propertyFile>liquibase.properties</propertyFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>liquibase-oracle</artifactId>
<version>${version.liquibase.ora-ext}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</pluginManagement>

Simplistic using Groovy in Maven

In some maven project I'll try to figure out how can be used Groovy language. For instance, I try to create a directory in validation phase, by using something like that
<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/xsd/maven-4.0.0.xsd">
...
<dependencies>
...
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.5.5</version>
<type>pom</type>
<scope>runtime</scope>
</dependency>
...
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.0</version>
<executions>
<execution>
<id>Project</id>
<phase>validate</phase>
<goals>
<goal>execute</goal>
</goals>
</execution>
</executions>
<configuration>
<source>
final FileTreeBuilder treeBuilder = new FileTreeBuilder(new File('tree'))
def folder = new File( 'sample_dir' )
if(!folder.exists()){
treeBuilder.dir('sample_dir')
}
</source>
</configuration>
</plugin>
...
</plugins>
</build>
But if it using the command mvn compile will be present error
[ERROR] script1.groovy: 3: unable to resolve class FileTreeBuilder
What have I missed and what should be added to make this plugin functional?
https://groovy.github.io/gmaven/groovy-maven-plugin/
Customizing Groovy Version
To customize the version of Groovy the plugin will use, override the org.codehaus.groovy:groovy-all dependency on the plugin definition in the project.
For example to use Groovy 2.0.6 instead of the default:
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.0.6</version>
</dependency>
</dependencies>
</plugin>

Resources