Eclipse/Maven: QueryDSL and SQL Server Issue Using Integrated Security - sql-server

Relevant details for the IDE:
Eclipse 2018-09
m2e 1.9.1.20180912-1601
A few high level details:
I'm using Maven and QueryDSL to generate Data Transfer Objects and Query classes for two databases in SQL Server
The JDBC connection in Maven needs to use integrated security (i.e. no stored passwords/SQL Server database authentication). This requires use of the sqljdbc_auth.dll native library.
This setup largely works, but only for the first Maven -> 'Update Project' after starting Eclipse. Even on the first run of the project update, it appears that something in Maven runs more than once and causes an exception. If I make any schema changes, then I have to Restart Eclipse to successfully update the Maven project. On the first run and subsequent runs I have at least two persistent Maven errors, though they change from first to subsequent runs.
Changing IDEs (ex. Eclipse -> IntelliJ) has a high cost right now and not a good option.
I'm open to using something other than QueryDSL if there is an ORM that works better (note I primarily work in .Net, but have occasional Java projects such as this one).
In summary I have two questions - identified as Question 1 and Question 2 below in bold.
Below is a redacted pom.xml, but includes enough information to reproduce (or identify that it can't be reproduced):
<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>REDACTED</groupId>
<artifactId>REDACTED</artifactId>
<version>REDACTED</version>
<name>REDACTED</name>
<description>REDACTED</description>
<properties>
<querydsl.version>4.2.1</querydsl.version>
<mssql.version>7.0.0.jre8</mssql.version>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.10</source>
<target>1.10</target>
</configuration>
</plugin>
<plugin>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>${querydsl.version}</version>
<executions>
<execution>
<id>database1</id>
<phase>validate</phase>
<configuration>
<jdbcDriver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbcDriver>
<jdbcUrl>jdbc:sqlserver://server:1433;databaseName=database1;integratedSecurity=true;</jdbcUrl>
<packageName>REDACTED.database1</packageName>
<exportBeans>true</exportBeans>
<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
</configuration>
<goals>
<goal>export</goal>
</goals>
</execution>
<execution>
<id>database2</id>
<phase>validate</phase>
<configuration>
<jdbcDriver>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbcDriver>
<jdbcUrl>jdbc:sqlserver://server:1433;databaseName=database2;integratedSecurity=true;</jdbcUrl>
<packageName>REDACTED.database2</packageName>
<exportBeans>true</exportBeans>
<targetFolder>${project.basedir}/target/generated-sources/java</targetFolder>
</configuration>
<goals>
<goal>export</goal>
</goals>
</execution>
<!-- <execution> <goals> <goal>export</goal> </goals> </execution> -->
</executions>
<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-bom</artifactId>
<type>pom</type>
<version>7.0.0.Final</version>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.6</version>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-sql</artifactId>
<version>${querydsl.version}</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-core</artifactId>
</dependency>
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-persistence-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-sql</artifactId>
</dependency>
</dependencies>
</project>
Eclipse produces two types of errors, an error involving multiple writes to a file and an error involving the native authentication library:
Execution database1 of goal com.querydsl:querydsl-maven-plugin:4.2.1:export failed: Attempted to write multiple times to <PATH>\CheckConstraints.java, please check your configuration (com.querydsl:querydsl-maven-plugin:4.2.1:export:database1:validate)
...
Caused by: java.lang.IllegalStateException: Attempted to write multiple times to <PATH>\CheckConstraints.java, please check your configuration
Question 1: Is there something off with the pom.xml file or an eclipse setting somewhere that would cause Maven to run the querydsl plugin executions more than once per validate phase of the maven build? Should I use a different phase than validate? Something else entirely?
Updating the maven project in eclipse more than once causes the following errors:
This driver is not configured for integrated authentication. ClientConnectionId:12c300a7-0674-41a1-8e64-16040e9dbde3 (com.querydsl:querydsl-maven-plugin:4.2.1:export:database2:validate)
org.apache.maven.plugin.MojoExecutionException: This driver is not configured for integrated authentication. ClientConnectionId:12c300a7-0674-41a1-8e64-16040e9dbde3
...
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:12c300a7-0674-41a1-8e64-16040e9dbde3
...
Caused by: java.lang.UnsatisfiedLinkError: Native Library C:\Windows\System32\sqljdbc_auth.dll already loaded in another classloader
This error is repeated for database2 as well. The ... are long sections of stack trace that might or might not be helpful. I've posted the full stack trace for both error types at the bottom of the question.
Research into this error indicates that there is likely a classloader/lifetime related issue to Maven and Eclipse. I'm not sure if Maven and Eclipse share a classloader, but the conclusion of the Maven -> 'Update Project' method is not causing the native library, sqljdbc_auth.dll, to be unloaded and subsequent updates are causing the Microsoft JDBC driver to attempt to reload the native library.
Question 2: How do I make Maven run in Eclipse in such a way as to have the native library, sqljdbc_auth.dll, unloaded (or the previously loaded native library reused)?
Below are the full stack traces for the two types of errors:
Error Type 1:
Execution database1 of goal com.querydsl:querydsl-maven-plugin:4.2.1:export failed: Attempted to write multiple times to <PATH>\CheckConstraints.java, please check your configuration (com.querydsl:querydsl-maven-plugin:4.2.1:export:database1:validate)
org.apache.maven.plugin.PluginExecutionException: Execution database1 of goal com.querydsl:querydsl-maven-plugin:4.2.1:export failed: Attempted to write multiple times to <Path>\CheckConstraints.java, please check your configuration
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:148)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:173)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:116)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:106)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:87)
at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:201)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:798)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:219)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:262)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:315)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:318)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:370)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:391)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.IllegalStateException: Attempted to write multiple times to <PATH>\CheckConstraints.java, please check your configuration
at com.querydsl.sql.codegen.MetaDataExporter.write(MetaDataExporter.java:431)
at com.querydsl.sql.codegen.MetaDataExporter.serialize(MetaDataExporter.java:413)
at com.querydsl.sql.codegen.MetaDataExporter.handleTable(MetaDataExporter.java:393)
at com.querydsl.sql.codegen.MetaDataExporter.handleTables(MetaDataExporter.java:260)
at com.querydsl.sql.codegen.MetaDataExporter.export(MetaDataExporter.java:251)
at com.querydsl.maven.AbstractMetaDataExportMojo.execute(AbstractMetaDataExportMojo.java:538)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
... 31 more
Error Type 2:
This driver is not configured for integrated authentication. ClientConnectionId:12c300a7-0674-41a1-8e64-16040e9dbde3 (com.querydsl:querydsl-maven-plugin:4.2.1:export:database2:validate)
org.apache.maven.plugin.MojoExecutionException: This driver is not configured for integrated authentication. ClientConnectionId:12c300a7-0674-41a1-8e64-16040e9dbde3
at com.querydsl.maven.AbstractMetaDataExportMojo.execute(AbstractMetaDataExportMojo.java:547)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:173)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$1.method(MavenBuilder.java:1)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1$1.call(MavenBuilder.java:116)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod$1.call(MavenBuilder.java:106)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.builder.MavenBuilder$BuildMethod.execute(MavenBuilder.java:87)
at org.eclipse.m2e.core.internal.builder.MavenBuilder.build(MavenBuilder.java:201)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:798)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:219)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:262)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:315)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:318)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:370)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:391)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:145)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:235)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication. ClientConnectionId:12c300a7-0674-41a1-8e64-16040e9dbde3
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:2826)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<init>(AuthenticationJNI.java:73)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3550)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:81)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3541)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2395)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.querydsl.maven.AbstractMetaDataExportMojo.execute(AbstractMetaDataExportMojo.java:536)
... 32 more
Caused by: java.lang.UnsatisfiedLinkError: Native Library C:\Windows\System32\sqljdbc_auth.dll already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.microsoft.sqlserver.jdbc.AuthenticationJNI.<clinit>(AuthenticationJNI.java:52)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:3549)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:81)
at com.microsoft.sqlserver.jdbc.SQLServerConnection$LogonCommand.doExecute(SQLServerConnection.java:3541)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2395)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.querydsl.maven.AbstractMetaDataExportMojo.execute(AbstractMetaDataExportMojo.java:536)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:112)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1360)
at org.eclipse.m2e.core.project.configurator.MojoExecutionBuildParticipant.build(MojoExecutionBuildParticipant.java:52)
at org.eclipse.m2e.core.internal.builder.MavenBuilderImpl.build(MavenBuilderImpl.java:137)
at org.eclipse.m2e.core.project.configurator.AbstractLifecycleMapping.configure(AbstractLifecycleMapping.java:111)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:508)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$3.call(ProjectConfigurationManager.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:501)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration0(ProjectConfigurationManager.java:439)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:352)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager$2.call(ProjectConfigurationManager.java:1)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:177)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:151)
at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:99)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:1351)
at org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.updateProjectConfiguration(ProjectConfigurationManager.java:349)
at org.eclipse.m2e.core.ui.internal.UpdateMavenProjectJob.runInWorkspace(UpdateMavenProjectJob.java:77)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:42)
... 1 more
Thanks in advance for any help.

Related

Maven cxf plugin logging

I'm using the Apache cxf maven plugin (v3.3.0) to successfully to generate java wrappers.
However, the output from the maven build contains thousands of DEBUG logging lines from the wsdl2java which I am unable to remove. Is there an extraarg or other way to silence the process so I get just a success (or possibly failure) message?
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<defaultOptions>
<autoNameResolution>true</autoNameResolution>
</defaultOptions>
<wsdlOptions>
<!--Some Web Service -->
<wsdlOption>
<wsdl>https://some/web/service.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-quiet</extraarg>
<extraarg>-p</extraarg>
<extraarg>com.foo.bar</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
It appears that under Java 9+ the plugin forces code generation in a forked JVM regardless of the default being documented as false and regardless of any explicit configuration of this option. The plugin execution doesn't see any logging configuration from the project. CXF is logging using java.util.logging and any log down to FINER severity gets printed to the console.
I solved this by providing an explicit path to a logging configuration file to the forked JVM using the plugin's additionalJvmArgs configuration option:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf-plugin.version}</version>
<configuration>
<additionalJvmArgs>-Dlogback.configurationFile=${project.basedir}/src/test/resources/logback-codegen.xml</additionalJvmArgs>
</configuration>
</plugin>
The system property for Logback (as in my case) is logback.configurationFile. For Log4j that would be log4j.configurationFile.
In the logging configuration file the following loggers can be added (Logback):
<!-- entries below silence excessive logging from cxf-codegen-plugin -->
<logger name="org.apache.cxf" level="info"/>
<logger name="org.apache.velocity" level="info"/>
This way the plugin execution will still print to the console all warnings and errors, but all the repetitive debug information goes away. The drawback is that you need to have such a logging configuration file visible in each of your projects. But then, you probably should have one anyway. The same one as for (unit) tests can often be used.
Sorry for not getting into the root solutions, but adding this in my dependencies help:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
<scope>provided</scope>
</dependency>
or put following in plugin execution helps too except for velocity logs
<additionalJvmArgs>
-Dorg.apache.cxf.Logger=null
</additionalJvmArgs>
Hope this would give a hints for someone to come out with a much proper solution.
Using maven-3.8.4 and cxf-codegen-plugin:3.5.1:wsdl2java, I've reduced log level with:
<configuration>
<additionalJvmArgs>-D.level=WARN</additionalJvmArgs>
</configuration>
More details here: Apache CXF

Error in creating rule engine drools

I intended to use the Openllet reasoner, as suppose to the other available reasoners. But this reasoner is compatible only with the OWL API 5.X.X distribution. I have a xxx.owl file which contains SWRL rules. Since the existing SWRL API is not compatible with OWL API 5, Ignazio Palmisano had kindly put up a forked repository with required changes, so that it is compatible with the OWL API 5.X.X distribution. Consequently, I removed the dependencies related to SWRL API and drools engine. Instead, I built them locally by downloading the 'zip' files.
Now, with ".jar" files of the SWRL API and Drools loaded into the project in intelliJ, I am presented with this following error:
Exception in thread "main" org.swrlapi.exceptions.SWRLRuleEngineException: Error creating rule engine Drools. Exception: java.lang.NoClassDefFoundError. Message: org/drools/runtime/rule/AgendaFilter
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:71)
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:41)
at org.swrlapi.factory.SWRLAPIFactory.createSWRLRuleEngine(SWRLAPIFactory.java:38)
at SWRLrules.main(SWRLrules.java:61)
Caused by: java.lang.NoClassDefFoundError: org/drools/runtime/rule/AgendaFilter
at org.swrlapi.drools.core.DroolsSWRLRuleEngineCreator.create(DroolsSWRLRuleEngineCreator.java:27)
at org.swrlapi.factory.DefaultSWRLRuleAndQueryEngineFactory.createSWRLRuleEngine(DefaultSWRLRuleAndQueryEngineFactory.java:59)
... 3 more
Caused by: java.lang.ClassNotFoundException: org.drools.runtime.rule.AgendaFilter
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 5 more code here
Here I am also attaching the dependencies in pom.xml file:
<dependencies>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-osgidistribution</artifactId>
<version>5.1.4</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency>
<groupId>com.github.galigator.openllet</groupId>
<artifactId>openllet-owlapi</artifactId>
<version>2.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>org.swrlapi.example.SWRLAPIExample</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.swrlapi.example.SWRLAPIExample</mainClass>
</configuration>
</plugin>
</plugins>
</build>
P.S: I built the swrl api and drools engine locally and imported the jar file into the project.
You do not need to remove the dependencies from the pom file (the error you're seeing is caused by some jar having been missed in the manual process).
If you use my swrlapi fork and change the version to, say, 2.0.6-SNAPSHOT, then running locally
mvn clean install
will put a 2.0.6-SNAPSHOT jar in your local maven repository. At that point, change your pom to require swrlapi 2.0.6-SNAPSHOT and you'll get the updated version in your application.

Maven default compile not picking up custom plugin goal

I have written a custom plugin, then I installed it. Then I modified the pom.xml of the project from which I want to use the custom plugin. When I invoke my plugin goal directly the plugin goal is executed successfully, but when I try to mvn compile my custom plugin goal is not executed. What might be the reason?
My plugin's 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.xxx.plugins.maven</groupId>
<artifactId>datanucleus-enhance-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Datanucleus-enhance Maven Plugin</name>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
My project using custom plugin I added following:
<!-- enhance JDO classes -->
<plugin>
<groupId>com.sukantu.plugins.maven</groupId>
<artifactId>datanucleus-enhance-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<configuration>
<jdoClassDirList>
<param>target/${project.artifactId}-${project.version}/WEB-INF/classes/</param>
</jdoClassDirList>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
I followed section Attaching the Mojo to the Build Lifecycle from maven guide site: https://maven.apache.org/guides/plugin/guide-java-plugin-development.html
The following command successfully calls my plugin goal:
mvn com.xxx.plugins.maven:datanucleus-enhance-maven-plugin:enhance
The following command does NOT successfully call my plugin goal:
mvn compile
Thanks for any inputs!
I came across this link:
How do I link a plugin execution to a phase in maven without forcing me to specify plugin on command line
So I removed <pluginManagement> tags so <plugins> appear directly under '<build>'. Then I tried 'mvn compile' from command line and it successfully called my custom plugin goal!
But when I checked pom.xml in Eclipse I saw another error referenced here How to solve “Plugin execution not covered by lifecycle configuration” .
Since the command line is working correctly, I think this is m2e Eclipse plugin error and so I have disabled the marked by going to 'Eclipse' -> 'Window' -> 'Show View' -> 'Markers' -> right click that marker -> 'Delete'. Now Eclipse is not showing any error and command line is also working as expected. Hope this helps someone else.

mvn-gae-plugin suddenly broken

I'm not sure what happened but I've made not changes to my pom and have only done a clean install but now running my app with mvn gae:run gives me the following error:
[ERROR] Failed to execute goal net.kindleit:maven-gae-plugin:0.9.4:run (default-cli) on project geoip-service: Execution default-cli of goal net.kindleit:maven-gae-plugin:0.9.4:run failed: Plugin net.kindleit:maven-gae-plugin:0.9.4 or one of its dependencies could not be resolved: Failed to collect dependencies for net.kindleit:maven-gae-plugin:jar:0.9.4 (): Failed to read artifact descriptor for net.kindleit:gae-runtime:pom:1.7.5: Could not find artifact net.kindleit:maven-gae-parent:pom:0.9.6-SNAPSHOT in genius (our_own_repo_here)
I'm using the 1.7.2 version of the sdk so I'm not sure where the 1.7.5 could be coming from.
For the time being, you can use this ugly hack
<properties>
<gae.version>1.7.5</gae.version>
<gae-runtime.version>1.7.5.1</gae-runtime.version>
</properties>
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>${maven.gae.plugin.version}</version>
<configuration>
<unpackVersion>${gae.version}</unpackVersion>
<serverId>appengine.google.com</serverId>
<appDir>${webappDirectory}</appDir>
</configuration>
<dependencies>
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae-runtime.version}</version>
<type>pom</type>
</dependency>
</dependencies>
</plugin>
I still don't know what the issue was, I.e. who was pulling in gae-runtime of version 1.7.5 but this is the work around that worked for me. Add the following under your maven-gae-plugin in profile/build/plugins/plugin etc.
<dependencies>
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>1.7.2</version>
<type>pom</type>
</dependency>
</dependencies>

Conflicting versions of datanucleus enhancer in a maven google app engine project

I'm having a problem setting up datanucleus enhancer to use with a google app engine project. If I use the datanucleus eclipse plugin everything goes well, but in my maven project I get a strange conflicting version error.
My POM has these datanucleus references:
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>1.1.0</version>
</dependency>
...
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>1.1.0</version>
<configuration>
<mappingIncludes>**/*.class</mappingIncludes>
<verbose>true</verbose>
<enhancerName>ASM</enhancerName>
<api>JDO</api>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
When I try to build the project I get the following error:
Exception in thread "main" Plugin (Bundle) "org.datanucleus" is already registered.
Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.0/**datanucleus-core-1.1.0.jar**" is already registered, and you are trying to register an identical plugin located at URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.3/**datanucleus-core-1.1.3.jar**."
org.datanucleus.exceptions.NucleusException: Plugin (Bundle) "org.datanucleus" is already registered. Ensure you dont have multiple JAR versions of the same plugin in the classpath. The URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.0/datanucleus-core-1.1.0.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/Users/drome/.m2/repository/org/datanucleus/datanucleus-core/1.1.3/datanucleus-core-1.1.3.jar."
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:437)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerBundle(NonManagedPluginRegistry.java:343)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensions(NonManagedPluginRegistry.java:227
)
at org.datanucleus.plugin.NonManagedPluginRegistry.registerExtensionPoints(NonManagedPluginRegistry.jav
a:159)
at org.datanucleus.plugin.PluginManager.registerExtensionPoints(PluginManager.java:82)
at org.datanucleus.OMFContext.(OMFContext.java:164)
at org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:171)
at org.datanucleus.enhancer.DataNucleusEnhancer.(DataNucleusEnhancer.java:149)
at org.datanucleus.enhancer.DataNucleusEnhancer.main(DataNucleusEnhancer.java:1157)
I don't understand why datanucleus required maven to download datanucleus-core-1.1.3.jar since this is not referenced in the pom.xml
I also do not understand why datanucleus-core-1.1.3.jar is being registered...
Any ideas?
Thanks in advance...
The DN M2 plugin pulls in the latest versions of the available DN jars that it needs to do its job (there is no other sensible way to do it other than use the latest). You want to restrict "core" to a different version, either by specifying the plugin dependency of core, or by specifying that in your application to
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>1.1.0</version>
<scope>runtime</scope>
</dependency>
Unfortunately the answer is "hidden" in the comments:
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>1.1.0</version>
<scope>runtime</scope>
</dependency>
That worked for me!
I ran into the same issue while testing a maven gae plugin archetype.
I fixed it by adding exclusions in my gae runtime transitive dependencies
<!-- Google App Engine meta-package -->
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae.version}</version>
<type>pom</type>
<exclusions>
<exclusion>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-core</artifactId>
</exclusion>
</exclusions>
</dependency>
and then adding the nucleus core as a runtime dependency
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus-core.version}</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>transaction-api</artifactId>
</exclusion>
</exclusions>
</dependency>
as keeping the gae plugin section simple:
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>${maven-datanucleus-plugin.version}</version>
<configuration>
<!--
Make sure this path contains your persistent classes!
-->
<mappingIncludes>**/model/*.class</mappingIncludes>
<verbose>true</verbose>
<enhancerName>ASM</enhancerName>
<api>JDO</api>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
After reading "How to override a plugin's dependency in Maven", I found another way to fix this. Here is my POM:
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.1.0-m3</version>
<configuration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>3.0.4</version>
</dependency>
</dependencies>
</plugin>
clearing your old version of datanucleus from your local maven repository also solving the problem.
Maven-datanucleus-plugin has stopped pulling in the latest versions of the available datanucleus-core since version 3.1.1.
Check the differences between the POM files for Maven-datanucleus-plugin 3.1.1 (http://repo1.maven.org/maven2/org/datanucleus/maven-datanucleus-plugin/3.1.1/maven-datanucleus-plugin-3.1.1.pom) and 3.1.0-release (http://mvnrepository.com/artifact/org.datanucleus/maven-datanucleus-plugin/3.1.0-release).
For maven-datanucleus-plugin 3.1.1 the version range of datanucleus-core dependency is (3.0.99, 3.1.99), and for maven-datanucleus-plugin 3.1.0-release it is (3.0.99, ). No wonder for the older versions of maven-datanucleus-plugin, it automatically pulls in the latest versions of datanucleus-core.

Resources