I'm building a Java Project MaterialsDep that is a plugin for project craftbukkit [loaded in my workspace and a direct dependency of MaterialsDep of type jar and scope compile]. Looking at MaterialsDep's pom's dependency hierarchy in eclipse all jars needed by CB show up as resolved and listed correctly. However running mvn dependency:copy-dependencies on project AP only copies direct dependencies and nothing else.
Running dependency:tree shows:
[INFO] --- maven-dependency-plugin:2.4:tree (default-cli) # MaterialsDep ---
[INFO] MaterialsDep:MaterialsDep:jar:0.0.1-SNAPSHOT
[INFO] +- org.bukkit:craftbukkit:jar:1.3.1-R1.1-SNAPSHOT:compile
[INFO] +- org.pircbotx:pircbotx:jar:1.7:compile
[INFO] \- org.bukkit:bukkit:jar:1.3.1-R1.1-SNAPSHOT:compile
which are the direct dependencies.
How should I go about ensuring that craftbukkit's dependency are recognized and copied ?
[EDIT]
dependency:tree for craftbukkit:
[INFO] org.bukkit:craftbukkit:jar:1.3.1-R1.1-SNAPSHOT
[INFO] +- org.bukkit:bukkit:jar:1.3.1-R1.1-SNAPSHOT:compile
[INFO] +- org.bukkit:minecraft-server:jar:1.3.1:compile
[INFO] +- net.sf.jopt-simple:jopt-simple:jar:3.2:compile
[INFO] +- jline:jline:jar:2.6:compile
[INFO] +- org.fusesource.jansi:jansi:jar:1.8:compile
[INFO] +- org.xerial:sqlite-jdbc:jar:3.7.2:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.14:compile
[INFO] +- org.avaje:ebean:jar:2.7.3:provided
[INFO] | \- javax.persistence:persistence-api:jar:1.0:provided
[INFO] +- org.yaml:snakeyaml:jar:1.9:provided
[INFO] +- com.google.guava:guava:jar:10.0:provided
[INFO] | \- com.google.code.findbugs:jsr305:jar:1.3.9:provided
[INFO] +- commons-lang:commons-lang:jar:2.3:provided
[INFO] +- junit:junit-dep:jar:4.10:test
[INFO] +- org.hamcrest:hamcrest-library:jar:1.2.1:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.2.1:test
[INFO] \- com.google.code.gson:gson:jar:2.1:compile
By configuring the dependency plugin correctly. The property excludeTransitive defines whether transitive dependencies will be ignored or not. Make sure it's value is false.
mvn help:effective-pom might help to find out how the plugin is configured.
[EDIT] copy-dependencies will only copy what dependency:tree shows. As you can see in the output above, craftbukkit itself doesn't have any further dependencies. My guess is that all dependencies in craftbukkit's POM have <optional>true</optional>.
If that is the case, then you will have to mention all of them again in your POM.
Related
I don't understand how to load CoreNLP's Shift-Reduce Constituency Parser (SRCP) from my java app.
I'm using Apache Maven to manage my project's dependencies. Per the docs, the SRCP model is not bundled with CoreNLP, so I have downloaded stanford-srparser-2014-10-23-models.jar separately (http://nlp.stanford.edu/software/srparser.shtml) and placed that file in:
~/.m2/repository/edu/stanford/nlp/stanford-corenlp/3.5.2/stanford-srparser-2014-10-23-models.jar
That is the same directory as the core dependency jar
~/.m2/repository/edu/stanford/nlp/stanford-corenlp/3.5.2/stanford-corenlp-3.5.2.jar
Here is the relevant portion of my project's pom.xml:
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.5.2</version>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.5.2</version>
<classifier>models</classifier>
</dependency>
Compiling is successful:
mvn clean compile
But when I try to load the app, I receive:
java.lang.reflect.InvocationTargetException
...
Caused by: edu.stanford.nlp.io.RuntimeIOException: java.io.IOException: Unable to resolve "edu/stanford/nlp/models/srparser/englishSR.ser.gz" as either class path, filename or URL
I unzipped the compiled project war, and "edu/stanford/nlp/models/srparser/englishSR.ser.gz" is not present.
Here is how I'm calling the model in my app:
// Initialize a CoreNLP pipeline
public static Properties props = new Properties();
public static StanfordCoreNLP pipeline;
// Set the CoreNLP pipeline annotators.
props.setProperty("annotators", "tokenize, ssplit, parse, sentiment");
props.setProperty("parse.model", "edu/stanford/nlp/models/srparser/englishSR.ser.gz");
pipeline = new StanfordCoreNLP(props);
How can I update my Maven config to force my CoreNLP dependency to include the srparser model? Keep in mind that I need this configuration to run in other developers' environments, so the solution should be clean and reusable if possible.
Thanks!
EDIT:
In response to #jah's comment, below are the results of mvn dependency:tree. The build succeeds, but the srparser model is not compiled/present:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # [REDACTED] ---
Downloading:
...
[INFO] com.[REDACTED].nlp:nlp:war:0.1.0
[INFO] +- com.strategicgains:RestExpress:jar:0.11.2:compile
[INFO] | +- com.strategicgains:RestExpress-Common:jar:0.11.2:compile
[INFO] | +- com.strategicgains:DateAdapterJ:jar:1.1.4:compile
[INFO] | +- com.thoughtworks.xstream:xstream:jar:1.4.7:compile
[INFO] | | +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] | | \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] | +- io.netty:netty-all:jar:4.0.29.Final:compile
[INFO] | +- org.owasp.encoder:encoder:jar:1.1.1:compile
[INFO] | \- com.jcraft:jzlib:jar:1.1.3:compile
[INFO] +- junit:junit:jar:4.11:test
[INFO] | \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- edu.stanford.nlp:stanford-corenlp:jar:3.5.2:compile
[INFO] | +- com.io7m.xom:xom:jar:1.2.10:compile
[INFO] | | +- xml-apis:xml-apis:jar:1.3.03:compile
[INFO] | | +- xerces:xercesImpl:jar:2.8.0:compile
[INFO] | | \- xalan:xalan:jar:2.7.0:compile
[INFO] | +- joda-time:joda-time:jar:2.1:compile
[INFO] | +- de.jollyday:jollyday:jar:0.4.7:compile
[INFO] | | \- javax.xml.bind:jaxb-api:jar:2.2.7:compile
[INFO] | +- com.googlecode.efficient-java-matrix-library:ejml:jar:0.23:compile
[INFO] | \- javax.json:javax.json-api:jar:1.0:compile
[INFO] +- edu.stanford.nlp:stanford-corenlp:jar:models:3.5.2:compile
[INFO] +- org.json:json:jar:20151123:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.6.4:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.6.0:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.6.4:compile
[INFO] \- commons-io:commons-io:jar:1.3.2:compile
First, download the srparser jar and place it in your project root: http://nlp.stanford.edu/software/stanford-srparser-2014-10-23-models.jar
Second, from the project root, execute the following command to install the srparser model dependency via Maven:
mvn install:install-file -Dfile=stanford-srparser-2014-10-23-models.jar -DgroupId=edu.stanford.nlp -DartifactId=stanford-srparser -Dversion=3.5.2 -Dpackaging=jar
Note the custom artifactId and lack of classifier in the command -- this is to prevent namespace confusion with the other CoreNLP modules.
Third, add the dependency to the Maven project's pom.xml:
<dependencies>
...
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-srparser</artifactId>
<version>3.5.2</version>
</dependency>
...
</dependencies>
Finally, clean install:
mvn clean install
If you continue to experience issues, it may be helpful to clear your Maven dependencies:
mvn dependency:purge-local-repository
And don't forget to add the download/install commands to your project README/environment bootstrap file!
(Thanks for your help #jah and #GaborAngeli.)
To run the shift-reduce parser, you need to include the shift-reduce models jar, which can be found at: http://nlp.stanford.edu/software/srparser.shtml
Not sure if it's on maven, but it appears not?
If you run the mvn command from the folder where the stanford-srparser-2014-10-23-models.jar is placed, then the following command should do the trick.
mvn install:install-file -Dfile=stanford-srparser-2014-10-23-models.jar -DgroupId=edu.stanford.nlp -DartifactId=stanford-corenlp -Dversion=3.5.2 -Dclassifier=models -Dpackaging=jar
I downloaded OWL API (4.0.1 and 4.0.2). But it needed plenty of dependencies that are nowhere mentioned. I downloaded dependency JARs from maven pom.xml file (found it somewhere for version OWL API 4.0.1). List of jars:
First of all, it was error with RDFFormat (need to add sesame lib, which was not in pom.xml.
But I still have "NoSuchMethodError" errors.
First one was
com.google.common.base.Objects.firstNonNull
(with Guava 17.0).I updated it to 18.0, now its
com.google.common.base.Platform.systemNanoTime
Here on stackoverflow is answer for this:
You most likely have both a recent version of Guava and either
google-collect or a version of Guava prior to 3.0 on your classpath
But no, I dont have old Guava lib named google-collect(ions).
Maven dependencies are transitive. If you don't want to use Maven for some reason you'll need to include all of them. Here's the dependency tree for owlapi 4.0.2.
[INFO] \- net.sourceforge.owlapi:owlapi-distribution:jar:4.0.2:compile
[INFO] +- org.openrdf.sesame:sesame-model:jar:2.7.12:compile
[INFO] | \- org.openrdf.sesame:sesame-util:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-api:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-languages:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-datatypes:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-binary:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-n3:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-nquads:jar:2.7.12:compile
[INFO] | \- commons-io:commons-io:jar:2.4:compile
[INFO] +- org.openrdf.sesame:sesame-rio-ntriples:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-rdfjson:jar:2.7.12:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.2.1:compile
[INFO] +- org.openrdf.sesame:sesame-rio-rdfxml:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-trix:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-turtle:jar:2.7.12:compile
[INFO] +- org.openrdf.sesame:sesame-rio-trig:jar:2.7.12:compile
[INFO] +- com.github.jsonld-java:jsonld-java-sesame:jar:0.5.0:compile
[INFO] | \- com.github.jsonld-java:jsonld-java:jar:0.5.0:compile
[INFO] | +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.3:compile
[INFO] | | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0:compile
[INFO] | +- org.apache.httpcomponents:httpclient-cache:jar:4.2.5:compile
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.2.5:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.2.4:compile
[INFO] | | \- commons-codec:commons-codec:jar:1.6:compile
[INFO] | \- org.slf4j:jcl-over-slf4j:jar:1.7.7:runtime
[INFO] +- org.semarglproject:semargl-sesame:jar:0.6.1:compile
[INFO] | +- org.semarglproject:semargl-core:jar:0.6.1:compile
[INFO] | \- org.semarglproject:semargl-rdfa:jar:0.6.1:compile
[INFO] | \- org.semarglproject:semargl-rdf:jar:0.6.1:compile
[INFO] +- com.google.guava:guava:jar:18.0:compile
[INFO] +- com.google.inject:guice:jar:4.0-beta:compile
[INFO] | +- javax.inject:javax.inject:jar:1:compile
[INFO] | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] +- com.google.inject.extensions:guice-multibindings:jar:4.0-beta:compile
[INFO] +- com.google.code.findbugs:jsr305:jar:2.0.1:compile
[INFO] +- org.slf4j:slf4j-api:jar:1.7.7:compile
[INFO] +- org.apache.directory.studio:org.apache.commons.io:jar:2.4:compile
[INFO] \- net.sf.trove4j:trove4j:jar:3.0.3:compile
For the most part, your life will be much easier using Maven (or some other modern build tool). It deals with dependency issues like this so you don't have to. If you're stuck with ant for some reason you could also take a look at ivy.
Thank you for you responses. I use
-verbose:class
and found out, that package for that class is from
gephi-toolkit.jar
Tt has google-collection too ... so yeah, different versions.
When I run "mvn dependency:tree" for my project it shows the following:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # xxxxx ---
[INFO] com.xxx.xxx:xxxxx:war:3.1.0-SNAPSHOT
...
[INFO] +- commons-configuration:commons-configuration:jar:1.5:compile
[INFO] | \- commons-beanutils:commons-beanutils-core:jar:1.7.0:compile
[INFO] +- org.seleniumhq.selenium:selenium-api:jar:2.34.0:test
[INFO] | +- com.google.guava:guava:jar:14.0:test
[INFO] | \- org.json:json:jar:20080701:test
[INFO] +- org.seleniumhq.selenium:selenium-htmlunit-driver:jar:2.34.0:test
[INFO] | +- org.seleniumhq.selenium:selenium-remote-driver:jar:2.34.0:test
[INFO] | | +- cglib:cglib-nodep:jar:2.1_3:test
[INFO] | | +- net.java.dev.jna:jna:jar:3.4.0:test
[INFO] | | \- net.java.dev.jna:platform:jar:3.4.0:test
[INFO] | \- net.sourceforge.htmlunit:htmlunit:jar:2.12:test
[INFO] | +- org.apache.commons:commons-lang3:jar:3.1:test
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.2.3:test
[INFO] | +- net.sourceforge.htmlunit:htmlunit-core-js:jar:2.12:test
[INFO] | +- xerces:xercesImpl:jar:2.10.0:test
>>>[INFO] | | \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] | +- net.sourceforge.nekohtml:nekohtml:jar:1.9.18:test
[INFO] | +- net.sourceforge.cssparser:cssparser:jar:0.9.9:test
[INFO] | | \- org.w3c.css:sac:jar:1.3:test
[INFO] | \- org.eclipse.jetty:jetty-websocket:jar:8.1.9.v20130131:test
[INFO] +- org.seleniumhq.selenium:selenium-firefox-driver:jar:2.34.0:test
...
As you see on the marked line, the xml-apis has "compile" scope, and as result it is packed into .war file. Why could it happen?
More interestingly it happens only while Java5 is used, for Java6 the dependency appears as "test".
Maven version: 3.0.4
Study the output of the following Maven command.
mvn -X dependency:tree -Dverbose
That should tell you why Maven upgraded the scope from test to compile.
If you take a look at xercesImpl it contains a dependency to xml-apis:xml-apis:jar:1.4.01:compile with the scope compile so the display of dependency plugin is correct. The usage of -Dverbose will do things as written in the docs:
Whether to include omitted nodes in the serialized dependency tree.
Apart from the above a test dependency as in your case is never being packaged into a war file.
There must be an other source of the same dependency which causes the packaging into the war
Furthermore the change in behaviour in relationship with adding explicit xml-apis to your pom is a supplemental evidence for this.
I had a similar problem.
In my case an entry in the dependencyManagement of a parent pom set the scope of the dependent artefact to compile. Actually I omitted the scope tag which effectively is the same as setting it to compile. Changing it to provided helped.
Seems the scope in dependencyManagement takes precedence over the transitive scope. Which makes sense but can still cause confusion when all you wanted to do is define the version.
It was actually not hard to spot: Looking at the effective-pom showed the dependencyManagement entry.
I run mvn dependency:list
and then I get:
[INFO] The following files have been resolved:
....
[INFO] org.springframework:spring-aop:jar:3.2.8.RELEASE:compile
[INFO] org.springframework:spring-beans:jar:3.2.8.RELEASE:compile
[INFO] org.springframework:spring-context:jar:3.2.8.RELEASE:compile
[INFO] org.springframework:spring-core:jar:4.0.3.RELEASE:compile
[INFO] org.springframework:spring-expression:jar:3.2.8.RELEASE:compile
[INFO] org.springframework:spring-jdbc:jar:3.2.8.RELEASE:compile
[INFO] org.springframework:spring-orm:jar:3.2.8.RELEASE:compile
[INFO] org.springframework:spring-oxm:jar:4.0.3.RELEASE:compile
[INFO] org.springframework:spring-test:jar:4.0.3.RELEASE:compile
[INFO] org.springframework:spring-tx:jar:3.2.8.RELEASE:compile
[INFO] org.springframework:spring-web:jar:4.0.3.RELEASE:compile
[INFO] org.springframework.data:spring-data-commons:jar:1.7.1.RELEASE:compile
[INFO] org.springframework.data:spring-data-jpa:jar:1.5.1.RELEASE:compile
How can I determine which dependency is responsible for Spring 3 jars as I only want the version 4 jars to be there.
Thanks!
Running dependency:tree instead of dependency:list will show you the dependency tree for the project, which should reveal the origin of the Spring 3 dependencies.
Here is an example of how the dependency tree output looks like:
[INFO] [dependency:tree]
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
[INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile
[INFO] | \- commons-validator:commons-validator:jar:1.2.0:compile
[INFO] | \- commons-digester:commons-digester:jar:1.6:compile
[INFO] | \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0)
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
[INFO] \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
[INFO] \- commons-collections:commons-collections:jar:2.0:compile
I am using eclipse to try to run a simple project here. When I typed contents in eclipse, it says: The type javax.validation.Payload cannot be resolved. It is indirectly referenced from required .class files. In the example shown there, he used maven and in my practice I haven't.
I also have maven plugin in eclipse m2e-wtp latest and kepler version of eclipse. I tried many websites, such as this one. Here he used command window and used some commands, but when I tried in my pc, it didn't work. I think maven needs to set in my environment variable. That means I have to install maven in my c:/programfiles or any.
Is there a way to run the commands in eclipse(naive)? can some one give me a link to build sample maven project using m2e eclipse?
I downloaded the application, and it ran fine on my computer.
All I did was unzip and type:
mvn clean tomcat:run-war
I think you might be missing a transitive dependency (which Maven will automatically download), ensure you have all of these on your eclipse classpath:
$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SpringMVC Maven Webapp 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # SpringMVC ---
[INFO] com.mkyong.common:SpringMVC:war:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-core:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-asm:jar:3.0.5.RELEASE:compile
[INFO] | \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-web:jar:3.0.5.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-beans:jar:3.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-context:jar:3.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-aop:jar:3.0.5.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.0.5.RELEASE:compile
[INFO] | +- org.springframework:spring-context-support:jar:3.0.5.RELEASE:compile
[INFO] | \- org.springframework:spring-expression:jar:3.0.5.RELEASE:compile
[INFO] \- org.hibernate:hibernate-validator:jar:4.2.0.Final:compile
[INFO] +- javax.validation:validation-api:jar:1.0.0.GA:compile
[INFO] \- org.slf4j:slf4j-api:jar:1.6.1:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.132s
[INFO] Finished at: Wed Sep 04 22:07:24 CDT 2013
[INFO] Final Memory: 6M/15M
[INFO] ------------------------------------------------------------------------
My guess is this jar:
javax.validation:validation-api:jar:1.0.0.GA:compile