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

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>

Related

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

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.

AspectJ annotations are not working in JAVA maven project (Not spring project)

I'm trying to implement AspectJ annotations in JAVA maven project without spring. I have added Aspects and create annotation. But its not invoking the Aspects where i have added as Annotation to the method..Below is my code..Also the project link - https://github.com/chandru-kumar/aop-example
I have added aspectj maven plugin as well..But its not getting invoked..Can you pls help..? Not sure what I'm missing.
I haven't found any example without Spring project..
Pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.aop.example</groupId>
<artifactId>aop-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.9.6</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.11</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
</plugin>
<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>
<useIncrementalCompilation>false</useIncrementalCompilation>
</configuration>
</plugin>
<!-- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
</configuration>
</execution>
</executions>
</plugin> -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
com.aop.example.Test
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
JAVA - Aspects - Advice
package com.aop.advices;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
public class SysoutAdvice {
#Around("#annotation(com.annotations.Sysout)")
public Object print(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
System.out.println("Start....");
Object object = proceedingJoinPoint.proceed();
System.out.println("End....");
return object;
}
}
JAVA - Annotation
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
#retention(RUNTIME)
#target(METHOD)
public #interface Sysout{}
I can tell that you are an AspectJ beginner. You made many mistakes. But do not worry, you are going to learn and get more experience over time.
Annotation must have RUNTIME scope
Otherwise the compiled code will not have an annotation to intercept, only the source code, which does not help.
Aspect must have #Aspect annotation
Otherwise the AspectJ compiler will not identify the class as an aspect.
Avoid double log output
If you do not add && execution(* *(..)), the aspect will intercept both call and execution joinpoints. The effect would be double log messages, because the aspect advice is triggered twice.
Add missing Maven plugin execution
Otherwise the AspectJ Maven plugin does not compile anything, because you did not tell it what to do.
Delete redundant AspectJ dependencies
Otherwise the Assembly plugin will pack them into the executable JAR, blowing it up to size 13.4 MB. But actually, you only need the AspectJ runtime aspectjrt in order to run an application when using compile-time weaving. The other two are for load-time weaving (aspectjweaver) and for the AspectJ compiler (aspetjtools), both of which you do not need during runtime.
If you follow my advice to remove those two, the JAR size shrinks dramatically to 0.12 MB. That is more than a factor 100 smaller.
Make sure the old AspectJ Maven plugin uses an up-to-date AspectJ compiler
The version number should be the same as the one used for aspectjrt. So you do not need aspetjtools as a runtime dependency, but as a plugin dependency, if you want to make sure you have identical versions.
This step is optional, but AspectJ Maven 1.11 uses AspectJ Tools 1.8.13 by default. This is fine if you just compile Java 8 code, because AspectJ Maven 1.11 does not support more than Java 8.
If you want a more modern plugin supporting AspectJ 1.9.7.M3 and Java 16, please look at the dev.aspectj plugin version (please note the other Maven group ID!).
There are other suboptimal things that should be changed in your Maven configuration, but this is the most important stuff, which makes your project run and your executable JAR small.
Update: Here is my pull request which fixes the problems above and a few more (see commit comments).
Consider writing this in your 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.aop</groupId>
<artifactId>AOPconcept</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>AOPconcept</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>6.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context
-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.9.1</version>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-aop -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>6.0.1</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.9.9.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<complianceLevel>1.5</complianceLevel>
</configuration>
<executions>
</executions>
</plugin>
</plugins>
</build>
</project>

Maven will not export runable JAR

So I have a small maven project in eclipse, if I export a runable JAR and select:
Package required libaries into generated JAR
it works fine.
I should note that one of my JAR's is maven controlled (Univocity) the other is a local Oracle JDBC JAR. I want to include both of these in my runable JAR package so I can deploy a single JAR to production and execute it with a single command.
In my POM I added maven-assembly-plugin and when I use mvn package, I get a JAR with the Univocity library, but it skips the Oracle JAR.
How can I get it to bundle the Oracle JAR into the final output ?
Here is the POM:
<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>au.com.myco</groupId>
<artifactId>MyCoOracleExtractor</artifactId>
<version>0.0.4</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<univocity.version>2.0.0</univocity.version>
</properties>
<dependencies>
<dependency>
<groupId>oracle.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
<type>jar</type>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc6-11.2.0.4.jar</systemPath>
</dependency>
<dependency>
<groupId>com.univocity</groupId>
<artifactId>univocity-parsers</artifactId>
<version>${univocity.version}</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assembly:package</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>au.com.myco.MyCoOracleExtractor</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I did try using maven-dependency-plugin, but it didnt solve the problem bundling them into the single JAR.
You have to install it manually because Oracle didn't let maven got any of their jars : so you got to install it manually with the command mvn install:install -Dfile=<path to file> ... and put it in your pom.xml like any other dependency without the <SystemPath> like this :
<dependencies>
<dependency>
<groupId>oracle.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
</dependecies>
In my case : when i want to deploy my application in tomcat : i got to put the jar ojdbc6 directly in the folder lib of tomcat.

Maven Webapp Project not recognizing the custom ruleset during build

I have a Maven WebApp project (Just a HelloWorld Servlet) in Eclipse and running tomcat server. My ultimate aim is to fail the build if the code contains out.print statements. I have defined the maven pmd plugin 2.5 in the pom.xml as below and defined a customized ruleset in a file called sop.xml as below.
But when I right click the project -> Run As -> Maven Build and try to package it, the build is successful and creating the war file. I want the build to fail because the .java code contains the out.print statements.
I am new to Maven and requesting all your kind help on this regard. Thanks.
Ruleset file(sop.xml):
<?xml version="1.0"?>
<ruleset name="Custom ruleset" xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0
http://pmd.sourceforge.net/ruleset_2_0_0.xsd"
xsi:noNamespaceSchemaLocation="http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
<description>This ruleset checks my code for println statements</description>
<rule ref="rulesets/JavaLogging.xml" message="Must handle exceptions">
</rule>
</ruleset>
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>MavenWebGroupId</groupId>
<artifactId>MavenWebArtifactId</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>MavenWebName</name>
<description>MavenWebDescription</description>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
<skip>false</skip>
<targetJdk>${compile.source}</targetJdk>
<rulesets>
<!-- Custom local file system rule set -->
<ruleset>c:\rulesets\sop.xml</ruleset>
</rulesets>
<linkXref>true</linkXref>
<failOnViolation>true</failOnViolation>
</configuration>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>build</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
</dependencies>
</project>
Looks like maven-pmd-plugin doesn't executed during packaging. To calling this plugin during packaging define it as follows:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.5</version>
<configuration>
...
</configuration>
<dependencies>
...
</dependencies>
<executions>
<execution>
<id>run-pmd</id>
<phase>prepare-package</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
Note to <executions> tag.

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>