GWT + Appengine + JPA + Eclipse + Maven: How to get them to work together - google-app-engine

I have a project where I want to use the eclipse GWT tools (dev mode and debugger) to interact with the GWT/Appengine/Maven application I am writing. I have things in a somewhat working order but there are still a few things around the edges I don't have right. I will post the POM file if anyone could help me with these few issues.
When I do a Maven->Update Project, I loose the appengine nature in the eclipse project properties and have to go to Properties, Google, AppEngine and recheck Use Google App Engine. Is there something I can do in the POM where I don't loose the appengine nature? I'm using the Google appengine-maven-plugin plugin. That seems to be the official one to use.
After a maven build, I have to do a project clean to get the jpa classes enhanced before I can run them with the Run As - Web Application launcher. The maven build has test cases for the domain objects that work within the build - and I see the classes being enhance with this goal in the build 'maven-datanucleus-plugin:3.1.3:enhance (default)'. But running as a Web Application it throws out errors telling me the classes are not enhanced unless I do a project clean which cause eclipse to do it's enhance. Is there a way to avoid this extra step?
I can not run the JUnit View test runner or use a launcher that uses that view. The JUnit View complains that: "Caused by: 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:/C:/Users/bondsd/.m2/repository/org/datanucleus/datanucleus-core/3.1.3/datanucleus-core-3.1.3.jar" is already registered, and you are trying to register an identical plugin located at URL "file:/C:/Program%20Files/eclipse/plugins/com.google.appengine.eclipse.sdkbundle_1.7.5/appengine-java-sdk-1.7.5/lib/opt/user/datanucleus/v2/datanucleus-core-3.1.3.jar."". I have tried various things, such as removing the datanucleus plugin and/or dependencies, various configuration options, and unchecking the 'Use Datnucleus JDO/JPA to access the datastore' in the app engine properties panel. Is there a way to get this to work?
Below is the POM I used with the company and project name x'ed out. If you need the launchers I will be glad to post them too. Thanks in advance for any advice or help on this. I have searched the internet and haven't found the right solution yet.
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx.xxxx</groupId>
<artifactId>shell</artifactId>
<packaging>war</packaging>
<version>0.1.0-proto</version>
<name>XXXXXX</name>
<description>A XXXXXXXX</description>
<properties>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- GWT version -->
<gwt.version>2.5.1</gwt.version>
<gwt.style>PRETTY</gwt.style>
<!-- GAE version -->
<appengine.version>1.7.6</appengine.version>
<appengine.sdk.version>1.7.6</appengine.sdk.version>
<appengine.orm.version>2.1.2</appengine.orm.version>
<appengine.port>8888</appengine.port>
<datanucleus.core.version>3.1.3</datanucleus.core.version>
<datanucleus.api.version>3.1.3</datanucleus.api.version>
<datanucleus.enhancer.version>3.1.1</datanucleus.enhancer.version>
<datanucleus.plugin.version>3.1.3</datanucleus.plugin.version>
<slf4jVersion>1.6.6</slf4jVersion>
<log4j.version>1.3</log4j.version>
<junit.version>4.11</junit.version>
</properties>
<dependencies>
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
<version>3.0</version>
</dependency>
<!-- GWT dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
<!-- GAE SDK -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${appengine.version}</version>
</dependency>
<!-- For the servlet filter -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> <groupId>jstl</groupId> <artifactId>jstl</artifactId>
<version>1.2</version> </dependency> -->
<!-- RequestFactory server -->
<dependency>
<groupId>com.trycatchsoft.gwt.requestfactory</groupId>
<artifactId>injected-requestfactory</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.google.web.bindery</groupId>
<artifactId>requestfactory-server</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.web.bindery</groupId>
<artifactId>requestfactory-apt</artifactId>
<version>${gwt.version}</version>
</dependency>
<!-- RequestFactory will use JSR 303 javax.validation -->
<!-- Validation API -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<!-- Validation Implementation -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.3.0.Final</version>
</dependency>
<!--Test Dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.0</version>
<scope>test</scope>
</dependency>
<!-- GAE libraries for local testing as described here: http://code.google.com/appengine/docs/java/howto/unittesting.html -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${appengine.version}</version>
<scope>test</scope>
</dependency>
<!-- End of Test Dependencies -->
<!-- JPA 2.0 for GAE -->
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>${appengine.orm.version}</version>
</dependency>
<!-- Datanucleus -->
<!-- datanucleus-core is not needed for compilation. in fact, it cannot
have compile scope because the datanucleus plugin automatically adds it during
enhancement and complains if there are two copies. app should not depend
on any classes in this lib anyways. -->
<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>
<!-- datanucleus-jpa is needed during compilation for its #Extension annotation
which is used throughout entity classes -->
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jpa</artifactId>
<version>${datanucleus.api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.2</version>
</dependency>
<!-- SLF4J logging libraries -->
<!-- <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId>
<version>${slf4jVersion}</version> </dependency> <dependency> <groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> <version>1.7.2</version> </dependency>
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.16</version>
</dependency> -->
<!-- End SLF4J logging libraries -->
</dependencies>
<build>
<!-- Generate compiled stuff in the folder used for developing mode -->
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<dependencies>
<!-- Need to run the RF Validation tool. This works on both the command-line
and in Eclipse, provided that m2e-apt is installed. -->
<dependency>
<groupId>com.google.web.bindery</groupId>
<artifactId>requestfactory-apt</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.5.1-rc1</version>
<dependencies>
<!-- Force plugin to use same gwt version -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
<configuration>
<strict>true</strict>
<extraJvmArgs>-Xss1024K -Xmx1024M -XX:MaxPermSize=256M</extraJvmArgs>
<logLevel>INFO</logLevel>
<style>${gwt.style}</style>
<copyWebapp>true</copyWebapp>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<runTarget>Shell.html</runTarget>
<webappDirectory>${webappDirectory}</webappDirectory>
<module>com.ihg.dashboard.Shell</module>
<server>com.google.appengine.tools.development.gwt.AppEngineLauncher</server>
<i18nMessagesBundle>com.ihg.dashboard.client.Messages</i18nMessagesBundle>
<appEngineVersion>${appengine.version}</appEngineVersion>
<!-- Should GWT create the Story of Your Compile Report -->
<compileReport>false</compileReport>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>i18n</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${appengine.version}</version>
<configuration>
<jvmFlags>
<jvmFlag>-Ddatastore.backing_store=${project.basedir}\local_db.bin</jvmFlag>
</jvmFlags>
<enhancerApi>JPA</enhancerApi>
</configuration>
</plugin>
<!-- This plug-in "enhances" your domain model objects (i.e. makes them
persistent for datanucleus) -->
<!-- Might not need this, appengine is supposed to do this appengine:enhance -->
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>${datanucleus.plugin.version}</version>
<configuration>
<mappingIncludes>**/domain/*.class</mappingIncludes>
<metadataIncludes>**/domain/*.class</metadataIncludes>
<verbose>false</verbose>
<enhancerName>ASM</enhancerName>
<api>JPA</api>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<!-- enhancement requires the gwt-user jar because many of the entity
classes implement IsSerializable and the enhancer needs it on the classpath
to function. because the gwt-user library has a scope of provided, it is
only available on the compilation and test classpath, and is not transitive
to the enhancement classpath. -->
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<!-- force maven-datanucleus-plugin to use the same version of datanucleus-core -->
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.core.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- Copy static web files before executing gwt:run -->
<!-- May not need this now -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webXml>${webappDirectory}/WEB-INF/web.xml</webXml>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>
gwt-maven-plugin
</artifactId>
<versionRange>
[2.5.1-rc1,)
</versionRange>
<goals>
<goal>i18n</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.datanucleus
</groupId>
<artifactId>
maven-datanucleus-plugin
</artifactId>
<versionRange>
${datanucleusVersion}
</versionRange>
<goals>
<goal>enhance</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
=======================================
On Edit: Here is a solution to bullet point 3. Disable the JPA/JDO in the Project Properties - Google - App Engine page. Go to the build path and remove all the datanucleus libraries that are listed as top level libraries (these are put there by enabled the appengine in the project properties). Make sure the Maven dependencies are at the bottom of the list on the Order Tab.
On Edit 2: I found a way to keep the GAE project nature when I do a Maven->Update Project. I added this to the POM (even though I am using an eclipse build with m2e installed)
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.7</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>false</downloadJavadocs>
<wtpversion>2.0</wtpversion>
<additionalBuildcommands>
<buildCommand>
<name>com.google.gwt.eclipse.core.gwtProjectValidator</name>
</buildCommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>com.google.gwt.eclipse.core.gwtNature</projectnature>
<projectnature>com.google.appengine.eclipse.core.gaeNature</projectnature>
</additionalProjectnatures>
</configuration>
</plugin>
This addresses Bullet point 1. So now I have points 1 and 3 solved (kind of). I still need a way to address bullet point 2, although the work around is easy if I remember to do it. I am more worried about the people who get the code after me remembering to do it.
I am also looking for a way to not use the eclipse launcher at all. I know it can be done with adding various profiles and configs. I just need to find the right configs to do that. By this, I mean a profile that will run the gwt code in dev mode (or super-dev mode) and also a profile that will run the debugger with the gwt code in dev mode.
On Edit 3: I solved bullet point 2. It was as simple as turning off Project->Build Automatically. I'm not sure what that was on in the first place.
That is all 3 bullet points solved. At this point I probably should create an answer for the question and mark it solved for those that are interested in this and didn't read down this far. I will do that in a day or two (when I have the time to compose a nice answer).

It looks like your maven setup is good, but let me make some observations that may help.
1) I would remove the enhancerApi from the appengine-maven-plugin as we're just executing the same thing as the maven-datanucleus-plugin. As a result, don't run the appengine:enhance goal along with the datanucleus plugin's goals.
2) The datanucleus plugin is setup only to enhance domain classes, which sounds right to me, but just verify this I guess.
3) I'm not the best with eclipse anymore, but I'm curious which maven plugin you are using, the m2eclipse plugin is developed by sonatype and the most accurate one in my opinion.
4) The execution of the war plugin on compile seems wrong to me, as this should default to the package phase anyway, which ensures other phases have properly executed beforehand.
5) You may need to get set up a few more execute directives for the plugins, or rely on defaults if they exist. The maven lifecycle can be a bit tricky, and I would recommend reading up on http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html and making sure eclipse is running the correct phases before launching your application.

Related

Unable to run flink jar : Multiple factories for identifier 'default' that implement

I was using the below mentioned POM file for writing the flink code
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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>flink</groupId>
<artifactId>flink-reporting</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Flink Quickstart Job</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<flink.version>1.15.0</flink.version>
<target.java.version>1.8</target.java.version>
<scala.binary.version>2.12</scala.binary.version>
<maven.compiler.source>${target.java.version}</maven.compiler.source>
<maven.compiler.target>${target.java.version}</maven.compiler.target>
<log4j.version>2.17.1</log4j.version>
</properties>
<repositories>
<repository>
<id>apache.snapshots</id>
<name>Apache Development Snapshot Repository</name>
<url>https://repository.apache.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<!-- Apache Flink dependencies -->
<!-- These dependencies are provided, because they should not be packaged into the JAR file. -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java</artifactId>
<version>${flink.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients</artifactId>
<version>${flink.version}</version>
</dependency>
<!-- Add connector dependencies here. They must be in the default scope (compile). -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-kafka</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.26</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.flink</groupId>-->
<!-- <artifactId>flink-table</artifactId>-->
<!-- <version>1.15.0</version>-->
<!-- <type>pom</type>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-java-bridge</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-api-scala-bridge_2.12</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-runtime</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-table-planner_2.12</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-connector-files</artifactId>
<version>1.15.0</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-csv</artifactId>
<version>1.15.0</version>
</dependency>
<!-- Add logging framework, to produce console output when running in the IDE. -->
<!-- These dependencies are excluded from the application JAR by default. -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-data-lake-store-sdk</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20220320</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Java Compiler -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>${target.java.version}</source>
<target>${target.java.version}</target>
</configuration>
</plugin>
<!-- We use the maven-shade plugin to create a fat jar that contains all necessary dependencies. -->
<!-- Change the value of <mainClass>...</mainClass> if your program entry point changes. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org.apache.flink:flink-shaded-force-shading</exclude>
<exclude>com.google.code.findbugs:jsr305</exclude>
<exclude>org.slf4j:*</exclude>
<exclude>org.apache.logging.log4j:*</exclude>
</excludes>
</artifactSet>
<filters>
<filter>
<!-- Do not copy the signatures in the META-INF folder.
Otherwise, this might cause SecurityExceptions when using the JAR. -->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>tableAPI.GettingStartedTable</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- This improves the out-of-the-box experience in Eclipse by resolving some warnings. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<versionRange>[3.1.1,)</versionRange>
<goals>
<goal>shade</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<versionRange>[3.1,)</versionRange>
<goals>
<goal>testCompile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore/>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
While running the jar file in flink cluster I am getting the following error.
The program finished with the following exception:
org.apache.flink.client.program.ProgramInvocationException: The main method caused an error: Multiple factories for identifier 'default' that implement 'org.apache.flink.table.delegation.ExecutorFactory' found in the classpath.
Ambiguous factory classes are:
org.apache.flink.table.planner.delegation.DefaultExecutorFactory
org.apache.flink.table.planner.loader.DelegateExecutorFactory
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:372)
at org.apache.flink.client.program.PackagedProgram.invokeInteractiveModeForExecution(PackagedProgram.java:222)
at org.apache.flink.client.ClientUtils.executeProgram(ClientUtils.java:114)
at org.apache.flink.client.cli.CliFrontend.executeProgram(CliFrontend.java:836)
at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:247)
at org.apache.flink.client.cli.CliFrontend.parseAndRun(CliFrontend.java:1078)
at org.apache.flink.client.cli.CliFrontend.lambda$main$10(CliFrontend.java:1156)
at org.apache.flink.runtime.security.contexts.NoOpSecurityContext.runSecured(NoOpSecurityContext.java:28)
at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1156)
Caused by: org.apache.flink.table.api.ValidationException: Multiple factories for identifier 'default' that implement 'org.apache.flink.table.delegation.ExecutorFactory' found in the classpath.
Ambiguous factory classes are:
org.apache.flink.table.planner.delegation.DefaultExecutorFactory
org.apache.flink.table.planner.loader.DelegateExecutorFactory
at org.apache.flink.table.factories.FactoryUtil.discoverFactory(FactoryUtil.java:553)
at org.apache.flink.table.api.internal.TableEnvironmentImpl.create(TableEnvironmentImpl.java:276)
at org.apache.flink.table.api.TableEnvironment.create(TableEnvironment.java:93)
at tableAPI.GettingStartedTable.main(GettingStartedTable.java:17)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.apache.flink.client.program.PackagedProgram.callMainMethod(PackagedProgram.java:355)
... 8 more
Using flink 1.15. I was able to run the code inside my IDE
You need to set some dependencies scope as provided so they are not included in the JAR to avoid conflicts, that is most likely the issue. You actually have a comment in your POM:
<!-- These dependencies are provided, because they should not be packaged into the JAR file. -->
See https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/configuration/overview/#flink-apis to see the list of runtime dependencies that should be set as provided and https://nightlies.apache.org/flink/flink-docs-stable/docs/dev/datastream/project-configuration/#setting-up-a-project-basic-dependencies for some more details

GWT 2.7 + GAE app looks for codeserver when deployed

Why does appengine try to use Super Dev Mode?
Every time I deploy my GWT app to appengine and try to access it I get the white loading screen, then after about 20-30 seconds I get this message:
I use maven with the gwt-maven-plugin and appengine-maven-plugin. Deploying using the maven-gae-plugin gives the same results.
If I switch back to using 2.6.1 versions of gwt and the gwt-maven-plugin it deploys ok, so it would seem it's something to do with the automatic dev mode launcher.
Some of my pom.xml
<build>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/super</directory>
</resource>
<resource>
<directory>${project.build.directory}/generated-sources/apt</directory>
</resource>
<resource>
<directory>${project.build.directory}/generated-sources/gwt</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${target.jdk}</source>
<target>${target.jdk}</target>
<encoding>${project.build.sourceEncoding}</encoding>
<proc>none</proc>
</configuration>
</plugin>
<!-- JUnit Testing - skip *.GwtTest cases -->
<!-- 'mvn test' - runs the Jukito tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/*GwtTest.java</exclude>
<exclude>**/*JUnitTest.java</exclude>
</excludes>
</configuration>
</plugin>
<!-- GWT -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt-maven-plugin.version}</version>
<configuration>
<strict>true</strict>
<testTimeOut>180</testTimeOut>
<!-- With multiple tests use GwtTestSuite.java for speed -->
<includes>**/*GwtTest.java</includes>
<mode>htmlunit</mode>
<extraJvmArgs>-Xss1024k -Xmx2048M -XX:MaxPermSize=512M</extraJvmArgs>
<logLevel>INFO</logLevel>
<style>PRETTY</style>
<copyWebapp>true</copyWebapp>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<server>com.google.appengine.tools.development.gwt.AppEngineLauncher</server>
<appEngineVersion>${gae.version}</appEngineVersion>
<appEngineHome>${gae.home}</appEngineHome>
<extraJvmArgs>-Dappengine.sdk.root=${gae.home}</extraJvmArgs>
<extraJvmArgs>-Ddatastore.default_high_rep_job_policy_unapplied_job_pct=20</extraJvmArgs>
<port>8888</port>
<runTarget>Project.html</runTarget>
<modules>
<module>com.utilitiessavings.usavappv7.Project</module>
</modules>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Google App Engine Deployment -->
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${gae.version}</version>
<configuration>
<enableJarSplitting>true</enableJarSplitting>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Google Web Toolkit dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>runtime</scope>
</dependency>
<!-- Google App Engine dependencies -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${gae.version}</version>
</dependency>
<!-- Testing -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${gae.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<!-- Persistence dependencies -->
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>${persistence-api.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.objectify</groupId>
<artifactId>objectify</artifactId>
<version>${objectify.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax.validation.version}</version>
</dependency>
<!-- Other dependencies -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
In my Project.gwt.xml
<add-linker name="xsiframe" />
(Tried removing this line but still got the same result)
Environment
Eclipse Luna (4.4.1)
Maven 3.2.3 (3.2.1 Embedded)
m2eclipse 1.5.0
gwt:compile tries to work "incrementally" by comparing the timestamp of the nocache.js file with the ones of the source files, and skipping GWT compilation if it thinks the output is up-to-date. This is brittle though. gwt:run (without <superDevMode>false</superDevMode>; and gwt:run-codeserver with launcherDir) will overwrite the nocache.js with a SuperDevMode-specific version, and this is likely to lead to gwt:compile skipping the compilation.
The takeaway is: when deploying or "releasing", make sure you first run mvn clean or force gwt:compile to run by passing -Dgwt.compiler.force to Maven.
Just for information, I had the same problem, caused by the usage of a non-standard project structure.
Maven was copying the .nocache files in a directory different than /target/which prevented the clean plugin from cleaning the generated files.
Adding a new with the directory where the files are copied solves the problem.

App Engine, JDO and Maven. Error on startup

I'm trying to create a simple test using JDO with App Engine and a Maven configuration.
My compile and data enhancement steps succeed. But at runtime (both mvn:test and appengine:devserver) I get:
1) Error in custom provider, javax.jdo.JDOFatalInternalException:
Class "com.google.appengine.datanucleus.DatastoreManager" was not found in the CLASSPATH.
Please check your specification and your CLASSPATH.
However, my classpath (target/demo/WEB-INF/lib) does contain: datanucleus-appengine-2.1.1.jar
And my dependencies are the same as those specified in the Google datanucleus project's POM:
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>[3.1.1, 3.2)</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>[3.1.1, 3.2)</version>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>2.1.1</version>
</dependency>
Appreciate any suggestions.
RB
I have everything working now. I thought I'd share a couple of the gotchas (since it took me several days to plough through all of this):
1). All of the versions really matter (esp. matching the App Engine ORM 2.1.1 to DataNucleus 3.1.1 -- including the plugin).
http://www.datanucleus.org/products/accessplatform_3_2/datastores/appengine.html
Here's what I ended up with:
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>3.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-api-jdo</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>com.google.appengine.orm</groupId>
<artifactId>datanucleus-appengine</artifactId>
<version>2.1.2</version>
</dependency>
...
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>false</verbose>
<fork>false</fork>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
2). Check the tail of the datanucleus.log to confirm that your classes were enhanced (via mvn datanucleus:enhance). I eventually realized that my test classes (in src/test) were being ignored.
I have added false in pom.xml and it works for me
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.1.2</version>
<configuration>
**<fork>false</fork>**
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

Can someone outline the exact steps required to convert a maven GWT project into GAE+JDO project

I found out using webApp with -maven switch generates a maven compliant project. Now once I have this project I have to do the following steps.
1) Add gae dependencies
2) Add jdo dependencies
3) Add app-engine configuration file
4) Add jdo configuration file
Is there something else, I am using app engine 1.6.6, and gwt 2.4. Please outline me the exact steps and dependencies. The links I found about the gae-maven plugin in other stack overflow questions, seem to be quite old and don't work well.
Here is my pom.xml: I use GAE, GWT and JDO. Hope it helps:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<!-- The Basics -->
<groupId>YOUR COMPANY</groupId>
<artifactId>YOUR ARTIFACT</artifactId>
<version>VERSION</version>
<packaging>pom</packaging>
<dependencies>
<!-- GWT dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
<!-- GAE libraries for local testing as described here: http://code.google.com/appengine/docs/java/howto/unittesting.html -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${gae.version}</version>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<!-- Google App Engine meta-package -->
<dependency>
<groupId>net.kindleit</groupId>
<artifactId>gae-runtime</artifactId>
<version>${gae.version}</version>
<type>pom</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo2-api</artifactId>
<version>2.3-eb</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-1.0-sdk</artifactId>
<version>${gae.version}</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-parent</artifactId>
<version>1.6.1</version>
<type>pom</type>
</dependency>
</dependencies>
<!-- Specify hard-coded project properties here -->
<properties>
<!-- GWT version -->
<gwt.version>2.4.0</gwt.version>
<!-- port defaults to 8080 -->
<gae.port>8080</gae.port>
<!-- Produce detailed JS during GWT compilation for development environment -->
<gwt.style>DETAILED</gwt.style>
<!-- Sets the project's default encoding. http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<!-- This is just for "eclipse:eclipse" goal to always attempt downloading
sources -->
<downloadSources>true</downloadSources>
<!-- Specify AppEngine version for your project. It should match SDK version
pointed to by ${gae.home} property (Typically, one used by your Eclipse plug-in) -->
<gae.version>1.6.6</gae.version>
<!-- Upload to http://test.latest.<applicationName>.appspot.com by default -->
<datanucleus.version>1.1.5</datanucleus.version>
<gae.plugin.version>0.9.2</gae.plugin.version>
</properties>
for what it's worth, here is a pom i just put together that seems to work ok wuth gae 1.7.4 and GWT 2.5 with JDO 3.0 -
<?xml version="1.0" encoding="UTF-8"?>
<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.nimbits.cloudplatform</groupId>
<artifactId>nimbitsplatform</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>nimbits-02</name>
<dependencies>
<dependency>
<groupId>javax.jdo</groupId>
<artifactId>jdo-api</artifactId>
<version>3.0</version>
</dependency>
<!-- Google App Engine meta-package -->
<!--<dependency>-->
<!--<groupId>net.kindleit</groupId>-->
<!--<artifactId>gae-runtime</artifactId>-->
<!--<version>${gae.version}</version>-->
<!--<type>pom</type>-->
<!--</dependency>-->
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<!-- GWT dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
<!-- J2EE Servlet API. We need it to compile IndexServlet class. You can probably remove
it, if you don't explicitly use Servlets -->
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
<scope>provided</scope>
</dependency>
<!-- Make use of JSP tags. Remove, if you don't use JSPs -->
<dependency>
<artifactId>standard</artifactId>
<groupId>taglibs</groupId>
<version>1.1.2</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
<!-- These dependencies are here just for enabling logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.24</version>
</dependency>
<!-- Test scope -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<!-- GAE libraries for local testing as described here: http://code.google.com/appengine/docs/java/howto/unittesting.html -->
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-labs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-api-stubs</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-testing</artifactId>
<version>${gae.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<!-- This plug-in "enhances" your domain model objects (i.e. makes them persistent for
datanucleus) -->
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>1.1.4</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>
<dependencies>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>1.1.5</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
<artifactId>transaction-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-rdbms</artifactId>
<version>1.1.5</version>
</dependency>
<dependency>
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-enhancer</artifactId>
<version>1.1.4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-beta-1</version>
<configuration>
<webResources>
<resource>
<directory>src/main/webapp</directory>
<filtering>true</filtering>
<includes>
<include>**/appengine-web.xml</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
<!-- Maven GWT plugin (ex. http://gwt-maven.googlecode.com/svn/docs/maven-googlewebtoolkit2-plugin/index.html)
http://mojo.codehaus.org/gwt-maven-plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<logLevel>INFO</logLevel>
<!-- match -Dgae.port -->
<port>${gae.port}</port>
<!--<!–This must point to your GWT modules!–>-->
<!--<compileTargets>-->
<!--<value>net.kindleit.gae.example.Messages</value>-->
<!--</compileTargets>-->
<!-- This is for generating Asynch interfaces -->
<!-- <servicePattern>**/client/*Service.java</servicePattern> -->
<extraJvmArgs>-Xmx512m</extraJvmArgs>
<!--<jvm>${JAVA_HOME}/bin/java</jvm> -->
<!--<noServer>false</noServer> -->
<!-- TODO This should help running GAE stuff in hosted mode (when gwt-maven-plugin-1.2
is released, see http://jira.codehaus.org/browse/MGWT-112) -->
<server>com.google.appengine.tools.development.gwt.AppEngineLauncher
</server>
<runTarget>/index.html</runTarget>
<style>DETAILED</style>
<webXml>war/WEB-INF/web.xml</webXml>
<!-- this parameter is VERY important with automatic mode - has to match the version
in your declared deps -->
<!-- if this is set incorrect (not a match), or left out (default is 1.5.2 for 2.0-beta23)
you will have mysterious errors -->
<gwtVersion>${gwt.version}</gwtVersion>
</configuration>
<executions>
<!-- <execution> <id>generateAsynch</id> <phase>generate-sources</phase> <goals>
<goal>generateAsync</goal> </goals> </execution> -->
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- The actual maven-gae-plugin. Type "mvn gae:run" to run project, "mvn gae:deploy"
to upload to GAE. -->
<plugin>
<groupId>net.kindleit</groupId>
<artifactId>maven-gae-plugin</artifactId>
<version>0.9.4</version>
</plugin>
<!-- Upload application to the appspot automatically, during release:perform -->
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<goals>gae:deploy</goals>
</configuration>
</plugin>
<!-- Java compiler version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Copy dependencies to war/WEB-INF/lib for GAE proj compliance. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>default-cli</id>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/webapp/WEB-INF/lib/</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<excludeArtifactIds>gwt-user,gwt-dev</excludeArtifactIds>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<!-- Specify hard-coded project properties here -->
<properties>
<!-- Sets the project's default encoding.
http://docs.codehaus.org/display/MAVENUSER/POM+Element+for+Source+File+Encoding -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- This is just for "eclipse:eclipse" goal to always attempt downloading sources -->
<downloadSources>true</downloadSources>
<!-- Specify AppEngine version for your project. It should match SDK version pointed to
by ${gae.home} property (Typically, one used by your Eclipse plug-in) -->
<gae.version>1.7.2</gae.version>
<gae.home>/mnt/devel/lib/appengine-java-sdk-1.7.4</gae.home>
<!-- GWT version -->
<gwt.version>1.6.3</gwt.version>
<appengine.target.version>1.7.4</appengine.target.version>
<!-- Upload to http://test.latest.<applicationName>.appspot.com by default -->
<gae.application.version>test</gae.application.version>
<!-- port defaults to 8080 -->
<gae.port>8082</gae.port>
<!-- Produce detailed JS during GWT compilation for development environment -->
<gwt.style>DETAILED</gwt.style>
</properties>
<profiles>
<!-- We can configure our integration server to activate this profile and perform gae:deploy,
thus uploading latest snapshot to the http://1.latest.<applicationName>.appspot.com automatically -->
<profile>
<id>integration-build</id>
<properties>
<gae.application.version>stage</gae.application.version>
<!-- Produce pretty JS during GWT compilation for test environment -->
<gwt.style>PRETTY</gwt.style>
</properties>
</profile>
<!-- This profile will activate automatically during release and upload application to
the http://2.latest.<applicationName>.appspot.com (We might want to set the 2nd version as
our applications Default version to be accessible at http://<applicationName>.appspot.com) -->
<profile>
<id>release-build</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<properties>
<!-- During release, set application version in appengine-web.xml to 2 -->
<gae.application.version>release</gae.application.version>
<!-- Produce compressed JS during GWT compilation for production environment -->
<gwt.style>OBFUSCATED</gwt.style>
</properties>
</profile>
</profiles>
</project>

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