Unable to generate session beans for entity classes because EJB Lite classes are not available on project classpath - jpa

The image shows the persistence.xml configuration and
the popup window where I try to create the new session beans.
My setup is
Netbeans 12.6
Jakarta ee9
JDK 17
Glassfish 6.2.1
I have tried to reinstall netbeans, reinstall the server tried to create a new project using ant build script adding the persitence libs manually but I am still getting the same error.
The pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.techbay</groupId>
<artifactId>Techbay</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Techbay-1.0-SNAPSHOT</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<jakartaee>9.0.0</jakartaee>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>jakarta.persistence</groupId>
<artifactId>jakarta.persistence-api</artifactId>
<version>3.1.0-RC2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>javax.persistence</artifactId>
<version>2.2.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>${jakartaee}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

I was finally able to solve this problem by adding to my POM
<dependency>
<groupId>org.glassfish.main.packager</groupId>
<artifactId>glassfish-ejb-lite</artifactId>
<version>5.0</version>
</dependency>
Then I realized that glassfish-ejb-lite-5.0.jar is not available in maven repository so I manually downloaded the source jar glassfish-ejb-lite-5.0-sources.jar from the net and manually added it to my local repository.
This solved the problem for now till the glassfish-ejb-lite.5.0 is officially available in maven central.
I hope this helps somebody with a similar problem.

Related

Fat jar from scala project throws error when run

I created Scala project using Maven as build tools. I try to build fat jar that later I will be able to run from command line. I wrote a program that use Keycloak library to create users with REST API. It works fine when I run it straight from the Intellij but when I compile and run jar it gives me following error which I assume is result of me misconfiguring maven and not including all required dependencies?
Exception in thread "main" javax.ws.rs.ProcessingException: RESTEASY004655: Unable to invoke request: javax.ws.rs.ProcessingException: RESTEASY003215: could not find writer for content-type application/x-www-form-urlencoded type: javax.ws.rs.core.Form$1
at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:328)
[...]
My pom.xml
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.generator</groupId>
<artifactId>data-generator</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<exec.mainClass>com.generator.GeneratorApp</exec.mainClass>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.13.8</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>18.0.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.4.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.generator.GeneratorApp</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And commands I am using to compile and run:
mvn clean compile assembly:single
java -cp ./target/data-generator-1.0-SNAPSHOT-jar-with-dependencies.jar com.generator.GeneratorApp
My experience with Maven is very limited (usually i was using SBT when working with Scala). I googled and searched through StackOverflow but I am stuck on this for some time now.
Let me know if you need any more details. I tried to include everything I thought is relevant.
In my case, to fix it, I had to include following dependencies in pom.xml:
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.13.2.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>3.13.2.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.13.2.Final</version>
</dependency>
Not sure why I need it, I thought they would be included automatically based on my other dependencies (Keycloak), which makes me think that it is workaround not actual solution.

jakarta.servlet with Tomcat 9 - Not Found Issue

I have a application which I am running using eclipse and tomcat 9 server.
When I run the application, its opens then index.html page in browser, but the API's called inside index page are erroring with 404 status.
I tried multiple things from various stackoverflow page but nothing seems to work.
I have a Httpservlet with following declaration
#WebServlet("/api/modules")
public class ModuleController extends HttpServlet {
#Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
// logic
}
}
Even if I directly try to hit localhost:8080/application-context/api/modules
I get the same 404 error.
Also my application doesn't have a web.xml.
Note: The application is working fine on other people's system.
Following is the pom.xml for reference.
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ch.bfh.ti</groupId>
<artifactId>academia-02</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<!-- General properties -->
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Version properties -->
<servlet.version>5.0.0</servlet.version>
<jackson.version>2.13.1</jackson.version>
<postgresql.version>42.3.2</postgresql.version>
<jetty.version>11.0.8</jetty.version>
<h2.version>2.1.210</h2.version>
<junit.version>5.8.2</junit.version>
<rest-assured.version>4.5.0</rest-assured.version>
<!-- Checkstyle properties -->
<checkstyle.config.location>src/etc/checkstyle.xml</checkstyle.config.location>
<checkstyle.header.file>src/etc/checkstyle-header.txt</checkstyle.header.file>
</properties>
<dependencies>
<!-- Servlet dependencies -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- Database dependency -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jaxrs_2.10</artifactId>
<version>1.3.1</version>
<scope>compile</scope>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
<version>${jetty.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M5</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.11.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>site</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.basedir}/target/site/images</outputDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/site/markdown/images</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.1.2</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
404 error reference:
HTTP Status 404 – Not Found
Type Status Report
Message The requested resource [/academia-02/api/modules] is not available
Description The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
Also I have already tried the following:
Changing tomcat version
adding a web.xml
clean build the application and then run on tomcat
checked that generated classes contains the Servlet class in proper location
Update tomcat properties -> Switch location
Update tomcat properties -> user tomcat installation in server location
Can you please let me know what can be done here ?
You're declaring a dependency on Servlet Spec 5.0 (and explicitly state that you're using a Jakarta servlet).
Thus, it's mandatory that you're using Tomcat 10. Works as declared/designed. Not an issue.

The POM for jar is invalid, transitive dependencies will not be available

I want to provide external dependency to my maven project in eclipse. Therefore, I ave copied the jar file and its POM.xml directly in the local Maven Repository. But somehow Eclipse is complaining that the POM for the jar is invalid.
My pom.xml for jar file in local Repository looks like below:
<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>
<parent>
<groupId>com.b.t</groupId>
<artifactId>v-parent</artifactId>
<version>3.9.0</version>
</parent>
<scm>
<developerConnection>scm:svn:url/</developerConnection>
</scm>
<artifactId>v-p</artifactId>
<version>1.1.0</version>
<name>p</name>
<build>
<plugins>
<!-- Plugin required to build java classes from XSD using XJC -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<arguments>-npa</arguments>
<schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
<packageName>com.b.t.v.fusion.p.generated</packageName>
<schemaFiles>pConfig.xsd</schemaFiles>
<outputDirectory>${basedir}/target/generated-sources</outputDirectory>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<!-- Plugin required to add the generated sources to the classpath -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>com.b.t</groupId>
<artifactId>v-fusioninterface</artifactId>
</dependency>
<dependency>
<!-- FFT -->
<groupId>com.github.wendykierp</groupId>
<artifactId>JTransforms</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<!-- Reading and writing of MATLAB files -->
<groupId>net.sourceforge.jmatio</groupId>
<artifactId>jmatio</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>doclint-java8-disable</id>
<activation>
<jdk>[1.8,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
I have already checked similar posts and have done necessary changes in eclipse.ini (specifying JDK's JRE as vmargs n all). My dependency in MAven Project looks like below:
<dependency>
<groupId>com.b.t</groupId>
<artifactId>v-p</artifactId>
<version>1.1.0</version>
</dependency>
Please note that the same jar file with corresponding POM.xml is working well for my colleague in Intellij.
I am using Eclipse Luna just for info. I also have checked in my Eclipse that the Installed JRE is jdk1.8.0_144.
Also I am getting the same error when I use mvn clean install on command prompt.
Could someone please suggest what can I check more ?
You cannot just copy the files into your local repo, you need to install them. There are instructions here: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
In your case is would be something like:
mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile>

Generate WSDL and Copy in Maven Projects

I can generate WSDL directly from service GUI as picture below.
But In the Maven project I don't see such "Generate and Copy WSDL...". My question is How to enable it in Maven Project ?
Is there anything that I am missing. I am also attaching my pom.xml.
Thank you.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.avalant</groupId>
<artifactId>OTPMaven</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>OTPMaven</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.12</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.7</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
<showDeprecation>false</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>6.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
As I have not got answer to this question. I have found temporary solution.
I am using command line. JDK's wsgen command to generate required output.
#echo off
set WSGEN="C:\Java\jdk1.6.0_39\bin\wsgen.exe"
set J1="C:\Java\jdk1.6.0_39\lib\tools.jar"
set J2="C:\Java\glassfish-3.1.2.2\glassfish\modules\webservices-osgi.jar"
set J3="C:\Java\glassfish-3.1.2.2\glassfish\modules\endorsed\webservices-api-osgi.jar"
set J4="C:\Java\glassfish-3.1.2.2\glassfish\modules\jaxb-osgi.jar"
set J5="C:\Java\glassfish-3.1.2.2\glassfish\modules\endorsed\jaxb-api-osgi.jar"
set J6="C:\Java\glassfish-3.1.2.2\glassfish\modules\javax.ejb.jar"
set J7="D:\NetBeansProjects\OTP\target\OTP-1.0\WEB-INF\lib\commons-lang3-3.1.jar"
set J8="D:\NetBeansProjects\OTP\target\OTP-1.0\WEB-INF\lib\commons-codec-1.8.jar"
set OUTPUT_DIR="D:\NetBeansProjects\OTP"
#echo on
%WSGEN% -classpath %J1%;%OUTPUT_DIR%\target\classes;%J2%;%J3%;%J4%;%J5%;%J6%;%J7%;%J8%; -d %OUTPUT_DIR%\jax-ws -Xendorsed -keep -wsdl -r %OUTPUT_DIR%\jax-ws -s %OUTPUT_DIR%\jax-ws -verbose com.avalant.ws.GenerateOTPWS

GWT maven project with server side dependencies

I have a maven GWT project under eclipse and since I added some server side dependencies the maven plugin doesn't compile anymore. Here follows more info about the context:
maven 3.0.3;
GWT 1.5.3;
GWT maven plugin org.codehaus.mojo:gwt-maven-plugin:1.2 (the latest compatible with GWT 1.5.3, http://mojo.codehaus.org/gwt-maven-plugin-1.2/).
The goal gwt:compile of the GWT maven plugin completes successfully if I don't add dependencies other than the GWT ones:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
When I add any other dependency, the goal gwt:compile fails:
[INFO] establishing classpath list (scope = compile)
[ERROR] Exception in thread "main" java.lang.NoSuchMethodError: org.eclipse.jdt.internal.compiler.Compiler.<init>(Lorg/eclipse/jdt/internal/compiler/env/INameEnvironment;Lorg/eclipse/jdt/internal/compiler/IErrorHandlingPolicy;Lorg/eclipse/jdt/internal/compiler/impl/CompilerOptions;Lorg/eclipse/jdt/internal/compiler/ICompilerRequestor;Lorg/eclipse/jdt/internal/compiler/IProblemFactory;)V
[ERROR] at com.google.gwt.dev.javac.JdtCompiler$CompilerImpl.<init>(JdtCompiler.java:93)
[ERROR] at com.google.gwt.dev.javac.JdtCompiler.<init>(JdtCompiler.java:231)
[ERROR] at com.google.gwt.dev.javac.JdtCompiler.compile(JdtCompiler.java:193)
[ERROR] at com.google.gwt.dev.javac.CompilationState.compile(CompilationState.java:115)
[ERROR] at com.google.gwt.dev.GWTCompiler.distill(GWTCompiler.java:327)
[ERROR] at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:564)
[ERROR] at com.google.gwt.dev.GWTCompiler.run(GWTCompiler.java:554)
[ERROR] at com.google.gwt.dev.GWTCompiler.main(GWTCompiler.java:214)
I did search a configuration parameter about classpath/dependencies in the gwt:compile (http://mojo.codehaus.org/gwt-maven-plugin-1.2/compile-mojo.html) with no success.
I would like to use server side dependencies alongside GWT ones telling the GWT plugin to not consider the non-GWT dependencies.
working pom (gwt:compile completes successfully):
<?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>mygroupid</groupId>
<artifactId>projectname</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>project name</name>
<organization>
<name>My company</name>
<url>my company url</url>
</organization>
<properties>
<gwt.version>1.5.3</gwt.version>
</properties>
<build>
<finalName>final name</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<ajdtVersion>none</ajdtVersion>
</configuration>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>org.mycompany.myproject.Main/welcomeGWT.html</runTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warSourceDirectory>war</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
not working pom (gwt:compile throws exception):
<?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>mygroupid</groupId>
<artifactId>projectname</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>project name</name>
<organization>
<name>My company</name>
<url>my company url</url>
</organization>
<properties>
<gwt.version>1.5.3</gwt.version>
</properties>
<build>
<finalName>final name</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
<version>2.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<ajdtVersion>none</ajdtVersion>
</configuration>
<version>2.9</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>org.mycompany.myproject.Main/welcomeGWT.html</runTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warSourceDirectory>war</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.ibatis</groupId>
<artifactId>ibatis-sqlmap</artifactId>
<version>2.3.4.726</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>3.6.0</version>
</dependency>
<!-- GWT -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Are you using JasperReport in our project? I remember having a problem using JasperReport and GWT. JasperReport includes a different version of the org.eclipse.jdt.internal.compiler.Compiler than what GWT is expecting.
I think you can fix this by simply changing the order of the class path (was already suggested in the comments). If that does not help, try to update your GWT version. Or try to find a version of JasperReport which includes a version of the org.eclipse.jdt.internal.compiler.Compile class that works with GWT.
I faced a similar error in our QA Linux environment during deployment of our web application and we managed to fix it. This problem wasn't even there when I deployed into my local Windows 10 and Linux Ubuntu virtual machine. My environment configuration is as follows
Ubuntu 16.04 LTS
Apache Maven 3.3.3
Apache Tomcat/8.0.32 (Ubuntu)
JVM 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14
The problem was because there were two eclipse Compiler classes that were found in two different jar files, and this creates conflicts in the classpath during tomcat deployment. The culprits are files ecj.jar and jdtcore.jar
My original pom.xml snipet is as below
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
<version>6.3.0.Final</version>
</dependency>
<dependency>
<groupId>net.sourceforge.dynamicreports</groupId>
<artifactId>dynamicreports-core</artifactId>
<version>3.1.3</version>
</dependency>
The Maven dependency tree for drools-compiler introduces ecj.jar file.
The Maven dependency for dynamicreports-core.jar file that has jasperreports.jar that in turn introduces jdtcore.jar file.
Solution:
We upgraded the version of dynamicreports-core that introduces jasperreports.jar file.
Note:
I was able to fix this issue after reading http://www.cnblogs.com/xiaoMzjm/p/4566672.html. Credits to this blogger.
<dependency>
<groupId>net.sourceforge.dynamicreports</groupId>
<artifactId>dynamicreports-core</artifactId>
<version>4.1.0</version>
</dependency>