Missing artifact log4j:log4j:bundle:1.2.17 - eclipse

I created a dynamic web application in eclipse Version: Kepler Service Release 1 using menu.
After that I converted it into a maven project using
configure -> convert to maven project. Then I did
maven->Add dependency and then searched for log4j.
After adding that on hovering over the tag
for log4j it displays Missing artifact log4j:log4j:bundle:1.2.17.
I can't update dependencies using maven. How to fix it?
Please also explain the reason for the error.
Here is the generated xml after adding log4j.
<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>Healthcare</groupId>
<artifactId>Healthcare</artifactId>
<version>0.0.1-HEALTHCARE</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<type>bundle</type>
</dependency>
</dependencies>
</project>

First why did you changed the default source folder location? The default is src/main/java and for webapp src/main/webapp. Apart from that a bundle for log4j does not exist on Maven Central just remove the <type>bundle</type> from your dependency, cause in Maven Central only a jar is available.

I always do the following trick:
In the dependencies management i edit the dependencies properties (select the dependencies with problem and click on properties button) changing the type from bundled to jar and that fixs the problem.
Well i hope that this solution work for you :) regards,

I too played with all the options provided above but it did not helped. By updating Maven dependencies forcefully my issue got resolved.
Go to project >> Maven >> Update Project
select the project and click OK.
Project will automatically try to download required jar but if still you are getting same error then do below step.
Go to project >> Maven >> Update Project >> check in the checkbox 'Force Update of Snapshots/Releases'
select the project and click OK.

Please check if the dependencies are correct or if it is missing.
<properties>
<springframework.version>4.2.1.RELEASE</springframework.version>
<jackson.version>2.5.3</jackson.version>
<log4j.version>1.2.17</log4j.version>
</properties>

By default (and the common usage), Maven would consume jars as a dependency. Just change the bundle to jar in your pom.xml file in the given dependency which is giving you an error.

Related

How to handle Dependencies in Eclipse Plugin Project using Tycho

I'm writing an eclipse plugin and I'd like to manage it using Maven, specifically dependencies.
Here is my pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.plugin</groupId>
<artifactId>SomePlugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<properties>
<tycho.version>0.24.0</tycho.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho.version}</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-versions-plugin</artifactId>
<version>${tycho.version}</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>luna</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/luna</url>
</repository>
</repositories>
</project>
I can successfully build this project, however Junit is not visible in my project, I'm not able to call any classes or method from Junit. So it seems I'm not properly using dependencies . Any idea how I can use dependencies? Junit is just an example, no dependency is available to me after a successful build.
I'm a noob to plugins and Maven so any help or guidance would be much appreciated.
You can create a p2 repository from a location of your own filled with jars/plugins/features (also put there jUnit) and then just add that repository to your pom.xml; the external dependency is not a good idea I think, I would recommend using a cached local repository.
How to create p2 repository : http://wiki.eclipse.org/Equinox/p2/Publisher#Features_And_Bundles_Publisher_Application.
Also, when building your Eclipse RCP product, use a custom target platform and also dump in there Eclispe SDK, JUnit+others jars, etc (just google Eclipe target platform)
A very late answer. For those who come on this now, there is the Orbit Eclipse repository which contain a lot of libraries useable with Tycho builds. Junit is one of these.

FailOnMissingWebXml error when validating pom.xml in Eclipse

When compiling a Maven project I get this error during validation phase of the pom.xml. It is quite a large project with complex build process. The project contains only JavaScript code and does not have to be compiled into war. I'm looking for a way to either:
Just disable the error through disabling failOnMissingWebXml (it appears to be a non-critical Eclipse error)
Find a solution that prevents this validation error in Eclipse (answers to related
questions didn't work for my specific scenario)
The full error:
Description Resource Path Location Type web.xml is missing
and <failOnMissingWebXml> is set to true pom.xml /testproject line 6
Maven Java EE Configuration Problem
After clicking on the error the problem seems to be on this line of 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.scs</groupId>
<artifactId>scs-control-panel</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging> **THE ERROR POINTS TO THIS LINE**
<parent>
<groupId>com.scs</groupId>
<artifactId>scs</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../scs</relativePath>
</parent>
<build>
</build>
<dependencies>
</dependencies>
</project>
Not sure if this is an Eclipse or Maven error, but probably Eclipse, since Maven runs smoothly through command line. It may also be a bug in Eclipse, I'm running Eclipse Java EE IDE for Web Developers Version: Mars.1 Release (4.5.1).
UPDATE1: I tried updating the project in Eclipse but no difference.
UPDATE2: I tried changing the package type from war to pom but no difference.
Everything in Maven revolves around plugins. Plugins are the programs that execute some behavior within the build process. Some plugin inclusions are implied without us having to declare anything.
These implied plugins have default configurations. For example, the maven-compiler-plugin is included in all projects without having to declare it. To override the default configurations we need to declare the plugin in our pom.xml file and set the configurations. For instance, you will see a lot of projects override the default version on the maven-compiler-plugin which has it's source and target set to Java 1.5. We can change to 1.8
<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>
</configuration>
</plugin>
</plugins>
</build>
This is just some theory behind the plugins to give you an idea of what's going on.
With that being said, in order to use <packaging>war<packaging>, the maven-war-plugin is used without us having to declare anything. Just like when using <packaging>jar</packaging>, the maven-jar-plugin's inclusion is implied.
The default configuration for the maven-war-plugin is to fail where there is no web.xml (that configuration property being failOnMissingWebXml). So if we want to override this default, we need to declare the plugin, then set the value for the property to false (not fail)
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
UPDATE
The war plugin now allows you to just use a property that it will lookup. This allows you to simply declare the property without having to override the plugin. To add this property, you would simply add the property failOnMissingWebXml with a value of false to the project <properties>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
Just by adding this, if you have no further configurations you need to add to the compiler plugin, you will no longer have to override and declare the compiler plugin in your pom.
UPDATE 2
So if you declare the maven-war-plugin and use a <version> 3.0.0+, the default for no web.xml failure will be set to false, so we no longer have to override the configuration property, though we still need to declare the plugin.
Do:
mvn clean eclipse:clean
Add this to your POM:
<packaging>war</packaging>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
I guess the easiest path is to choose the war plugin version 3. The default value for failOnMissingWebXml has been changed from true to false.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
Once set in your pom the nasty error vanishes for ever.
Add the below property to POM.xml
<failOnMissingWebXml>false</failOnMissingWebXml>
I was able to resolve this problem by adding this property in POM.xml as like below.
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>

gwt with maven and bootstrap eclipse starter project

I struggle for a few days now with integrating maven and gwt in eclipse. I was searching web for some ready to import project, but unfortunatelly everything crashed so long.
I am new to gwt. I would like learn it. Earlier I was using maven, spring and playframework with sbt.
I haven't use ant like build tool. But I like it integration between gwt and eclipe (I can click run in super dev mode).
One think is that I do not like in ant, I have to manually download jar and put it in classpath. I think it is unnecessary if maven can do it for me.
I would like also to use this library: gwtbootstrap3
I can't handle this on my own.
Can someone of You prepare for me that eclipse project, that I could just import.
Here is my newest 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>pl.korbeldaniel.btsp</groupId>
<artifactId>btsp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>btsp</name>
<properties>
<gwt.version>2.7.0</gwt.version>
<gwtBootstrap3.version>0.9.1-SNAPSHOT</gwtBootstrap3.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
<build>
<finalName>btsp</finalName>
<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>
But I cant run in like native gwt project.
Yes, it's a definitely possible. You just have to sift through a ton of documentation to figure it out.
You'll need Google Plugin for eclipse and the m2e (Maven Integration for Eclipse) plugin
After you have those, right click on a GWT project-> configure -> convert to Maven Project.
Now, to use GwtBootstrap3, all you need to do is add GWT and gwtBootstrap3 as dependencies in your pom. (Details here).
If you need any ready to import maven projects, you can clone GwtBootstrap3-demo project from github and run that as a web application. As for learning GWT, tutorials are your best option (Pay close attention to UiBinder for GwtBootstrap3).
click here, here and here for details about setting everything up.

The maven project generated by gwt-maven-plugin can't be imported into eclipse via import existing maven project

I firstly generated a gwt maven project by executing --
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.7.0
After that, the pom.xml is as follows:
<?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.boye.games</groupId>
<artifactId>games-gwt</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GWT Maven Archetype</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>${gwtVersion}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see
gwt-maven-plugin documentation at codehaus.org -->
<configuration>
<runTarget>LineThree.html</runTarget>
<modules>
<module>com.boye.games.linethree.LineThree</module>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
Then I imported this project into eclipse via built-in eclipse function -- import existing Maven project.
However, the process failed due to several reasons:
GreetingServiceAsync cannot be resolved to a type
Execution default of goal org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync failed:
Plugin org.codehaus.mojo:gwt-maven-plugin:2.7.0 or one of its
dependencies could not be resolved: Failed to collect dependencies for
org.codehaus.mojo:gwt-maven-plugin:jar:2.7.0 ()
(org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync:default:generate-sources)
google plugin can't identify this project as gwt web application automatically.
My environment as follows:
java version 1.7.0_03
eclipse version Kepler Service Release 2
gwt version 2.7.0
Please advice, thanks a lot!
I did another attempt to try in a win32 computer, the problem re-appeared even if I set up the environment as aforementioned working in my win64 computer.
So I really got confused, like Klarki said, I have to do some tweaks to get it work. I generated GreetingServiceAsync via mvn gwt:generateAsync then manually copy GreetingServiceAsync to source folder, then I remove <goal>generateAsync</goal> in pom.xml, then import project via eclipse's existing maven project. It works again!
Sadly see it not working intelligently.
The problem was with generateAsync, which in your case generates GreetingServiceAsync on execution. Eclipse probably wasn't configured to handle it properly and this class was not generated and eclipse reported the missing class warning.
Another thing that could be done to get the project to work was to run mvn package from command line and add the generated dir in target dir as source dir in eclipse (vie right clicking the project and selecting New -> source folder > browsing folder name > target > generated-sources > the right folder)
Also you may run into same issue after you do mvn clean - the generated GreetingServiceAsync will be deleted and the problem may come back.
The problem exists because eclipse isn't tightly integrated with maven and uses its own build system ignoring maven targets that you don't have plugins for. What you could do is to open eclipse preferences > maven > lifecycle mappings and there you can enable generateAsync to execute.
If you copy the generated class manually you have to keep in mind that you need to update it when needed, where as it is intended to generate automatically. So you loose this convenience.
This work for me:
I deleted the local maven gwt repository, in windows 7 it's in C:\Users\.m2\repository\com\google\gwt, and then make a
mvn clean complile
so maven re-import al dependencys.
After I changed my environment as follows:
java version "1.8.0_05"
eclipse Version: Luna Release (4.4.0)
Google plugin for Eclipse 4.4
I works like a charm.
Probably, it's a version incompatibility issue.

Maven Dependencies references non existing library

As stated above I have a problem regarding maven. In my current eclipse project I used maven for dependecy management and it worked fine until now.
The project is not working anymore and it states that:
Maven Dependencies references non existing library:
c:\.m2\repository\org\eclipse\lyo\oslc4j\core\oslc4j-core\1.1\oslc4j-core-1.1.jar'
If i check the folder there are files that have the same name as the jar but end on jar.lastUpdated.
I tried maven clean and maven update which did not work. The line in my pom.xml is marked red and states:
Missing artifact org.eclipse.lyo.oslc4j.core:oslc4j-core:jar:1.1
This is the content of my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http:/www.w3.org2001XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.or/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>rtc_oslc_common</groupId>
<artifactId>rtc_oslc_common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
This block is the one with the marker where it states the artifact is missing.
<dependencies>
<dependency>
<groupId>org.eclipse.lyo.oslc4j.core</groupId>
<artifactId>oslc4j-core</artifactId>
<version>1.1</version>
</dependency>
</dependencies>
</project>
I don't know why it is not just reloading the jars and instead stays in this weird state. Help very much appriaciated.
Basically Maven is telling you that it cannot find the dependency you declared in your pom.xml. The fact that there is a file called *.jar.lastUpdated means that Maven tried to download the dependency but wasn't able to fetch it.
First you could try to completely delete the folder containing the *.jar.lastUpdated and run the build again. Maven will then try to download the dependency again. Perhaps it was just a temporary error.
But as this dependency is not available in Maven Central, you may have to add the corresponding repository to your pom.xml.
Sometimes an officially stated dependency configuration is incorrect, too. For example, as of 2015-05-23 the Robolectric site says...
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>
... which gives the same error you describe. After banging my head for a while (of course this was the first time I've ever tried Maven), I ended up checking at Maven Central this URL: http://mvnrepository.com/artifact/org.robolectric/robolectric
Lo and behold, there is no version 3.0. Instead, there are versions "3.0-rc1" and "3.0-rc2". When I changed the dependency to "3.0-rc2", suddenly everything worked.
I got the error like this:
The container 'Maven Dependencies' references non existing library 'G:\m2\repository\org\apache\tomcat\tomcat-embed\7.0.65\tomcat-embed-7.0.65.jar'
I found the tomcat-embed is actually a *.pom file but not a *.jar
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-embed</artifactId>
<version>7.0.65</version>
<type>pom</type>
</dependency>
So I fixed this problem by:
delete tomcat-embed-7.0.65.jar.lastUpdated
copy a *.jar file to dir G:\m2\repository\org\apache\tomcat\tomcat-embed\7.0.65\
renamed to tomcat-embed-7.0.65.jar
But the other way to solve this problem?
Firstly, you repair, intenet problem. after that You must delete folders in maven repository folder. (For me C:\Users\ekomut.m2\repository)
If you have an Internet problem, you can see "*.jar.lastUpdated" .If you don't delete this folder, maven can not try download again.