Problem with JBoss dependencies in Maven - maven-2

I have code dependant on some JBoss provided libraries. I have added to my POM following dependency:
...
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
</repository>
...
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
<version>6.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
And I receive following error
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.jboss.aspects:jboss-transaction-aspects
Reason: Failed to build model from file 'C:\Users\User\.m2\repository\org\jboss\
aspects\jboss-transaction-aspects\1.0.0.GA\jboss-transaction-aspects-1.0.0.GA.po
m'.
Error: 'no more data available - expected end tags </dependency></dependencies><
/project> to close start tag <dependency> from line 48 and start tag <dependenci
es> from line 45 and start tag <project> from line 1, parser stopped on END_TAG
seen ...<groupId>org.jboss</groupId>\n ... #50:5' for project org.jboss.aspec
ts:jboss-transaction-aspects
I couldn't "google" it out. Any ideas?

It seems either your dependencies tags are not matching, or you don't have them.

Related

How to install a plugin in Jira?

I wanted to create a sample servlet as a Jira-plugin according to a tutorial.
I have built the code as it is and I used the following pom.xml to build the code.
When I run the servlet URL I'm getting the following issue about class cast.
[INFO] [talledLocalContainer] ERROR - 13:41:52,368 - com.atlassian.plugin.servlet.DefaultServletModuleManager - [http-bio-5990-exec-4] - Unable to create new reference LazyLoadedServletReference{d
escriptor=com.atlassian.plugins.tutorial.refapp.adminUI:test (null), servletContext=org.apache.catalina.core.ApplicationContextFacade#2829d93e}
[INFO] [talledLocalContainer] com.atlassian.util.concurrent.LazyReference$InitializationException: java.lang.ClassCastException: com.atlassian.plugins.tutorial.refapp.MyPluginServlet cannot be cast to javax.servlet.http.HttpServlet
[INFO] [talledLocalContainer] at com.atlassian.util.concurrent.LazyReference.getInterruptibly(LazyReference.java:149)
This is possibly a dependency issue in your pom.xml. Check to make sure you are not bundling resources into your plugin that already exist in the environment that is hosting your plugin.
In your case, you might want to check for this:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
With the key part here being <scope>provided</scope> indicating this resource is needed for compilation but does not need to be bundled with the plugin as it is already provided by the runtime environment. If this line doesn't exist or the scope is anything other than provided, then try adding/changing it.
See this page for more info: Dependency Issues during Plugin Initialisation

org.jibx: maven-jibx-plugin:1.2.1 - Error reading path

I am trying to execute a goal using maven-jibx-plugin version 1.2.1, but I am getting the following error:
[ERROR] Failed to execute goal org.jibx:maven-jibx-plugin:1.2.1:bind (default) on project XoXcertExIm: Error loading class java.lang.CharSequence: Error reading
path java/lang/CharSequence.class for class java.lang.CharSequence -> [Help 1]
I am using Maven 3.2.5, Java versions 1.8.0_11, and windows 7 as the OS.
There is an issue on Jibx to support Java 8 see Issue here
There is a Workaround in this comment that you can try.
I had the same problem...
Workaround was as easy as include newer "bcel" dependency to the plugin "maven-jibx-plugin":
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.6</version>
<dependencies>
<!-- Workaround to avoid error compiling with JDK 1.8 -->
<dependency>
<groupId>org.apache.bcel</groupId>
<artifactId>bcel</artifactId>
<version>6.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
You should include a new Maven repository definition in your "settings.xml" to get the new dependency:
<repository>
<id>apache-snapshots-repo</id>
<url>https://repository.apache.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
Regards

Passing parameters from jenkins to maven

I set my variables in jenkins like this :
http://i.stack.imgur.com/mipCP.jpg
testngVersion
I want to use in my pom.xml:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>%{testngVersion}</version>
<scope>test</scope>
</dependency>
I tried :
<version>%{env.testngVersion}</version>
What im doing wrong ?
I keep getting:
[ERROR] Failed to execute goal on project Testing: Could not resolve dependencies for project Framework:Testing:jar:1.0-SNAPSHOT: Failed to collect dependencies at org.testng:testng:jar:%{env.testngVersion}: Failed to read artifact descriptor for org.testng:testng:jar:%{env.testngVersion}: Could not transfer artifact org.testng:testng:pom:%{env.testngVersion}
It is not %{...}
It should be ${testngVersion}

How to use httpclient 4.1.x with Maven

httpclient version 4.0 works in my pom.xml:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.0</version>
</dependency>
...but versions > 4.0 don't compile:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1</version>
</dependency>
The error:
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: unknown:httpclient
Reason: Parent: null:httpmime:jar:null of project: unknown:httpclient has wrong
packaging: jar. Must be 'pom'. for project unknown:httpclient
Any idea how to use httpclient 4.1 with Maven?
confirmed, use Maven 3.0.x and it works! here is example from working pom.xml
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.3.2</version>
</dependency>
</dependencies>
I just tried same configurations
jar got downloaded from following location which is one of default repos
http://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.1
Just try after mentioning http://repo1.maven.org/maven2 explicitly in your pom file
and try using command line
and apache http client 4.1.1 version is also available now
It was a Maven issue: Using Maven 3.0.3 instead of 2.2.1 solved the problem.

Maven - how to put the build dependance jar files?

I run a simple CXF maven project http://cxf.apache.org/docs/using-cxf-with-maven.html, and get error below
[INFO] [cxf-codegen:wsdl2java {execution: generate-sources}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org/springframework/core/io/support/ResourcePatternResolver
org.springframework.core.io.support.ResourcePatternResolver
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: org/springframework/core/io/support/ResourcePatternResolver
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
I don't know how to put the springframework-core dependance ?
I tried below like most of answers
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>2.5.6</version>
</dependency>
</dependencies>
but it didn't help, I also don't know why it depends on springframework
It works if I put the jar file under $M2_HOME/lib, but is it correct way ? since when I solve this, it requires to add more lib there, can I put it into pom.xml somewhere ?
I tried to put <dependencies/> inside <build> tag, it doesn't work
my maven is 2.2.1 on windows
It works if I put the jar file under $M2_HOME/lib, but is it correct way ?
No, definitely not. To add a dependency, you need to declare it in your pom.xml, something like this:
<project>
...
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>???</version>
</dependency>
...
</dependencies>
</project>
But I don't understand why you would have to add this dependency, spring-core is a dependency of cxf, you should get it transitively. You're not providing enough context information for a more precise answer though.
You have to define it in the pom.xml
Read the docs at http://maven.apache.org/pom.html#Dependencies
You'll need to add this to your Maven pom.xml file in the <dependencies> section:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>???</version>
</dependency>
The version number will depend on which version of spring you're using. (I'm using 2.0 as the version #, along with spring 2.0.8).
Finally I found it by myself, it is due to the error of my springframework-2.5.5 package from local repository. The jar file is not correct. I notice this later in eclipse
Pascal's answer is also correct.
The springframework-2.5.5 is automatically download by maven, unfortunately it is broken, so it still complain the class, and if I put springframework-2.5.6 inside, even it will be downloaded, it will not be used, maven still think it loaded the springframework-2.5.5 into its classpath.
And if I put into %M2_HOME%/lib, surely it will be maven's classpath, and it is wrong to use it.
Since I met this kind of problem before, now I know what it is.
Summary: checking your dependance files to see whether the package is correct
BTW: Thanks for all especially pascal