I am trying to launch a Scage Project. I never used maven before.
I created a pom.xml file and downloaded the files with intellij
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ScageTest</groupId>
<artifactId>ScageTest</artifactId>
<version>1.0</version>
<repositories>
<repository>
<id>scage</id>
<name>Scage Maven Repo</name>
<url>http://scage.googlecode.com/svn/maven-repository</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>su.msk.dunno</groupId>
<artifactId>scage</artifactId>
<version>0.9</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
This worked just fine. I also created the main file, as pointed in the tutorial
import net.scage.ScageScreenApp
import net.scage.ScageLib._
import net.scage.support.Vec
object HelloWorldExample extends ScageScreenApp("Hello World") {
private var ang = 0f
actionStaticPeriod(100) {
ang += 5
}
backgroundColor = BLACK
render {
openglMove(windowSize/2)
openglRotate(ang)
print("Hello World!", Vec(-50, -5), GREEN)
}
}
As pointed in the tutorial I have to use this command to build it mvn clean package -Pwebstart
log:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) # ScageTest ---
[WARNING] JAR will be empty - no content was marked for inclusion!
[INFO] Building jar: C:\Users\kanta\IdeaProjects\ScageTest\target\ScageTest-1.0.
jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.922s
[INFO] Finished at: Mon Oct 29 23:40:07 CET 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "webstart" could not be activated because it doe
s not exist.
Now the output is a .jar file instead of a .jnlp file, also nothing happens if I doubleclick the .jar file.
Any ideas what went wrong?
You are missing the webstart profile in your pom.xml
look at the pom.xml inside the scage example project: https://code.google.com/p/scage/downloads/detail?name=scage-example-project.zip&can=2&q=
it is quite large, but among others has thing it has the profile specified
<project>
<profiles>
<profile>
<id>webstart</id>
...
</profile>
</profiles>
</project>
Related
EDIT: This question should absolutely not be closed. I'm NOT asking how to create an executable jar. A jar doesn't need to be executable to be run from the terminal. For example, if I have have this code:
package com.dogzilla.maven.quickstart;
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World" );
}
}
...and Maven builds it, it creates quickstart-0.0.1-SNAPSHOT.jar. Which is not, ahem, 'executable'.
I can run it from the terminal quite successfully with this:
java -cp /opt/workspace/eclipse/java/quickstart/target/quickstart-0.0.1-SNAPSHOT.jar com.dogzilla.maven.quickstart.App
The problem, as I have written below, is experienced when using an external dependency. </end edit>
I have a simple Maven project in Eclipse (2020-6). It was set up by doing the following in Eclipse:
1. File -> New -> Other... Maven -> Maven Project
2. Used the maven-archetype-quickstart archetype
Group ID: com.dogzilla.maven
Artifact ID: quickstart
Right click the pom file -> select Add Dependency -> enter:
Group ID: com.google.code.gson
Artifact ID: gson
Version: 2.8.6
Which I verified on https://search.maven.org/
Here's the POM file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dogzilla.maven</groupId>
<artifactId>quickstart</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>quickstart</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
Here's the source code:
package com.dogzilla.maven.quickstart;
import com.google.gson.Gson;
public class App
{
public static void main( String[] args )
{
Gson gson = new Gson();
System.out.println(gson.toJson("Hello World!") );
}
}
I then right-clicked on the POM file -> Run As -> Maven Build...
and here is the output:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/eclipse/java/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/opt/eclipse/java/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/eclipse/java/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/opt/eclipse/java/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.dogzilla.maven:quickstart >--------------------
[INFO] Building quickstart 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) # quickstart ---
[INFO] Deleting /opt/workspace/eclipse/java/quickstart/target
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) # quickstart ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /opt/workspace/eclipse/java/quickstart/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) # quickstart ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /opt/workspace/eclipse/java/quickstart/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) # quickstart ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /opt/workspace/eclipse/java/quickstart/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) # quickstart ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /opt/workspace/eclipse/java/quickstart/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) # quickstart ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.dogzilla.maven.quickstart.AppTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.022 s - in com.dogzilla.maven.quickstart.AppTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-jar-plugin:3.0.2:jar (default-jar) # quickstart ---
[INFO] Building jar: /opt/workspace/eclipse/java/quickstart/target/quickstart-0.0.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.967 s
[INFO] Finished at: 2020-12-13T20:00:27-07:00
[INFO] ------------------------------------------------------------------------
But if I run:
java -cp /opt/workspace/eclipse/java/quickstart/target/quickstart-0.0.1-SNAPSHOT.jar com.dogzilla.maven.quickstart.App
It fails with:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/Gson
at com.dogzilla.maven.quickstart.App.main(App.java:13)
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 1 more
The thing is if I change System.out.println(gson.toJson("Hello World!") ); to plain 'ol System.out.println("Hello World"); it works. So I know the porblem isn't with my java command or how I set the project up outside of the dependency getting resolved.
So the question is, I'm not sure how this is failing on the dependency. I was under the impression Maven managed all that for you. Why is this failing to run?
The jar file that created from your project only contains classes that written by you. If you need to run the application, you need to include all the necessary dependencies (either direct or transitive) in your classpath.
If you need a single jar file that you can execute without other dependencies, Please follow this to create a fatjar.
Use the Maven plugin mentioned in comment https://stackoverflow.com/a/65486325/679858 or use the Maven Shade plugin described here: https://maven.apache.org/plugins/maven-shade-plugin/
Your question was "Why does it run from Eclipse and not from console?":
If you run it from Eclipse then the Maven plugin in Eclipse knows the full runtime classpath and so it works. If you run it in console with the created JAR file then that JAR file only contains the classes of your sources but not the transitive dependencies, e.g. Google GSON. But if you use the Maven Assembly plugin or the Maven Shade plugin then you can create a JAR file which contains all the transitive dependencies of your project. That jar could be executed like you wrote it in your example.
try remove gson from .m2 folder then run maven install again.
You are not providing the path to the additional, transitive, dependencies of your project in the java command, which is why it fails.
You are using maven to build your project, not to execute your class: this is not Maven purpose, although it can do it using maven-exec-plugin. Eclipse is different: it uses Maven information (with m2e) and provides a context to run classes, context that includes dependencies.
The option -cp, explained in depth at Oracle Web Site: java (15), accepts one or more path to list of directories, jar and zip to search for class files:
--class-path classpath, -classpath classpath, or -cp classpath
A semicolon (;) separated list of directories, JAR archives, and ZIP archives to search for class files.
Specifying classpath overrides any setting of the CLASSPATH environment variable. If the class path option isn't used and
classpath isn't set, then the user class path consists of the current
directory (.).
As a special convenience, a class path element that contains a base name of an asterisk (*) is considered equivalent to specifying a
list of all the files in the directory with the extension .jar or .JAR
. A Java program can't tell the difference between the two
invocations. For example, if the directory mydir contains a.jar and
b.JAR, then the class path element mydir/* is expanded to A.jar:b.JAR,
except that the order of JAR files is unspecified. All .jar files in
the specified directory, even hidden ones, are included in the list. A
class path entry consisting of an asterisk (*) expands to a list of
all the jar files in the current directory. The CLASSPATH environment
variable, where defined, is similarly expanded. Any class path
wildcard expansion that occurs before the Java VM is started. Java
programs never see wildcards that aren't expanded except by querying
the environment, such as by calling System.getenv("CLASSPATH").
So you need to fix your command to provides gson and any other compile/runtime/provided dependencies you may add later:
CLASSPATH=''
CLASSPATH+=";$HOME/.m2/repository/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar"
CLASSPATH+=";/opt/workspace/eclipse/java/quickstart/target/quickstart-0.0.1-SNAPSHOT.jar"
CLASSPATH="${CLASSPATH:1}" # remove leading ';'
java -cp "${CLASSPATH}" com.dogzilla.maven.quickstart.App
The man says that you can use ; to separate entries; that is true at least for Windows. However on other Linux based OS (which seems to are on due to /opt being used), this can also be :: that what appassembler does when writing CLASSPATH.
Do note that you will have to adapt the path manually to retarget the actual location of gson.jar (I guessed from what maven does by default).
You can also use appassembler or launch4j to do the trick for you. You can also use build-classpath to build the classpath (it may also work from command line).
The story behind: I submitted a bug to some public repo in GitHub, and it was fixed, but when I asked to release these changes I didn't get any response. So I'm waiting for next library version for 2 months. So I decided to fork this repo and publish to custom Bintray. The repo is https://github.com/okta/okta-sdk-java
The project has multiple maven modules:
$ find . -type f -name pom.xml
./httpclients/okhttp/pom.xml
./httpclients/httpclient/pom.xml
./impl/pom.xml
./swagger-templates/pom.xml
./pom.xml
./integration-tests/pom.xml
./api/pom.xml
./coverage/pom.xml
./examples/pom.xml
./examples/quickstart/pom.xml
I need to publish only impl module.
The problem is that root pom.xml has parent configuration:
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.okta</groupId>
<artifactId>okta-parent</artifactId>
<version>14</version>
<relativePath>../okta-java-parent</relativePath>
</parent>
<groupId>com.okta.sdk</groupId>
<artifactId>okta-sdk-root</artifactId>
<version>1.6.0-SNAPSHOT</version>
<packaging>pom</packaging>
And all deploy config is specified in okta-parent pom.
I tried to override repository config with (in root pom.xml):
<distributionManagement>
<repository>
<id>bintray-g4s8-maven</id>
<name>mvn</name>
<url>https://api.bintray.com/maven/g4s8/mvn/okta-sdk-impl/;publish=1</url>
</repository>
</distributionManagement>
but it didn't help.
I have server configuration in my settings.xml for this repo, and it's working fine for all other projects of mine:
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>bintray-g4s8-maven</id>
<username>g4s8</username>
<password>...</password>
</server>
</servers>
</settings>
When I'm trying to publish it I'm getting error:
$ mvn deploy -pl impl -Ppublish -DskipTests
...
[INFO] --- nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) # okta-sdk-impl ---
[INFO] Performing deferred deploys (gathering into "/home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred")...
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT.jar
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/pom.xml to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT.pom
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT-sources.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT-sources.jar
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar
[INFO] Installing /home/projects/github.com/g4s8/okta-sdk-java/impl/target/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar to /home/projects/github.com/g4s8/okta-sdk-java/impl/target/nexus-staging/deferred/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-SNAPSHOT-javadoc.jar
[INFO] Deploying remotely...
[INFO] Bulk deploying locally gathered artifacts from directory:
[INFO] * Bulk deploying locally gathered snapshot artifacts
Downloading from sonatype-nexus-snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/maven-metadata.xml
Downloaded from sonatype-nexus-snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/maven-metadata.xml (993 B at 412 B/s)
Uploading to sonatype-nexus-snapshots: https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-20191101.130725-30-javadoc.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 58.070 s
[INFO] Finished at: 2019-11-01T16:07:41+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.6.8:deploy (injected-nexus-deploy) on project okta-sdk-impl: Failed to deploy artifacts: Could not transfer artifact com.okta.sdk:okta-sdk-impl:jar:javadoc:1.6.0-20191101.130725-30 from/to sonatype-nexus-snapshots (https://oss.sonatype.org/content/repositories/snapshots/): Failed to transfer file https://oss.sonatype.org/content/repositories/snapshots/com/okta/sdk/okta-sdk-impl/1.6.0-SNAPSHOT/okta-sdk-impl-1.6.0-20191101.130725-30-javadoc.jar with status code 401 -> [Help 1]
Maven is uploading artifacts to https://oss.sonatype.org/ instead of configured URL https://api.bintray.com/maven/g4s8/mvn/okta-sdk-impl/;publish=1. How can I force it to use my URL instead of parent URL?
Update
Effective pom shows both repositories in distributionManagement:
<distributionManagement>
<repository>
<id>bintray-g4s8-maven</id>
<name>mvn</name>
<url>https://api.bintray.com/maven/g4s8/mvn/okta-sdk-impl/;publish=1</url>
</repository>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
It is looking like you are building a SNAPSHOT version. The configured <snapshotRepository> is oss.sonatype.... You only added a configuration for building release versions.
we have got a problem. I set up job on jenkins and while building a project it fetches artifacts from nexus. But even though it downloaded them job failed with artifacts could not be found. It happened only to artifacts we manually imported to the nexus.
Any hints?
[INFO] Downloading: http://xxx/nexus/content/groups/public/com/oracle/aqapi /12.1.0.2/aqapi-12.1.0.2.pom
[WARNING] The POM for com.oracle:aqapi:jar:12.1.0.2 is missing, no dependency information available
[INFO] Downloading: http://xxx/nexus/content/groups/public/com/ibm/com.ibm.mq/7.1/com.ibm.mq-7.1.pom
[WARNING] The POM for com.ibm:com.ibm.mq:jar:7.1 is missing, no dependency information available
[INFO] Downloading: http://xxx/nexus/content/groups/public/com/ibm/com.ibm.dhbcore/7.1/com.ibm.dhbcore-7.1.pom
[WARNING] The POM for com.ibm:com.ibm.dhbcore:jar:7.1 is missing, no dependency information available
[INFO] Downloading: http://xxx/nexus/content/groups/public/com/oracle/aqapi/12.1.0.2/aqapi-12.1.0.2.jar
[INFO] Downloading: http://xxx/nexus/content/groups/public/com/ibm/com.ibm.mq/7.1/com.ibm.mq-7.1.jar
[INFO] Downloading: http://xxx/nexus/content/groups/public/com/ibm/com.ibm.dhbcore/7.1/com.ibm.dhbcore-7.1.jar
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
....
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.091s
[INFO] Finished at: Fri Dec 22 14:09:58 CET 2017
[INFO] Final Memory: 16M/491M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project XXX: Could not resolve dependencies for project YYY:jar:2.14.11: The following artifacts could not be resolved: com.oracle:aqapi:jar:12.1.0.2, com.ibm:com.ibm.mq:jar:7.1, com.ibm:com.ibm.dhbcore:jar:7.1: Could not find artifact com.oracle:aqapi:jar:12.1.0.2 in nexus (http://xxx/nexus/content/groups/public) -> [Help 1]
[ERROR]`
I think it has not downloaded completely yet, you can check in ~/.m2/repository for dependency.
Because its showing only "downloading" in actual case it will appear downloaded message.
first check for the n/w settings and internet.
if n/w is not the issue delete the ~/.m2 folder and retry once again
Do you see the dependency in Nexus?
Does Information in pom file in nexus correspond to your pom?
http://nexusUrl/nexus/content/repositories/central/checkstyle/checkstyle/4.1/checkstyle-4.1.pom
<?xml version="1.0"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>checkstyle</groupId>
<artifactId>checkstyle</artifactId>
<version>4.1</version>
<dependencies>
...
</dependencies>
</project>
and in your pom:
<dependency>
<groupId>checkstyle</groupId>
<artifactId>checkstyle</artifactId>
<version>4.1</version>
</dependency>
and check your settings for access to Nexus (settings.xml).
I've just started working with maven and I can't figure out how to solve the problem I have. It seems to my java file is compiled and test starts but no result shows up.
Demo.java:
package tutorial2;
public class Demo {
public boolean getBool(){
return false;
}
}
TestDemo.java:
package tutorial2;
import static org.junit.Assert.*;
import org.junit.Test;
public class TestDemo {
#Test
public void shouldBe(){
Demo demo = new Demo();
assertTrue(demo.getBool());
}
}
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lets.develop.withme</groupId>
<artifactId>tutorial2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Tutorial 02</name>
<description>My second tutorial</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project
I'm getting this on console:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutorial 02 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # tutorial2 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # tutorial2 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # tutorial2 ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # tutorial2 ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # tutorial2 ---
[INFO] Surefire report directory: /home/adam/workspaceJavaEE/tutorial2/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running tutorial2.TestDemo
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.006 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.943 s
[INFO] Finished at: 2016-10-14T00:34:25+02:00
[INFO] Final Memory: 10M/212M
[INFO] ------------------------------------------------------------------------
Solved:
I solved problem by myself. Dependency in xml file was not configured properly. Version of junit dependency was wrong so It could't be run by maven.
Advise:
You should always add dependencies by "Insert Dependency" menu. It can be displayed by using shortcut "crtl"+"space" when your cursor is between <dependency> and </dependency> in your xml file. When you in "Select Dependency" menu enter "junit" in "Enter..." textbox and choose your version of junit. After clicking "ok" your dependency will be automatically added. This helps avoid problem with incorrect version typed manually.
By default, Surefire (the plugin that runs during mvn test) looks for classes in target/test-classes (which are compiled from src/test/java and maybe other places) that end in Test. Your class name is TestDemo, which doesn't end in Test, and won't be run. Either rename it to DemoTest (preferable), or manually configure Surefire in <plugins> (the approach when you're using a framework with alternate naming conventions, such as Spock's *Spec).
According to maven documentation avalible on:
By default, the Surefire Plugin will automatically include all test
classes with the following wildcard patterns:
"/Test*.java" - includes all of its subdirectories and all Java
filenames that start with "Test". "/*Test.java" - includes all of
its subdirectories and all Java filenames that end with "Test".
"/*TestCase.java" - includes all of its subdirectories and all Java
filenames that end with "TestCase".
I am using Stanford CoreNLP on Ubuntu 14.04 and facing the following issue when I run the following code:
Java Code:
package com.mycompany.app;
import java.io.*;
import java.util.*;
/*import edu.stanford.nlp.ling.HasWord;
import edu.stanford.nlp.ling.TaggedWord;
import edu.stanford.nlp.parser.shiftreduce.ShiftReduceParser;
import edu.stanford.nlp.process.DocumentPreprocessor;
import edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser;
import edu.stanford.nlp.trees.Tree;*/
import edu.stanford.nlp.tagger.maxent.MaxentTagger;
public class App
{
public static void main(String[] args) throws Exception, NoClassDefFoundError
{
MaxentTagger tagger = null;
if(tagger == null)
{
tagger = new MaxentTagger("mymodel.tagger");
}
System.out.println("Let's do this!");
}
}
Command Run:
mvn clean install exec:java -Dexec.mainClass=com.mycompany.app.App
Terminal Output:
[INFO]
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) # dt_mvn ---
[INFO] Building jar: /home/sidharth/Desktop/dt_mvn/target/dt_mvn-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3:install (default-install) # dt_mvn ---
[INFO] Installing /home/sidharth/Desktop/dt_mvn/target/dt_mvn-1.0-SNAPSHOT.jar to /home/sidharth/.m2/repository/com/mycompany/app/dt_mvn/1.0-SNAPSHOT/dt_mvn-1.0-SNAPSHOT.jar
[INFO] Installing /home/sidharth/Desktop/dt_mvn/pom.xml to /home/sidharth/.m2/repository/com/mycompany/app/dt_mvn/1.0-SNAPSHOT/dt_mvn-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- exec-maven-plugin:1.4.0:java (default-cli) # dt_mvn ---
Reading POS tagger model from mymodel.tagger ... [WARNING]
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:293)
at java.lang.Thread.run(Thread.java:745)
Caused by: edu.stanford.nlp.io.RuntimeIOException: java.io.StreamCorruptedException: invalid stream header: 00048E4D
at edu.stanford.nlp.maxent.iis.LambdaSolve.read_lambdas(LambdaSolve.java:726)
at edu.stanford.nlp.tagger.maxent.LambdaSolveTagger.<init>(LambdaSolveTagger.java:76)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:863)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.readModelAndInit(MaxentTagger.java:767)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:298)
at edu.stanford.nlp.tagger.maxent.MaxentTagger.<init>(MaxentTagger.java:263)
at com.mycompany.app.App.main(App.java:22)
... 6 more
Caused by: java.io.StreamCorruptedException: invalid stream header: 00048E4D
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:806)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)
at edu.stanford.nlp.maxent.iis.LambdaSolve.read_lambdas(LambdaSolve.java:719)
... 12 more
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.260s
[INFO] Finished at: Sun Dec 20 01:34:29 IST 2015
[INFO] Final Memory: 23M/228M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project dt_mvn: An exception occured while executing the Java class. null: InvocationTargetException: java.io.StreamCorruptedException: invalid stream header: 00048E4D -> [Help 1]
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>dt_mvn</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>dt_mvn</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.5.2</version>
</dependency>
</dependencies>
</project>
However, changing version in pom.xml from 3.5.2 to 1.3.0 works correctly. What could be the reason for this?
Thanks!
P.S.
If it's of any use, the maven project was created by the following command:
mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=dt_mvn -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
I suspect however you built "mymodel.tagger" is incompatible with later versions so the deserialization is failing. What version did you use to build my_model.tagger? Does your Maven project fail if you use 1.3.5 ? I can see changes in our repo in LambdaSolve.java involving serialization in the time period between 1.3.1 and 1.3.5 so I suspect that is the reason.
Also make sure you use Java 1.8 with Stanford CoreNLP 3.5.0 or later.