I want to use Jmathplot.jar
I tried to put it as a dependency
<dependency>
<groupId>jmathplot</groupId>
<artifactId>jmathplot</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/jmathplot.jar</systemPath>
</dependency>
but when installing I get this error:
Some problems were encountered while building the effective model for com.NResearch:dable-start-tRisk:jar:0.1-SNAPSHOT
[WARNING] 'dependencies.dependency.systemPath' for jmathplot:jmathplot:jar should not point at files within the project directory, ${project.basedir}/lib/jmathplot.jar will be unresolvable by dependent projects # line 44, column 19
How can I get around this please?
EDIT1:
I cannot change Maven to include all dependent jars into a single jar. As this is uploaded to a web project.
"Dependent" is using your project, "dependency" is used by your project.
The real error here is that jmathplot.jar is in a folder that can really only reliably be found by your project. Even though your dependents know how to find your artifact in the local repository, they won't know where the sources are for your artifact, hence won't be able to find lib/jmathplot.jar. You can fix that by changing the systemPath to an absolute path. It can still be parametrized, but then please use properties rather than implicit properties (such as ${project.basedir}.
It'd be better to get rid of the systemPath dependency, by installing jmathplot into a company repository, so it can be used alike 'normal' artifacts. But that may not be a useful option if you have to distribute your artifact out of the reach of your company repository. It would even be better if jmathplot would just get deployed to the Maven central repository.
As a last resort you may choose to bundle the dependencies (not the dependents). You can do this:
Using the Maven Shade Plugin. It lets you choose which packages to include which may be useful to bundle only jmathplot (and not other dependencies).
Using the Maven Assembly Plugin. It has a predefined descriptor for "JAR with dependencies" which would fit your use case. You could create your own descriptor off of that example and set dependencySets.dependencySet.scope=system to only include the system dependencies that are giving you trouble.
Best way is to install your dependency on your local repository. To do this:
1) using project source, install to local repository using mvn install
2) if you don't have source code, install to local repository using this
hope it's help
nota: you are spamming around this question, do you ? (see here: JMathPlot what is the Maven dependency code please )
Related
I experimented with webservices and jboss4 for the last couple of days, and I stumbled over the following problem:
I included this dependency in my pom.xml:
<dependency>
<groupId>org.jboss</groupId>
<artifactId>jboss-jaxws</artifactId>
<version>4.2.2</version>
</dependency>
As it turned out, this caused JBoss4 to fail with the error message
java.lang.IllegalStateException: Cannot find endpoint meta data
Until I added the tiny little line
<scope>provided</scope>
to the dependency. I now understand that this problem was caused by the fact, that JBoss4 brings this library himself, and that it is the double inclusion of the same library (probably 2 different versions) that caused this. But now, when I look into the JBoss lib folder I see the following files:
commons-codec.jar
commons-httpclient.jar
commons-logging.jar
concurrent.jar
endorsed
getopt.jar
jboss-common.jar
jboss-jmx.jar
jboss-system.jar
jboss-xml-binding.jar
log4j-boot.jar
How do I know which jars correspond to which maven artifact? How do I know for any of the million files in my .m2/repository folder which groupid, artifactid and version number they belong to?
All the jar files in provided/included by Jboss are not related to maven. They are there just for the sake for jboss it self to run. Other application who wants to run in the container need to provide they own sets of library. BUT, some time, some of the library provided by JBoss is enough for the application (since they will live on the same VM), so you dont need to provide your own. You use those provided library for your development purpose, and later, when you deploy, you dont include them in your deployment.
So, there are no telling which Jar, provided by JBOSS should relate to which artifactId or groupId or version in the maven repositories, unless for some hint on their names.
For example, if you see that Jboss brings "commons-codec.jar" with it. There are no telling that the jar comes from which artifactId or groupId or version in Maven. You may guess that "commons-codec" should be a name of some artifact. Sites like http://mvnrepository.com/ helps you to find what related maven artifact that may relate to the jar you are investigating.
The artefact name is always ${artifactId}-${version}.${type}
in your case : jboss-jaxws-4.2.2.jar.
You're just looking for it in the bad place, the lib folder you're talking about must be the one of the unified classloader, the library you're looking for must be loaded by the server classloader i.e. it must reside in JBOSS_HOME/modules
[edit]
Ferdinand Neman is right when he says that jboss is not related to maven. Dependencies declaration in pom just allows maven to build and package your project. The runtime behavior depends on your targeted environment, the only things to ensure is that your dependencies must be resolved during classloading whether because they are packaged with your project or provided by the runtime environment.
Anyway the jar jboss-jaxws-4.2.2.jar will necessary be present on your workstation (in the local maven repository) to allow class linkage during maven compilation, as the jar is marked as provided it will not be included in the resulting build artefact.
Maybe you find useful this maven command
mvn dependency:tree -Dverbose
It shows you jar dependencies, classified by group-artifact and it also represents dependencies between them as a tree.
I am trying to implement a little service in Scala using Maven to manage dependencies and I would like to add webhdfs-java-client that I have found at https://github.com/wdavidw/webhdfs-java-client
I have added to pom.xml following code:
<dependency>
<groupId>org.zxs</groupId>
<artifactId>webhdfs-java-client</artifactId>
<version>0.0.0</version>
</dependency>
It does not work, as I have expected. Does anyone could give me an advice if there exists some catalog of maven repositories (something like pip for Python)? And what can I possibly do if I'll not find this library in the catalog? Is it possible to somehow add it to maven manually?
In maven world you can install this dependency locally and resolution will be done via local cache (the one that usually resides in ~/.m2). Steps are as simple as mvn clean install in that repo. Having said this, it wouldn't resolve problem for your users (transitive dependencies, you know), which is why you likely need to publish that dependency somewhere (or ask library author whether it's published somewhere).
SBT, which is scala's de-facto build tool allows you to depend on other sbt flavored projects simply by referencing their git repository, but sadly, maven has no such feature.
I am having a java project with a ant build file, using this ant file i create an ejb of the project and deploy it on the jboss server.
Now I am planning to use maven and convert this existing project which consist of nearly 28-30 jar's in its class path(jars related to ejb3, hibernate, jboss, etc).
I can easily do it using eclipse i.e right click project goto maven and click Conver to Maven.
A pom.xml is generated and the MavenClassPath Container is also added to the project.
Now I want to know how to get rid of those 28-30 jar's present in the lib folder of the project and in the classpath. i.e. I want my pom.xml handle all the dependencies.
Does Maven provide any mechanism to achieve this goal while converting the project or I have to add all of these jar dependencies one by one manually in the pom.xml file.
The intention of doing this is I want to have common maven remote repository where the jars will be stored and each developer machine will point to it through their maven project.
Thanks
I think you're after a repository manager like Nexus (I use Nexus, it seems to be the most popular http://nexus.sonatype.org/ ).
Nexus can be used as:
A proxy repository (for Maven Central, etc)
A repository for your own releases.
Nexus provides user management for your developers to release builds into the repo.
Developers will then point their Maven settings.xml file to your Nexus repository, and all their dependencies will come from here (Nexus will cache them).
I'm afraid you will have to configure the dependencies individually, but that is a good thing, because you should pay attention to what version ranges you are interested in for each dependency.
Any jars which can't be found in Maven Central, etc, you can add to your own Nexus repository .
Ofcourse there are alternatives to Nexus, but I haven't used any.
HTH
The most important thing i can recommend is to use a Maven Repository Manager (Nexus, Artifactory or Achiva or other..).
Second your pom conversion via Eclipse shows me that you are not using an up-to-date Eclipse nor an up-to-date Maven Plugin for Eclipse. The best thing would be use Eclipse-Indigo (m2e is the newest and greatest).
Furthermore you have to go through all your jar's and add them step by step to you pom (dependencies) and see if your project can be compiled. This should be checked on command line not inside Eclipse.
After you got a working pom.xml file put it into your version control and check if you can remove some of your added dependencies based on transitive dependencies. After that you can finally delete your lib folder.
When I open a POM file and click on the "Dependency Hierarchy" tab at the bottom, it gives me the error, "Project read error". It works with other projects in the same workspace, just not with this one. Any ideas?
EDIT
In response to #Yhn's answer.
Running the compile and package phases outside of Eclipse from the command-line work as expected. It compiles the application and builds the final WAR file.
Eclipse is indeed pointing to the default location of the Maven settings.xml file, so it should be aware of the custom repositories that are defined in it (my company has its own Maven repository).
I can open and edit the POM file from Eclipse, so it must have read/write permissions to the file.
The project is not configured in Eclipse as a Maven project, so I cannot run the package phase from Eclipse (I can only run it from the command-line).
I wonder if it has anything to do with the fact that I was having trouble building the project with Maven 3 because apparently some of the transitive dependencies are configured for Maven 1, which Maven 3 does not support (this is my theory anyway, based on some of the error messages). I can build the project with Maven 2, but I still get messages such as the following:
Downloading: http://dist.codehaus.org/mule/dependencies/maven2/org/codehaus/xfie/bcprov-jdk14/133/bcprov-jdk14-133.pom
[INFO] Unable to find resource 'org.codehaus.xfire:bcprov-jdk14:pom:133' in repsitory mule (http://dist.codehaus.org/mule/dependencies/maven2)
It must be able to find these dependences however, because it downloaded the JARs just fine and can build the application. It seems like the problem is that the dependencies don't have POM files associated with them, which is maybe why they cannot be used with Maven 3. This might also be why I cannot view the Dependency Hierarchy in Eclipse.
EDIT 2
I converted the project to a Maven project by going to "Configure > Convert to Maven Project". When I open the POM file, I see the error:
ArtifactDescriptorException: Failed to read artifact descriptor for woodstox:wst (Click for 140 more)
(woodstox:wst is another transitive dependency of the project). An error appears in the "Markers" view for seemingly every depedency and transitive dependency in my project. However, I can successfully build the project by doing a "Run As > Maven build". (Edit: This might be because this project has no Java source code, but the JARs of the dependencies correctly appear in the final WAR.) The Dependency Hierarchy still gives the same error--"Project read error".
About the "Unable to find resource" messages--but this only appears for a handful of transitive dependencies. The project has many more transitive dependencies, but these messages do not appear for them. It seems like, because the dependencies do not have POM files, that Maven tries to search for them every time the project is built. Is this normal not to have POMs??
How might I go about getting a repo manager? Is this something that would have to be installed on the company's Maven repository or can you install it on your own workstation?
I had this problem with some non-maven jars that I needed to include in my maven project. I put the jars in my local repository using this maven command:
mvn install:install-file -Dfile=/test/gov.nist.xccdf-1.2.jar -DgroupId=gov.nist -DartifactId=xccdf -Dpackaging=jar -Dversion=1.2
Then I referred to them as dependencies in my pom.xml:
<dependency>
<groupId>gov.nist</groupId>
<artifactId>xccdf</artifactId>
<version>1.2</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
This worked fine for a while, but I must have upgraded something in eclipse, and I started getting the error you describe.
The fix is to take them out of the local repository, and redo the install-file asking maven to generate a pom for you:
mvn -DgeneratePom=true install:install-file -Dfile=/test/gov.nist.xccdf-1.2.jar -DgroupId=gov.nist -DartifactId=xccdf -Dpackaging=jar -Dversion=1.2
The command will cause a pom to be generated in the same directory (within your local repo) where the jar is placed.
In recent versions of eclipse maven support, the maven build is still done with maven 2 (if you right-click your pom.xml, choose run as mvn package for example). The dependency analysis is now done with an embedded maven 3 plugin, which doesn't like a dependency that has no pom.xml.
I had the same problem. If you made your project a maven project, you should run:
Right Mouse Click on project | Maven | Update Dependencies or
Right Mouse Click on project | Maven | Update Project Configuration
That worked for me.
Given the information through the comments:
mvn compile/mvn package work through console (I'm assuming outside of eclipse). Based on that, the POM file should be correct and dependencies can be resolved.
However; it could be that eclipse's settings aren't correct. For example, if eclipse has some own maven properties (instead of the default ~/.m2/settings.xml file); I can imagine it to fail resolving dependencies configured in the settings.xml used by maven itself. The settings for this should be in the Eclipse Preferences # Maven > User Settings.
Also make sure that Eclipse can actually read the file (not locked, correct rights, etc).
Should this seem to be correct; can you try to run the mvn goal compile from eclipse? You can do this by right-clicking the project and selecting run as > maven package. That way it should run maven with the same settings as eclipse is using, and might show any additional errors in it's configuration.
--
In response to additional information:
Basically it tells you - when using Maven 2 - that it can't find a dependency resource (in this case bcprov-jdk14) in the given repository (codehaus/mule). When I search that maven module (bcprov-jdk14) I find it in the Maven central repo (through our local nexus) # repo1.maven.org/maven2. Maybe that causes the error you're getting with Maven2?
And as the Maven 3 doc says; for Maven 1.x repo's; you should proxy them through a repo manager that can serve it to you as a maven 2 repository (I believe we do that here too for some repo's through Sonatype Nexus OSS)
ps.: Enabling maven dependency management in eclipse should be enough to be able to use maven run targets; if you would want to test it.
--
Sound like it can be multiple problems... given that the normal maven build works fine, one would think that maven can at least get the artifacts it depends upon and their dependencies... Yet, eclipse doesn't seem to be able to.
Double check if your Eclipse internet connection settings are correct? Since you were talking about a company repo, I'm assuming there will probably also be a proxy (I had to set up my Eclipse to use that one too; though for plugins (see next point)).
Another possibility, from experience, can be a rule-based proxy block on *.pom url requests (our proxy here blocks that to force usage of the local repo manager, how evil and annoying that is :(). You might want to try and open the .pom file it tries to download manually in your browser to see if this is the case (I can't, for example...).
To get the repo set up, you would probably have to ask the one responsible for the repository to add it as a maven2 proxy.
At the very least, it seems Eclipse is having issues getting the dependency poms (which are needed to build the dependency tree) from the internet. You could always try to ask some ICT crew (if they are capable enough...) about it at your company, maybe they have some useful hints.
right click on the project, Maven->Update Project->Tick "Force Update of Snapshots/Releases"
I had the same problem when I added a new dependency to pom.xml without network connection. After this, I had so many problems such as "Missing artifacts", "Missing Descriptor", or "Project Read error". I solved this
delete the bad dependency just added from local repository.
rebuild local index.
re-add the dependency
<properties>
<!-- ********************** -->
<!-- Plugin's properties -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
</properties>
this pom setting worked for me
Usually this happens if there is a typo in the pom that Maven cannot understand and then it throws Project read error. Like in my case I copied a maven dependency snippet and I by passed the version. Instead of typing the actual version # it was getting it dynamically ${asciidoctorj.version} and my pom didn't have this in the properties section. So I got this error. Once I removed that and put a version number it started working.
I had this after copying a local repository folder from another machine. The fix was to go into the repository folder I copied and delete
_remote.repositories along with the 'LastUpdated' files then refresh the Maven dependencies in Eclipse (Alt+F5)
I faced same situation today. In my case it's caused by dependency name in wrong case. E.g.
Project A -> Project B -> Project C
In project B's pm file, I mistakenly specified the dependency artifacts name with "c" in stead of "C".
As in mac os, the files system is case insensitive. so I can build it in command line without detecting this mistake.
In Eclipse it breaks, but it provides very bad error message. In the error list, it says "dependency problem", but the name of dependency is empty. It also can't identify which line in the POM causes the problem.
When try to open "Effective POM" in POM viewer, it will show project read error. In the pop up error dialog box, it will show:
Could not read maven project
java.nio.channels.OverlappingFileLockException
All the messages are useless and misleading.
I finally detected this problem by submit to Jenkins CI after wasted hours of time.
I did maven clean install and the errors were gone
I faced the same issue of "Project read error" while clicking on "Dependency Hierarchy" tab. In my project I had a parent pom and child pom.
Parent pom had a property <appVersion>4.5<appVersion> that was being used in child pom
<version>${appVersion}<version>.
I selected the main project, right click and choose run as maven clean. The console display showed warning that version is using expression but should be a constant. Replacing ${appVersion} with constant value of 4.5 fixed the issue.
I'm in the process of learning maven (and java packaging & distribution) with a new oss project I'm making as practice. Here's my situation, all java of course:
My main project is ProjectA, maven-based in a github repository. I have also created one utility project, maven-based, in github: ProjectB. ProjectA depends on a project I have heavily modified that originally was from a google-code ant-based repository, ProjectC.
So, how do I set up the build for ProjectA such that someone can download ProjectA.jar and use it without needing to install jars for ProjectB and ProjectC, and also how do I set up the build such that someone could check out ProjectA and run only 'mvn package' for a full compile?
(Additionally, what should I do with my modified version of ProjectC? include the class files directly into ProjectA, or fork the project into something that could then be used by as a maven dependency?)
I've been reading around, links such as this SO question and this SO question, but I'm unclear how those relate to my particular circumstance. So, any help would be appreciated. Thanks!
So, how do I set up the build for ProjectA such that someone can download ProjectA.jar and use it without needing to install jars for ProjectB and ProjectC
Assuming ProjectA is a JAR, you can create an executable JAR that bundles the dependencies with the Maven Assembly Plugin (and the predefined jar-with-dependencies descriptor) or with the Maven Shade Plugin.
how do I set up the build such that someone could check out ProjectA and run only 'mvn package' for a full compile?
You have to deploy the dependencies to a repository that can be read over HTTP and to declare this repository in your pom.xml. AFAIK, git-hub doesn't offer any facility for that. But any web hosting service with FTP access (or better, scp) should do the trick. If your project is open source, another option would be to use Sonatype's OSS Repository Hosting service.
Just in case, you might want to read this blog post but you won't learn much more things.
The easiest would still be to organize the 3 projects as a multi-modules maven project and to build all modules.
Additionally, what should I do with my modified version of ProjectC?
From a modularization point of view (assuming you found a solution for the above part about repository), it would certainly make sense to have it as a separate module, especially if there is an opportunity someone can use ProjectC outside your project.
You have to publish the code from the additional dependencies. Two options:
Use the maven-shade-plugin to create a maven artifact containing all the content of the B and C jars, and publish that under your own G/A/V coordinates.
Publish copies of B and C under your own G/A/V coordinates using the maven-deploy-plugin to your forge just as you will publish your own code. Different forges have different policies; but if you abide by the licenses of B and C you should be OK.