When I run import org.apache.commons.net.ftp.{FTP, FTPClient} I receive the error: object apache is not a member of package org. I am using Maven, and I tried adding
<dependency>
<groupId>org.apache.commons.net</groupId>
<artifactId>commons-net</artifactId>
</dependency>
and/or
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
as well as various other similar packages to my pom.xml file, but nothing is working. This seems to be a very simple error yet I cannot figure out what I'm missing. This is my first time using Maven, am I misunderstanding how dependencies work? I am using Scala 2.11.6 if that matters.
Update: I was finally able to run the file I wanted through this command:
mvn exec:java -Dexec.mainClass="com.havas.plugins.test"
Related
I unable to import Java jwt 3.10.0. in my spring project. Actually I was trying before version 3.15.0 but it was giving me an error in pom.xml
"Dependency 'com.auth0:java-jwt:3.15.0' not found"
anyway I then move with version 3.10.0 which is accepted in pom.xml, but it doesn't importing in project, although I've many updated Maven, restart Intellj.
Grateful if anyone can advise.
Dependency in pom.xml
<!-- https://mvnrepository.com/artifact/com.auth0/java-jwt -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.10.0</version>
</dependency>
I'm trying to compile a project (webapp) with Maven and that project "uses" .jar's that are in the Wildfly installation directory (.../Wildfly.../modules/...).
Is there an easy way to import all of these modules through the POM?
I've tried using:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-client-all</artifactId>
<version>10.1.0.Final</version>
</dependency>
And it didn't work.
After that I tried using:
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>10.1.0.Final</version>
<type>pom</type>
</dependency>
To no effect either, giving me the following error:
Could not resolve dependencies for project
someproject:someproject:war:0.0.1-SNAPSHOT: The following artifacts
could not be resolved: org.apache.activemq:artemis-
commons:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-core-
client:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-hqclient-
protocol:jar:1.1.0.wildfly-017, org.apache.activemq:artemis-jms-
client:jar:1.1.0.wildfly-017, org.slf4j:jcl-over-slf4j:jar:1.7.7.jbossorg-1:
Could not find artifact org.apache.activemq:artemis-
commons:jar:1.1.0.wildfly-017 in central
(https://repo.maven.apache.org/maven2)
Any tips would be appreciated.
The wildlfy feature pack [1][2], contains pretty much everything that Wildlfy uses for distribution. However, this has way much more dependencies that you actually need, in most cases. So, just be aware of it.
You can also check out Wildlfy BOMs [3][4], which might be useful for you, as well.
Happy Coding!
[1] https://mvnrepository.com/artifact/org.wildfly/wildfly-feature-pack/11.0.0.Final
[2] https://github.com/wildfly/wildfly/tree/master/feature-pack/src/main/resources/modules/system/layers/base
[3] https://mvnrepository.com/artifact/org.wildfly.bom/wildfly-javaee7
[4] https://github.com/wildfly/boms
I am trying to run a eclipse plugin test that uses OCL, more specifically:
Diagnostic diagnostic = Diagnostician.INSTANCE.validate(modelRoot);
Which works fine if i run it as rightclick -> run as ... -> Eclipse Plugin Test
But if i try to run it via maven (maven install) it fails with the following errormessage:
java.lang.AssertionError: Unable to find delegate to evaluate the 'constraint' on ...
I tried adding
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.tycho.surefire.junit4</artifactId>
<version>0.14.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.ocl</groupId>
<artifactId>ecore</artifactId>
<version>3.3.0-v20130520-1222</version>
</dependency>
<dependency>
<groupId>org.eclipse.emf</groupId>
<artifactId>ocl</artifactId>
<version>1.1.0-v200706201508</version>
</dependency>
<dependency>
<groupId>org.eclipse.emf.query</groupId>
<artifactId>ocl</artifactId>
<version>1.1.0-v200706071712</version>
</dependency>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>ocl</artifactId>
<version>3.4.0-v20140524-1358</version>
</dependency>
to the tycho dependenncies (in the pom), but without any sucess. I would greatly appreciate any ideas on how to fix this
to run tycho test you have to configure the target platform for the test first, Please refer to this
hope this helps
I want to use Jetty as an embedded library in a Java project I'm working on in IntelliJ IDEA. However, there are many different packages for Jetty available from the Maven Central Repository. The JAR available for direct download from here is named as jetty-distribution-9.0.3.v20130506.tar.gz, so I assumed the best complete package available from the Maven Central Repo was org.eclipse.jetty:jetty-distribution:9.0.3.v20130506. But IntelliJ returns this error when attempting to use that coordinate to retrieve the library:
No files were downloaded for org.eclipse.jetty:jetty-distribution:9.0.3.v20130506
Why can't that package be found? And if it's not usable, which packages should I download?
Edit: I now realise that the coordinate I should have been using is org.eclipse.jetty.aggregate:jetty-all:9.0.3.v20130506. I can locate this at search.maven.org, but IntelliJ cannot find anything newer than version 7. Can anyone reproduce or explain this issue? Moved to new question.
Check the dependency type.
There are so called pom type of dependencies, which act as a list of other dependencies. To be able to fetch them, you have to mark them as pom dependencies in your pom.xml
If you only need the server component, try searching for this string
'org.eclipse.jetty:jetty-server:9.0.3.v20130506'
Maven dependencies have a type, which by default is jar. The jetty distribution package is not a jar, and as you can see in the central repository, you can download either a .zip or a .tar.gz, so you'll have to declare the dependency as:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-distribution</artifactId>
<version>${jetty.version}</version>
<type>zip</type>
</dependency>
If you build now, it will download the zip and the build will probably succeed. But, a zip is different from a jar, so depending on what you're actually doing in that build, you will have to do more things to actually make use of that zip.
You probably don't want to use the distribution package unless you're also building a standalone distribution (.zip) for your project as well, in which case you should probably use the maven-assembly-plugin which can unzip the jetty distribution and rezip your whole project.
What you should do is decide what exactly you're going to need and build a custom jetty. Here's the starting point, enough to be able to deploy a simple servlet-based application:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-xml</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-deploy</artifactId>
<version>${jetty.version}</version>
</dependency>
You're probably going to need this one as well, since this is how you can start Jetty:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-start</artifactId>
<version>${jetty.version}</version>
</dependency>
Look at the list of modules to see what else you might need, for example jetty-ajp, jetty-websocket, or jetty-jsp.
I have a Java Maven project that I developed a while ago and that doesn't work anymore. It uses a parent pom together with another Maven project in which I think the Jena version was changed and it also uses an external library that uses Jena. The Maven dependency is:
<dependency>
<groupId>com.hp.hpl.jena</groupId>
<artifactId>jena</artifactId>
<version>2.6.4</version>
</dependency>
When I execute my tests I get the following errors:
java.lang.NoClassDefFoundError: Could not initialize class
com.hp.hpl.jena.query.ARQ
java.lang.NoClassDefFoundError: org/apache/jena/iri/IRIFactory
at org.openjena.riot.system.PrefixMap.add(PrefixMap.java:54)
at com.hp.hpl.jena.sparql.util.MappingRegistry.addPrefixMapping(MappingRegistry.java:33)
at com.hp.hpl.jena.query.ARQ.init(ARQ.java:449) [...]
The errors are not thrown by my code directly but by the library I include. Can I prevent this by downgrading the Jena version in the parent pom or what can I do here?
P.S.: I now have a minimal code example that reproduces the error (java.lang.NoClassDefFoundError: org/apache/jena/iri/IRIFactory):
import org.junit.Test;
import com.hp.hpl.jena.query.ARQ;
public class DependencyTest
{
#Test
public void testARQ()
{
ARQ a = new ARQ();
}
}
And I guess it comes from this dependency:
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>2.9.1-incubating-SNAPSHOT</version>
</dependency>
I know there is probably a factory instead of a constructor but I guess this still shows where the problem is.
P.S.: I noticed that I had the dependencies "jena", "arq" and "jena-arq":
<dependency>
<groupId>com.hp.hpl.jena</groupId>
<artifactId>arq</artifactId>
<version>2.8.8</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>2.9.1-incubating-SNAPSHOT</version>
</dependency>
dependency>
<groupId>com.hp.hpl.jena</groupId>
<artifactId>jena</artifactId>
<version>2.6.4</version>
</dependency>
So I thought maybe I have too much overlapping dependencies and commented out "jena" and "arq". But I still get the error
java.lang.NoClassDefFoundError: Could not initialize class com.hp.hpl.jena.query.ARQ
at com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP.<init> [...]
I also tried out forcing a non-snapshot-version 2.9.0-incubating, but then I still get the NoClassDefFoundError with and without using the "jena" and "arq"-dependencies.
P.P.S.:
I still get the same error even when I use the following dependencies:
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-arq</artifactId>
<version>2.9.0-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>2.7.0-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-iri</artifactId>
<version>2.7.0-incubating</version>
</dependency>
You can search for the missing class using the Maven Central search application
http://search.maven.org/#search|ga|1|fc%3A%22com.hp.hpl.jena.query.ARQ%22
It demonstrates that the dependency you appear to be missing is:
<dependency>
<groupId>com.hp.hpl.jena</groupId>
<artifactId>arq</artifactId>
<version>2.6.0</version>
</dependency>
Doesn't appear to be a version 2.6.4, but you're probabily best advised to go for a more modern version (This project was recently donated to apache)
Instructions for using Apache Jena with Maven are here:
incubator.apache.org/jena/download/maven.html
Specifying ARQ 2.9.0 as a dependency in your project pom.xml will pull in the other Jena components that you need.
I finally resolved this error by excluding the "jena"-Dependency brought in as a transitive dependency from some library.