Can't integrate AssertJ into TestNG (Java 1.8, Maven) - assertj

Added dependency into pom.xml
After adding static import (tried also many with all list) and assertion (AssertThat) - it doesn't work.
import static org.assertj.core.api.Assertions.*;
It's not finding any JAR for AssertJ. After pressing 2 times control+space - there are no suggestions.

I have seen AssertJ working with Idea, please double check your classpath in Idea.
You can check hos maven resolve your dependencies with mvn dependency:tree, you should see something like:
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # assertj-examples-java-8 ---
[INFO] org.assertj:assertj-examples-java-8:jar:1.0
[INFO] +- org.assertj:assertj-core:jar:3.12.2-SNAPSHOT:test

Related

How to get Project dependencies from SBT console

Is there a way to inspect the dependencies between my projects in my build (in the sbt console)?
I'd like to check if those configs where successful
projectA.dependsOn(projectB)
and
projectC.aggregate(projectD, projectF)
#Mario Camou's answer is valid if you want to see external dependencies. But if you just want to check if dependency configs were successful, you can simply do:
> sbt
$ projects
This should provide info like: (taken from my Mac)
[info] In file:/Users/vaedama/development/projectA/
[info] projectB
which means that your projectA is dependent on projectB
Now if you want to see which project aggregates which project, you can just do:
> sbt // enter SBT prompt
$ projects // view all projects
The result should look like:
[info] In file:/Users/vaedama/development/SimpleProject/
[info] projectC
$ project projectC // switch to the projectC
$ projectInfo // view aggregations
The result should look something like:
[info] projectD/*:projectInfo
[info] ModuleInfo(projectD, projectD,None,None,List(),com.foo.bar,None,None)
[info] projectF/*:projectInfo
[info] ModuleInfo(projectF, projectF,None,None,List(),com.foo.bar,None,None)
which means that your projectC is an aggregate of projectD and projectF
You could try the sbt-dependency-graph plugin from https://github.com/jrudolph/sbt-dependency-graph
To get a list of the project dependencies of the current project one can also do
show projectDependencies

Eclipse maven jboss project - what do I need to add to the pom.xml so maven can compile?

I managed to set up my Jboss WTP project in maven. Right click on the project > Run as > Run on server (Jboss 7) works fine. But if I go ahead and delete the target directory and then try to execute compile goal it fails with missing dependencies:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.\
singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building PROJECT 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # PROJECT ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\path\\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # PROJECT ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to C:\path\\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/path/to/file/Controller.java:[14,21] package javax.servlet does not exist
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/to/file/DataServlet.java:[3,30] package gr.uoa.di.java.helpers does not exist
#.....
[ERROR] /C:/path/to/file/DataServlet.java:[26,32] package javax.servlet.annotation does not exist
[ERROR] /C:/path/to/file/DataServlet.java:[28,26] package javax.servlet.http does not exist
#.....
[INFO] 49 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
If I clean the project so the target directory is populated with classes then try to compile the project all fine:
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # DataCollectionServlet ---
[INFO] Nothing to compile - all classes are up to date
I have 1 question:
What exactly should I add to the pom.xml to reproduce the compilation environment of the Run on Server eclipse command ? EDIT: For instance adding:
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
to the pom solved the "servlet API not found" issue - but is it the way to go ? Or should I add something like:
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-spec-api</artifactId>
<version>7.1.1.Final</version>
</dependency>
(see here). NB: adding the dependencies suggested by m2e plugin would result in a huge pom - moreover I am not sure all of it would be needed (it's a plain servlet/jsp project):
I am on Eclipse Luna Java EE pack, maven 3.1 (the one that comes with eclipse) and using Jboss 7.1.1.Final
I ended up just adding:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>javax.servlet.jsp.jstl</artifactId>
<version>1.2.1</version>
<scope>provided</scope>
</dependency>
This transitively added the servlet-api:
Still don't know if adding this is the right way to add jstl 1.2.1 - notice it adds the jstl 1.2 api (EDIT: it isn't: Standard way of adding JSLT 1.2.1 in a Maven Project?)
I also still have problems with my homebrew jar (Can maven treat WEB-INF\lib the way eclipse (and m2e) does?) but closing this for now.

Use Maven embedded in Eclipse to install dependencies

I am trying to add log4j as a Maven Dependency. So I added it to the pom.xml
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.15</version>
</dependency>
Now I have a warning message that I am missing 6 artifacts (jars that log4j depends on). As described on the following site Maven Repository - log4j.
My goal is to get Maven to install the 6 dependencies for me. I have Eclipse Kepler with embedded Maven, so I cannot run "mvn install". I see from this stackoverflow answer Run Maven Install in Eclipse that I can right click on the project and Run As > Maven Install. But I get the following error:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ############# 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.522s
[INFO] Finished at: Wed Nov 27 12:13:11 CST 2013
[INFO] Final Memory: 6M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project #############: Could not resolve dependencies for project #############:#############:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
Please let me know if I am on the right path and how best to proceed to get the log4j dependencies. Thank you in advance for any help.
UPDATE
After checking Preferences > Maven > User Settings, I discovered that the settings.xml file that is being referenced does not exist. I clicked "Update Settings" and I get the following error:
ArtifactTransferException: Could not transfer artifact com.sun.jdmk:jmxtools:jar:1.2.1 from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No connector available to access repository java.net (https://maven-repository.dev.java.net/nonav/repository) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory
UPDATE 2
It looks like my issue is a result of Maven 3 (which comes with Kepler) is trying to access a Maven 2 repository and having compatibility issues. I have yet to figure out how to redirect to an appropriate repository.
I changed the version from 1.2.15 to 1.2.17 and it worked (1.2.16 works as well). I do not see any of the dependencies listed "here" listed in the Resolved Dependencies frame like I did with 1.2.15. I do not have a full understanding of why this worked, but it worked for me.
You can right-click on your project then Maven > Update Snapshots. (Make sure u check the "Force update on snapshots" checkbox. This should work.

maven dependency not found in repository

I'm trying to run the project, which uses gwt-dev.
The instructions are at: http://neiliscoding.blogspot.ru/2012/05/how-to-setup-examples-for-use-in-gxt-3.html?showComment=1362999279386
when I create dependency in terminal like: mvn install:install-file -DgroupId=com.google.gwt -DartifactId=gwt-dev -Dversion=2.5.0 -Dpackaging=jar -Dfile='/home/mikhail/Загрузки/libraries/gwt-2.5.0/gwt-dev.jar'
and add dependency to the pom.xml:
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>2.5.0</version>
</dependency>
maven says:
[WARNING] You should not declare gwt-dev as a project dependency. This may introduce complex dependency conflicts
Downloading: http://repo1.maven.org/maven2/com/google/gwt/gwt-dev/2.5.0/gwt-dev-2.5.0-linux-libs.zip
[INFO] Unable to find resource 'com.google.gwt:gwt-dev:zip:linux-libs:2.5.0' in repository central (http://repo1.maven.org/maven2)
else if I remove it maven says:
[INFO] using GWT jars from project dependencies : 2.5.0
Downloading: http://repo1.maven.org/maven2/com/google/gwt/gwt-dev/2.5.0/gwt-dev-2.5.0-linux-libs.zip
[INFO] Unable to find resource 'com.google.gwt:gwt-dev:zip:linux-libs:2.5.0' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
So I have Build error in both cases. How to deal with such situation? help me please.
I didn't managed with this problem yet but I've just found that I used 1.2 version of maven plugin. I'm not shure it is the main problem, but I'd like to deal with it anyway. so, sinse I've added this plugin according to your first link, maven drops build error:
`
[INFO] Scanning for projects...
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central
[INFO] artifact org.apache.maven.plugins:maven-archetype-plugin: checking for updates from central
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [org.apache.maven.plugins:maven-archetype-plugin:RELEASE:generate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] Preparing archetype:generate
[INFO] No goals needed for project - skipping
[INFO] [archetype:generate {execution: default-cli}]
[INFO] Generating project in Batch mode
[INFO] Archetype repository missing. Using the one from [org.codehaus.mojo:gwt-maven-plugin:2.5.1-rc1] found in catalog remote
[WARNING] Property module is missing. Add -Dmodule=someValue
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Archetype org.codehaus.mojo:gwt-maven-plugin:2.5.1-rc1 is not configured
Property module is missing.
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4 seconds
[INFO] Finished at: Tue Mar 12 15:18:50 MSK 2013
[INFO] Final Memory: 27M/428M
`
and by the way, I use intellij IDEA
GWT stopped maintaining separate platform dependent libs for windows,linux and mac long time ago. GWT 1.7 was the last of such platform dependent libs. So "linux-libs" does not make sense in your error. I am guessing you are using a really old gwt-maven-plugin .
Move to latest gwt-maven-plugin.
Use <scope>provided</scope> for gwt-dev dependency to avoid it being pushed into WEB-INF/lib ( harmless but redundant )
Use global/central repository instead of installing it user repo locally.
You can also start off using GWT samples for maven projects here.
Note - your query might be a duplicate/similart to NetBeans + GWT 2.2.0 + Maven compile problem
Edit for new GWT release
GWT 2.5.1 has been released and also make note gwt-maven-plugin is of 2.5.0 ( 1 step behind GWT :)

Stanford CoreNLP: Building Error (NoSuchMethodError)

Sorry if this is a newbie's question.
I was trying to use maven in Netbeans to build CoreNLP parser.
I first added dependency of stanford-corenlp 1.2.0. However, I always got an error while compiling my code. I tried to simplify my code to just create the StanfordCoreNLP object, but it still did not function with the same error message. I guess here might come with the main trouble spot then.
My simplified code shows as:
import java.util.Properties;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
The error message:
Exception in thread "main" java.lang.NoSuchMethodError:
edu.stanford.nlp.process.PTBTokenizer.factory
(Ledu/stanford/nlp/process/LexedTokenFactory;Ljava/lang/String;)Ledu/stanford/nlp/objectbank/TokenizerFactory;
at edu.stanford.nlp.pipeline.PTBTokenizerAnnotator.<init>(PTBTokenizerAnnotator.java:42)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$1.create(StanfordCoreNLP.java:365)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$1.create(StanfordCoreNLP.java:355)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:62)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:328)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:194)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:184)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:176)
at com.mycompany.hellocore.App.main(App.java:26)
I also tried the same thing via maven on Eclipse, the error message is still the same. Can anyone give me some suggestions? Thanks!
OS: Mac Lion /
Java version: 1.6.0_29
[Update]
01-6-2012 Based on Sri Sankaran's suggestion, i tried mvn dependency: tree:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building hellocore 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) # hellocore ---
[INFO] com.mycompany:hellocore:jar:1.0-SNAPSHOT
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] \- edu.stanford.nlp:stanford-corenlp:jar:1.2.0:compile
[INFO] +- xom:xom:jar:1.2.5: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.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.483s
[INFO] Finished at: Fri Jan 06 08:55:06 EST 2012
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
The setting in my Netbeans:
But it seems like the library in need looks the same as what is already downloaded in Netbeans. The project still stops while Adding annotator tokenize.
[Update]
01-09-2012
After i reinstalled my system, the problem was gone. So i think the code and the module are both correct. The classpath directories might be just messed up by me. Thank you for all people's helps.
Just a gentle reminder for people using corenlp via Netbeans. In addition to the standard dependency of stanford-corenlp.jar. If you want to inlcude the stanford-corenlp-models.jar into your project. Seems like you also need to specify the <classifier> to add the models to the dependency repository.
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>1.2.0</version>
<classifier>models</classifier>
</dependency>
You need to include model (POS tag, NER, Coref, etc), so your annotator worked.
You can get it here
The usage of Standford NLP suggests that there are other dependencies. If they aren't transitively included in the classpath by virtue of the stated dependency on stanford-corenlp 1.2.0 you will have to explicitly state these other dependencies as well. The command mvn dependency:tree should display your effective dependency tree.