How to disable karaf-maven-plugin 4 tight dependency constraint checks - java

Currently I am moving from karaf 3.0.5 to the newest version 4.0.2, I do assembly my own karaf with the karaf-maven-plugin. This is how my pom looks like.
<?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">
<parent>
<groupId>my.own.group</groupId>
<artifactId>assemble</artifactId>
<version>1.14.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<artifactId>karaf-customize</artifactId>
<modelVersion>4.0.0</modelVersion>
<packaging>karaf-assembly</packaging>
<dependencies>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>framework</artifactId>
<version>${karaf.version}</version>
<type>kar</type>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>standard</artifactId>
<classifier>features</classifier>
<version>${karaf.version}</version>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf.karaf</groupId>
<artifactId>apache-cxf</artifactId>
<classifier>features</classifier>
<version>${cxf.version}</version>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>enterprise</artifactId>
<classifier>features</classifier>
<version>${karaf.version}</version>
<type>xml</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>my.own.group</groupId>
<artifactId>kar-archive</artifactId>
<version>1.14.0-SNAPSHOT</version>
<type>pom</type>
<optional>true</optional>
</dependency>
<dependency>
<groupId>my.own.group</groupId>
<artifactId>karaf-branding</artifactId>
<version>1.14.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.alutam</groupId>
<artifactId>ziputils</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<extensions>true</extensions>
<configuration>
<javase>1.8</javase>
<bootFeatures>
<feature>jasypt-encryption</feature>
<feature>config</feature>
<feature>standard</feature>
<feature>region</feature>
<feature>management</feature>
<feature>bundle</feature>
<feature>package</feature>
<feature>kar</feature>
<feature>ssh</feature>
<feature>http</feature>
<feature>cxf</feature>
<feature>service-wrapper</feature>
<feature>jdbc</feature>
<feature>system</feature>
</bootFeatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
With this configuration I do get the following error for several dependencies.
Caused by: org.osgi.framework.BundleException: Unsupported 'Bundle-ManifestVersion' value: 1
at org.apache.karaf.features.internal.resolver.ResourceBuilder.doBuild(ResourceBuilder.java:88)
at org.apache.karaf.features.internal.resolver.ResourceBuilder.build(ResourceBuilder.java:78)
I guess it happens within this parser. The reason is some old third party libraries have only Bundle-ManifestVersion: 1 set within their manifest file.
With karaf-maven-plugin 3.x this didn't matter at all. In contrast the karaf-maven-plugin 4.x fails with message above.
The only way I know to fix this is either rebuild from source or repack the hole jar again.
Is there any other way like a configuration for the karaf-maven-plugin to disable this constraint check? Because it would be awful lot of work to get all of this bundles up an running, again.

I faced the same error when updating to Karaf 4 and you have two choices:
Osgify conflictive dependency using bndtools:
Download bnd tools
Open a shell where you have downloaded bnd-2.4.0.jar.
Type:
java -jar bnd-2.4.0.jar wrap -o osgify-dependency.jar dependency.jar
where dependency.jar is your third party and osgify-dependency.jar will be the output.
Deploy to maven repo overriding the previous maven coordinates, or deploy your thirdparty with different coordinates.
mvn deploy:deploy-file -Dfile osgify-dependency.jar ..
Enable the wrap protocol
Add to you maven karaf plugin wrap and wrapper features.
So you can use wrap protocol to fix your corrupted MANIFEST.MF
Inside some karaf features:
<bundle>wrap:mvn:group.id/third.party.artefact.id/version</bundle>
Inside your pom.xml notice feature wrap / wrapper.
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<extensions>true</extensions>
<executions>
</executions>
<configuration>
<!-- no startupFeatures -->
<bootFeatures>
<feature>feature</feature>
<feature>jaas</feature>
<feature>shell</feature>
<feature>ssh</feature>
<feature>management</feature>
<feature>bundle</feature>
<feature>config</feature>
<feature>deployer</feature>
<feature>diagnostic</feature>
<feature>instance</feature>
<feature>kar</feature>
<feature>log</feature>
<feature>package</feature>
<feature>service</feature>
<feature>system</feature>
<feature>wrap</feature>
<feature>aries-blueprint</feature>
</bootFeatures>
<installedFeatures>
..
<feature>wrapper</feature>
</installedFeatures>
</configuration>
</plugin>
Here you have the full code where i tested:
https://github.com/antoniomaria/gazpachoquest/blob/master/karaf-assembly/pom.xml

Related

Start a JavaFX application with maven and Java 17

My System:
Has multiple jdks (1.8, 16, 17)
Has IntelliJ's Maven
Is a windows 10 machine
I want to start my JavaFX app with maven. For that I use the javafx:run button inside of the Plugins menu.
Then I get errors about my jdk, being on a too-low-level (It's telling me I try to execute my Main method with my jdk-8), which is not true, as every single jdk-specification is set to jdk-17.
Please don't send me any links about other posts. I have already tried those and the steps there did not work out for me.
This is the error I get
Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Yes I already tried to change IntelliJs jdks, the JAVA_HOME variable and the run configs of maven itself
Sometimes I also get an error from maven, telling me there is no JavaFX version 17 in the maven repository (but the maven repo of my workplace). Is there a way to change my maven-repo to the default maven website?
This is 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>groupId</groupId>
<artifactId>M226a_miniproject</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>17</release>
<verbose>true</verbose>
<fork>true</fork>
<executable>C:/Users/[user.name]/.jdks/openjdk-17/bin/javac</executable>
<compilerVersion>1.3</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>ch.package.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.1</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>17.0.0.1</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-graphics -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>17.0.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>17.0.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>17.0.0.1</version>
</dependency>
</dependencies>
</project>
Maybe somethings wrong with the <version>0.0.8</version> in the second plugin?
Also: The error about the JRE not recognizing the class file does make zero sense, as even my maven is using a custom path to my jdk-17.
Edit: Updated pom.xml
(Fixed the problem on my Ubuntu 20.04 machine, but the error was the same)
The problem was, that I only had downloaded a jdk-17 into IntelliJ.
I simply installed the jdk-17 by running sudo apt install openjdk-17-jdk, which installs the jdk and sudo update-alternatives --config java, which updates the intex of the newest jdk (i think).
The last step was to restart IntelliJ and I was good to go.

module-info when one of my external libraries doesn't have a module-info

I am a beginner in Java coding, I am teaching myself JavaFX and making a project that uses JPA through Hibernate (I have no knowledge on Spring yet).
The problem I find myself having is that an essential external library doesn't have a module-info for me to refer to in my project.
I can have either JavaFX or mysql-connector-java working, but not both at the same time.
The connector I am using is: https://mvnrepository.com/artifact/mysql/mysql-connector-java version 8.0.19
When I exclude my module-info my JPA works, when I use my module-info my FX works
I asked my teacher for help but he doesn't seem to have an idea yet on how I can use my JavaFX and JPA in the same project. Does anyone have a good suggestion on how I can fix this issue?
My POM
<?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>com.tumblr.calscodingcorner</groupId>
<artifactId>dnd5e_database_maker</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>com.tumblr.calscodingcorner.application.App</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.19</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.4.12.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>11</version>
<type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
</dependencies>
My module.info
module dnd5e.database.maker {
requires javafx.controls;
requires java.persistence;
requires mysql.connector.java;
exports com.tumblr.calscodingcorner.application;}
Thanks in advance for any advice
Answering the title:
module-info when one of my external libraries doesn't have a module-info
You need to require (in module-info.java) the automatic module name corresponding to the name of the dependency jar (without the version), or to the Automatic-Module-Name declared in the jar's MANIFEST (if exists). Then maven will automatically add the jar to --module-path.
If you don't require the jar inside module-info, it will be added to --classpath in which case it will become part of the unnamed module and won't be visible by your module (only by automatic modules).
You can add -X to maven to see which dependencies are added to -classpath and which to --module-path
See the spec
[...] A named module cannot, in fact, even declare a dependence upon the unnamed module. This restriction is intentional, since allowing named modules to depend upon the arbitrary content of the class path would make reliable configuration impossible

how to fix "java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory" error when run java jar application

we are using eclipse+spring tool suite to build java application, we can start the application in eclipse IDE, but if we export as jar with all dependency jars, and run it on linux machine. we always gets error as following:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at com.ctrip.framework.apollo.demo.api.SimpleApolloConfigDemo.<clinit>(SimpleApolloConfigDemo.java:22)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
here is our POM.xml below:
<?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">
<parent>
<artifactId>apollo</artifactId>
<groupId>com.ctrip.framework.apollo</groupId>
<version>1.3.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-demo</artifactId>
<name>Apollo Demo</name>
<packaging>jar</packaging>
<properties>
<java.version>1.7</java.version>
<github.path>${project.artifactId}</github.path>
</properties>
<dependencies>
<dependency>
<groupId>com.ctrip.framework.apollo</groupId>
<artifactId>apollo-client</artifactId>
<version>${project.version}</version>
</dependency>
<!-- for spring demo -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<!-- for spring boot demo -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<!-- for refresh scope demo -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-context</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</dependency>
<!-- take over jcl -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
</dependencies>
</project>
2.1 we already included slf4j-log4j12 and slf4j-api as depdency.
2.2 the application can run normally in eclipse IDE window.
2.3 if we export executable jar including all dependencies, and ship jar on linux machine, run the jar file will get the above error.
2.4 we also checked generated jar package on windows with winRAR, the slf4j and log4j* jar package were there, see picture below.
we have struggled this for half day, but did not get any progress. Hope each expert can share with us some light or any suggestions. really appreciated!!!
You need to tell maven to compile the dependencys like this, the jars are compiled but you need the src in youre jar and not the jars in there:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<configuration>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
and dependencys normaly have a <scope>compile</scope> tag, to tell the compile that they are needed at runtime
I've faced a similar problem few days ago, right I add the jar libraries but the core (scripts/classes) of the jar file are no included due some reason I was able to solve that problem by right click on the jar file go to properties and set the class path for the classes of that jar folder.
if you wanna check that the jar file has no class Def inside it explore the jar file from the explorer and double click on any class you'll see a page showing up and says there's no script for this class and it asks you to set the class path.
Another approach I tried which also worked for me is I've imported the same jar files on netbeans and they worked 100%

Handling 3rd party dependencies in OSGI

I'm trying to learn OSGI and figured I would build a simple rest application using Spark Servlet.
https://mvnrepository.com/artifact/com.sparkjava/spark-core/1.0
Within my maven build plugin, I embed Spark-Core. However, after I build and run the bundle, it tells me there is a wiring package problem. So I add the package import, rinse and repeat. I'll get a different wiring package problem, so then I add the dependency, etc.
This seems like a long tedious process to add one package after another. What's the correct way to do this?
POM
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>osgi-demo</artifactId>
<groupId>com.osgi-hacking</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
<artifactId>osgiclient</artifactId>
<dependencies>
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.7.2</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-server</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-servlet</artifactId>
<version>9.4.8.v20171121</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>
${project.groupId}.${project.artifactId}
</Bundle-SymbolicName>
<Bundle-Name>
CUSTOM :: GREETER CLIENT :: BUNDLE
</Bundle-Name>
<Bundle-Version>
9.4.8.v20171121
</Bundle-Version>
<Bundle-Activator>
com.osgi.client.Activator
</Bundle-Activator>
<Embed-Dependency>
spark-core
</Embed-Dependency>
<Import-Package>
*
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
The spark core jar is already a bundle.
So there is no need to embed it. Simply install it as well as its dependendencies (which is mainly jetty) in OSGi.
For your own bundle. Simply remove all inside . The defaults of the maven bundle plugin will produce what you need.
It will detect the packages you need and write Import-Package statements for them. When you then have spark-core installed as a bundle it should work fine.

Maven null dependency and multiple annotations on this line

Something has gone wrong with my pom and I have a blank dependency and artifactId in the xml but get the same error whether I delete the tags or not.
I am using eclipse with m2eclipse installed in my home folder on Linux Mint 14 with maven version 'Apache Maven 2.2.1 (rdebian-8)' installed
Here is 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>TransferHandler</groupId>
<artifactId>TransferHandler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.4.6-rc1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-vfs2</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.49</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.2</version>
<classifier>ftp</classifier>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<artifactId></artifactId>
</dependency>
</dependencies>
</project>
There are three error messages displayed:
On line1:
Multiple annotations found at this line:
- null (org.apache.maven.plugins:maven-resources-plugin:2.5:resources:default-resources:process-resources)
- null (org.apache.maven.plugins:maven-resources-plugin:2.5:testResources:default-testResources:process-test-
resources)
On line70:
Multiple annotations found at this line:
- Project build error: 'dependencies.dependency.groupId' for null::jar is
missing.
- Project build error: 'dependencies.dependency.version' for null::jar is
missing.
On line 71:
Project build error: 'dependencies.dependency.artifactId' for null::jar is missing.
It seems like the one on line 70 with the empty tags is the root cause (excerpt below) but I'm not sure.
<dependency>
<artifactId></artifactId>
</dependency>
Even if I delete the empty tags from the xml and refresh maven and the project the error remains. On my Dependencies tab I see a jar with a '?' next to it but can't delete it and in my Dependency Hierachy tab I see a ' : [compile]' jar but can delete or exclude it.
How can I remove this ghost/null jar?
Try This Header
<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">
Good Luck !
I found a way around the problem using git but was not able to solve it directly by removing the offending packages.
The work-around was to shutdown eclipse, remove the pom and then use git to discard changes in the working directory. Commands:
rm pom.xml
git checkout -- pom.xml
Then the pom should reappear returned to its state at the last commit (which luckily for me was before this error arose). Not a very satisfying answer but at least it worked. If anyone posts an answer and explanation to the heart of the real problem (ie why can't I remove a null package and how did it get there in the first place) I would still be happy to accept it.

Categories

Resources