Maven 2.2.1 fails to build EAR project with m2eclipse - java

I am having trouble building an EJB EAR with Maven in Eclipse 3.6 with the m2eclipse project builder. Curiously, a manual build (either on the command line or with "Run as -> Maven build") works fine. I have set up Eclipse to use an external Maven 2.2.1 installation.
The error message is as follows:
Build errors for my-app; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-ear-plugin:2.4.2:generate-application-xml (default-generate-application-xml) on project my-app: Failed to initialize ear modules
So apparently generation of the application.xml descriptor fails for some reason I could not yet determine.
In the error log view I have the following message:
Unknown artifact type[test-jar]
I have read in a forum that might be caused by a "test-jar" dependency that is missing "test" scope; however, I have double- and triple-checked for this and can't find any unscoped "test-jar" dependencies in my pom.xml files.
I've found the following entries with mvn help:effective-pom though:
<dependency>
<groupId>org.jboss.test</groupId>
<artifactId>jboss-test</artifactId>
<version>1.1.4.GA</version>
<exclusions>
<exclusion>
<artifactId>log4j</artifactId>
<groupId>apache-log4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- ... --->
<dependency>
<groupId>jboss.jms-integration-tests</groupId>
<artifactId>integration-mdb20</artifactId>
<version>1.0.1.GA</version>
</dependency>
<dependency>
<groupId>jboss.jms-integration-tests</groupId>
<artifactId>integration-mdb20-durable</artifactId>
<version>1.0.1.GA</version>
</dependency>
<dependency>
<groupId>jboss.jms-integration-tests</groupId>
<artifactId>integration-mdb20-selector</artifactId>
<version>1.0.1.GA</version>
</dependency>
<dependency>
<groupId>jboss.jms-integration-tests</groupId>
<artifactId>integration-mdb20-userTransaction</artifactId>
<version>1.0.1.GA</version>
</dependency>
<dependency>
<groupId>jboss.jms-integration-tests</groupId>
<artifactId>integration-mdb20-userTransactionDups</artifactId>
<version>1.0.1.GA</version>
</dependency>
<dependency>
<groupId>jboss.jms-integration-tests</groupId>
<artifactId>jms-integration-tests</artifactId>
<version>1.0.1.GA</version>
</dependency>
I have no idea where those dependencies come from or if they are relevant at all.
The most curious thing is that, like I said, building works fine when I do it manually.
However, this means that I can't use some m2eclipse features like WTP integration.
Any suggestions?

To find where dependencies come from, open your pom in m2eclipse's Maven POM editor. On the right hand side of the 'Dependency Hierarchy' tab, is the resolved dependency list. This is synonymous with the effective-pom dependency listing. Select any dependency on the right and where that dependencies comes from will be revealed on the left.

Related

spring-security-core conflicting version issue in build tree

I am trying to install spring-security-core to my project and here's how I am doing it in my pom.xml
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.0.7.RELEASE</version>
</dependency>
The issue is that when I build the project I see org.springframework.security.spring-security-core with version 4.2.9.RELEASE in my artifacts instead of 5.0.7.RELEASE. My pom.xml is deep down in my build tree and it's a part of a big spring boot project. artifact spring-security-core is not present in any other pom.xml in my tree.
From what I've read so far it looks like this is happening because something in the parent tree is downloading spring-security-core 4.2.9.RELEASE as a dependency without explicitly mentioning it in their pom.xml. How to debug this problem ?
In one of the parent pom.xml there's a dependency like this :
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.3.22.RELEASE</version>
</dependency>
Would that explain why spring-security-core old version is getting downloaded ? Any help is appreciated.
Check the dependency tree with this command
mvn dependency:tree
If spring-context-support also has spring-security, you can exclude that from the dependency by adding exclusions
example
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>4.3.22.RELEASE</version>
<exclusions>
<exclusion>
<groupId> groupid of the jar to be excluded </groupId>
<artifactId>artifact id of the jar to be excluded</artifactId>
</exclusion>
</exclusions>
</dependency>
Go to the location of parent pom.xml file and as run the command
mvn dependency:tree >> tree.txt
It will create a file with dependency tree. Search for "spring-security-core" you will find which version is downloaded.
There are couple of work around:
You can repeat this to each pom.xml as well to know from where it gets the reference.
If one of the pom referring the version then your dependency will not consider if its got resolve earlier.
Check if any po.xml file referring to any spring security related libraries. If so, what is there version. And if you need then as mentioned by #Vinay, exclude it so your library version gets referred.
If you want to download this version of library then mentioned it at the top, so it gets referred and no other version will downloaded.
There is no relation for spring security with spring-context-code. Refer this maven link.

Missing plugins found while loading a transformation on Kettle

I receive this error whenever I run my extraction from the command line, not in the Spoon UI.
Missing plugins found while loading a transformation
Step : MongoDbInput
at org.pentaho.di.job.entries.trans.JobEntryTrans.getTransMeta(JobEntryTrans.java:1200)
at org.pentaho.di.job.entries.trans.JobEntryTrans.execute(JobEntryTrans.java:643)
at org.pentaho.di.job.Job.execute(Job.java:714)
at org.pentaho.di.job.Job.execute(Job.java:856)
... 4 more
Caused by: org.pentaho.di.core.exception.KettleMissingPluginsException:
Missing plugins found while loading a transformation
My maven dependencies is as follows.
<dependency>
<groupId>rhino</groupId>
<artifactId>js</artifactId>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libbase</artifactId>
<version>5.1.0.0-752</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-big-data-plugin</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-mongodb-plugin</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>metastore</artifactId>
<version>5.1.0.0-751</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libformula</artifactId>
</dependency>
<dependency>
<groupId>simple-jndi</groupId>
<artifactId>simple-jndi</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-compiler</artifactId>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-core</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
</dependencies>
Am I missing anything?
before init kettleEnviroment
KettleEnviroment.init();
you should add this code like
StepPluginType.getInstance().getPluginFolders().add(new PluginFolder("your plugins path", false, true));
Having the MongoDB plugin as a dependency only works for compilation. When PDI runs it looks for a plugins/ folder under the current directory, and will load all plugins from there. You can override the location by setting the KETTLE_PLUGIN_BASE_FOLDERS system property. Either way, you'll want a plugins/ folder and to unzip the MongoDB plugin package (not the JAR) into plugins/. That should put a folder called pentaho-mongodb-plugin under plugins/, and if PDI is pointing at that plugins/ folder, it should load and use the plugin successfully at runtime.
You must run Kitchen from Kettle installation directory.
As written here:
http://wiki.pentaho.com/display/EAI/Kitchen+User+Documentation
Please make sure that you are positioned in the Kettle directory
before running the samples below. If you put these scripts into a
batch file or shell script, simply do a change directory to the
installation directory
I had the same error message after an update from version 7 to 8.3. In my case, it was the step 'Abort' and 'Attend' that caused the error. In version 8 these two steps aren't part of the library "kettle-engine-8.3.0.0-371.jar" anymore, they are now part of the library "pdi-core-plugins-impl-8.3.0.0-371.jar" in a new plugin. I had to add the plugin in the maven-dependencies:
<dependency>
<groupId>org.pentaho.di.plugins</groupId>
<artifactId>pdi-core-plugins-impl</artifactId>
<version>8.3.0.0-371</version>
</dependency>
But that was still not everything, I still got the error message. The reason: "To use non-native plugins with an embedded Pentaho Server, you must configure the server to find where the plugins reside" (https://help.hitachivantara.com/Documentation/Pentaho/8.0/Developer_Center/PDI/Embed).
So above the line KettleEnvironment.init() in my java-code, I added this one:
System.setProperty("KETTLE_PLUGIN_CLASSES", "org.pentaho.di.trans.steps.abort.AbortMeta,org.pentaho.di.trans.steps.append.AppendMeta");
KettleEnvironment.init();
This way worked for me. There's also a suggestion using a plugin-folder (see the link or the other answers) and working with KETTLE_PLUGIN_BASE_FOLDER instead.
Unfortunately, the error message doesn't mention which plugin is missing. I deleted and added them (in my local Spoon application) until I found exactly the one that was missing.
Just edit spoon.sh and add
OPT="$OPT -DKETTLE_PLUGIN_BASE_FOLDERS=$BASEDIR/plugins"
right after the line where the OPT variable is set.
This is actually the solution from mattyb. Editing spoon.sh will fix the problem for good.
Another solution is to create a symbolic link in your ${KETTLE_HOME}/.kettle directory which points to the plugins folder.

Failed to install Magnolia Data Module (version 2.3.0)

I've imported magnolia-module-standard-templating-kit maven dependency in Pom file in webapp. It's version is 2.3.0 and Magnolia version is 5.3. After build & run Tomcat server and start install modules, I encountered a failure as below:
Magnolia Data Module (version 2.3.0)
Could not install or update data module. Task 'Data AppLauncher group ordering' failed. (PathNotFoundException: /modules/ui-admincentral/config/appLauncherLayout/groups/data)
pom.xml:
<!-- Overlay Magnolia Empty Webapp. Alternatively, use the bundled-webapp or the enterprise-webapp. Dependencies versions are already imported by parent, so no need to replicate here. -->
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-empty-webapp</artifactId>
<type>pom</type>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-empty-webapp</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>com.mycompany.projects</groupId>
<artifactId>myTemplateModule</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>info.magnolia.contacts</groupId>
<artifactId>magnolia-contacts</artifactId>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-module-standard-templating-kit</artifactId>
</dependency>
Anyone can help me resolve this problem?
I managed to replicate the exception you get and i think the problem is the order you add the dependencies and do the "Start install" process.
if i first do a "Start install" with only the magnolia-empty-webapp dependencies and then i stop the server, add the magnolia-module-standard-templating-kit to the pom.xml and do another "Start install" i got the exception:
But if instead i do a "Start install" specifying all the dependencies (stk and empty-webapp) from the beginning i don't get an exception at all
I recommend you to add these dependencies as well for demo project and the pop theme
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-theme-pop</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>info.magnolia</groupId>
<artifactId>magnolia-demo-project</artifactId>
<version>${project.version}</version>
</dependency>

Maven retains older version of asm in repository

Initially, I had the maven dependency for asm version 3.2 in pom.xml file of my project. I update the same to version 4.1 using the following dependency
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>4.1</version>
<scope>compile</scope>
</dependency>
but now my project has both jar files in WEB-INF/lib - asm 3.2 and asm 4.1. I need some features of asm 4.1 but due to both jars being available asm 3.2 code is used because of which I cannot use the asm 4.1 feature.
Any help in this matter is appreciated.
The dependency for asm 3.2 is:
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.2</version>
</dependency>
Note the group IDs do not match. What is likely happening is that another of your dependencies is loading asm 3.2 as a transitive dependency. Maven's dependency resolution process cannot determine that the 4.1 version is supposed to override the 3.2 version due to the group ID difference, and there is a problem.
What you need to do is eliminate the 3.2 version. First figure out which dependency is causing Maven to pull it in, by running mvn dependency:tree or using the Eclipse POM editor's dependency hierarchy tab. Then find that dependency in your POM and add an exclusion:
<dependency>
<groupId>some.group.id</groupId>
<artifactId>dependency-pulling-in-asm</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
Maven documentation explains this further.
Give the following command after updating pom.xml
mvn clean

Maven error when resolving dependency

I am new to Maven and am trying to set up one of my first POMs. My application will cache using EhCache. Going to Maven Central Repo (link here) I copy-n-pasted the <dependency> tag and copy it into my pom.xml like so:
...many dependencies above this point
<dependency>
<scope>compile</scope>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>4.0.1.Final</version>
</dependency>
<dependency>
<scope>compile</scope>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<scope>compile</scope>
<groupId>jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>3.5.3</version>
</dependency>
...many dependencies below this point
When I save the changes, Eclipse builds the workspace and gives me an error on the opening <dependency> tag for EhCache 2.5:
Missing artifact net.sf.ehcache:ehcache:jar:2.5.0
So I figured that perhaps v.2.5.0 has something wrong with it, and repeated the same for 2.4.7 (the last 2.4.x release before 2.5.0). Same deal.
Since I'm so new to Maven, I don't even know where to begin looking. I tried Project >> Clean and even restarted Eclipse to see if it was just a typical Eclipse "quirk". Nope.
I am thinking:
Could EhCache be publishing bad JARs to the Maven repo?
Could Maven Repo have something wrong with it?
Could this be due to something else configured wrong in my pom.xml?
Could this be a "JAR hell" issue where I have a conflict somewhere on my dependency graph?
How would SO start tackling this problem? Thanks in advance!
It is usually safer to refer to search.maven.org. Dependency from there:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.5.0</version>
<type>pom</type>
</dependency>
Mind type pom. From module's pom:
This is a pom artifact to pull in ehcache-core and ehcache-terracotta
for clustering. Make sure to set 'type' to 'pom' in your dependency.
Aparently when someone does not need terracotta, ehcache-core will do perfectly fine as other answer states.
They use ehcache-core in the official documentation. Maven Central does not have a jar artifact for ehcache 2.5 which explains your error message.
Using ehcache-core changes the dependency to:
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.5.0</version>
</dependency>
Which successfully downloads on my machine (ehcache does not).
I dropped this into IntelliJ and it found it. I suspect there is something wrong with your settings. Try creating a project with only this dependency in it. If it fails to download, I would check your setting. e.g. .m2/settings.xml Are you using a Nexus server or maven proxy/cache?
BTW: A simpler way to search for JARs is to use http://mvnrepository.com/ which will find all the available versions and show you the XML you need to add.

Categories

Resources