I have set up a WildFly Maven project with a local dependency. I compile the library (mvn compile) which is used as a local dependency and install it (mvn install) in the local Maven repository. Doing this allows me to successfully compile the WildFly project using Maven. The problem I encounter is that it fails to deploy (mvn wildfly:deploy), because it can't find the classes referenced in the local library, throwing a NoClassDefFoundError exception as result.
The library dependency is included as follows:
<dependency>
<groupId>mygroup</groupId>
<artifactId>library</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
I'm using the WildFly Maven plugin. Is there anything I should be doing differently?
<scope>provided</scope> - when you say provided you are saying that this lib will be available at runtime and does not need to be compiled with the current jar.
Hence what the artifact that you build using mvn compile/install will not include that library dependency.
This means that the application container(wildfly) you are running in must provide the jar.
You are getting the error because you havn't provided the library.jar in your application container nor have to included in your build file.
There are two solutions:
Explicitly defined the dependency in you jboss configuration:
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.1/html/Development_Guide/Add_an_Explicit_Module_Dependency_to_a_Deployment1.html
Change the scope from provided to compile: <scope> compile </scope>
Related
Missing artifact com.oracle:ojdbc6:jar:11.1.0.7.0
I am using Spring tool suite IDE for developing spring maven project which is similar ecllipse IDE, I found Solutions for this issue on stackoverflow but it doesn't work for me'.
I tried two links:
Missing artifact com.oracle:ojdbc6:jar:11.2.0.3,
Oracle JDBC ojdbc6 Jar as a Maven Dependency
but still I am getting
Missing artifact com.oracle:ojdbc6:jar:11.1.0.7.0
error in pom.xml, I am now stuck at this point.
its because of ojdbc jar is not available on maven repo. so you have to add this dependency from local relative path
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.1.0.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc6.jar</systemPath>
</dependency>
You can download ojdbc jar from http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
I have a multi-module maven project which has a pom file with packaging type as jar as described below. Another module in the project depends on this jar. When executing command mvn clean install, everything works fine but when executing mvn clean install -DskipTests=true, the project throws an error complaining unable to resolve dependency for the jar.
<artifactId>project.artifact.id</artifactId>
<packaging>jar</packaging>
<name>Project Name</name>
<description>Project Description</description>
<dependencies>
....
</dependencies>
Do I need to include some jar plugin or any other workaround for the same ?
The problem was due to version mismatch. Verify the versions of dependencies included and check for any conflicting dependency versions.
My hope was that it would be easy to get Maven to run our application on any machine by simply deploying the pom.xml and using the maven exec goal.
The main class to run is inside the jar which is produced from the same pom.xml. But it seems that, while Maven quite nicely includes all the dependencies on the classpath, the pom's jar does not get included, or else it cannot be resolved from the repository where maven deployed it (which is an internal not public repository).
The steps I followed:
run mvn deploy -- this deploys our jar on an internal maven repository
install maven on the target machine (not the same as the build machine)
deploy the pom.xml to the target machine.
try to run using mvn exec:java ... or mvn exec:exec ...
What I see is that Maven pulls all the dependency jars onto the classpath correctly, but does not pull in the jar described by the pom.xml.
I tried various configuration options in the pom.xml, but nothing seemed to work. First, tried to configure exec:java as shown in this answer, but Maven did not search the internal repository for that jar. (It did seem to check the public maven repositories though).
Second, I tried to switch to the exec:exec version and configure like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath/>
<argument>com.ezxinc.tfix.TFix</argument>
</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>ezxinc</groupId>
<artifactId>tfix</artifactId>
<version>0.0.3-SNAPSHOT</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>
The dependency shown there is the information for the jar which the pom.xml deployed into our internal repository.
Of course, everything works fine if I unjar the class files into target subdirectory beneath the one where the pom.xml is.
If it helps, the full pom.xml can viewed here.
I think you'll need to have a different pom.xml file rather than trying to use the same pom from the project being built in step 1 of your description. This separate pom file could then include the project in question as a dependency so that it will get downloaded and included in the classpath when running maven commands.
The problem is that maven assumes that the project being described by a pom file is going to be compiled form source rather than downloaded from a repository. Anything you want downloaded from a repository needs to be a dependency, and if you try to include the current project as a dependency of itself you end up with a problem where the project could never be built the first time since it hasn't already been built and deployed to the repository yet.
I have a Gradle project that declares dependencies like
dependencies {
compile group:'jaxen', name:'jaxen', version:'1.+'
}
However whenever I publish with either the old Maven upload plugin or the new maven-publish plugin it generates this in its POM:
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.+</version>
<scope>compile</scope>
</dependency>
Which when a different Maven project tries to depend on the Gradle project fails with:
Could not resolve dependenices for project ...: Failure to find jaxen:jaxen:jar:1.+
I've been searching for a few hours and can't figure out how to get Gradle to declare Maven-valid dependencies. Does anyone know how to do this automatically? Is this a gradle bug?
I'm using the latest Gradle 2.3, Maven 3.3.1, and Java 8
I have a jar file that is built only as a profile. How do I reference that in a <dependency/> block? Let's say it's groupId is com.mycompany, artifactId is test-jar, version is 2.0 and profile is customBuild.
From the project you are building run mvn install, which will install the jar locally in your .m2 directory. Then you can reference it as a regular dependency using
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>test-jar</artifactId>
<version>2.0</version>
</dependency>
in your dependent projects.