I met two unsolvable problems about jenkins - java

Firstly this are my configures
enter image description here
It seems that I can't upload the picture, so I copied the error message
my jdk version is jdk1.8.0_152
my maven version is apache-maven-3.6.1-bin
I can run this program in IDEA
public class Main {
public static void main(String[] args) throws IOException {
String filePath = "./cifile";
File dir = new File(filePath);
// 一、检查放置文件的文件夹路径是否存在,不存在则创建
if (!dir.exists()) {
dir.mkdirs();// mkdirs创建多级目录
}
File checkFile = new File(filePath + "/filename.txt");
FileWriter writer = null;
try {
// 二、检查目标文件是否存在,不存在则创建
if (!checkFile.exists()) {
checkFile.createNewFile();// 创建目标文件
}
// 三、向目标文件中写入内容
// FileWriter(File file, boolean append),append为true时为追加模式,false或缺省则为覆盖模式
writer = new FileWriter(checkFile, true);
writer.append("my content");
writer.flush();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != writer)
writer.close();
}
}
}
This program is just a simple write file
So there is no configuration in my pom.xml 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>org.example</groupId>
<artifactId>citest</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
</project>
The following is my error message
Started by user ameng
Running as SYSTEM
Building in workspace C:\Users\阿蒙\.jenkins\workspace\test
Updating http://114.67.219.61:8080/svn/TeamDesigner at revision '2022-10-21T14:20:55.278 +0800' --quiet
Using sole credentials pengweihao/****** in realm ‘<http://114.67.219.61:8080> VisualSVN Server’
At revision 3
No changes for http://114.67.219.61:8080/svn/TeamDesigner since the previous build
Parsing POMs
Established TCP socket on 64312
[TeamDesigner] $ "C:\Program Files\Java\jdk1.8.0_152/bin/java" -cp C:\Users\阿蒙\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-agent-1.14.jar;D:\apache-maven-3.6.1-bin\boot\plexus-classworlds-2.6.0.jar;D:\apache-maven-3.6.1-bin/conf/logging jenkins.maven3.agent.Maven35Main D:\apache-maven-3.6.1-bin C:\Users\??\.jenkins\war\WEB-INF\lib\remoting-4.13.2.jar C:\Users\阿蒙\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-interceptor-1.14.jar C:\Users\阿蒙\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.14.jar 64312
Exception in thread "main" java.lang.ClassNotFoundException: hudson.remoting.Launcher
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at jenkins.maven3.agent.Maven35Main.main(Maven35Main.java:136)
at jenkins.maven3.agent.Maven35Main.main(Maven35Main.java:66)
ERROR: ================================================================================
ERROR: Invalid project setup: Connection reset
ERROR: [JENKINS-18403][JENKINS-28294] JDK 'jdk' not supported to run Maven projects.
ERROR: Maven projects have to be launched with a Java version greater or equal to the minimum version required by the controller.
ERROR: Use the Maven JDK Toolchains (plugin) to build your maven project with an older JDK.
ERROR: Retrying with agent Java and setting compile/test properties to point to C:\Program Files\Java\jdk1.8.0_152.
ERROR: ================================================================================
Established TCP socket on 64314
[TeamDesigner] $ "C:\Program Files\Java\jre1.8.0_152/bin/java" -cp C:\Users\阿蒙\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-agent-1.14.jar;D:\apache-maven-3.6.1-bin\boot\plexus-classworlds-2.6.0.jar;D:\apache-maven-3.6.1-bin/conf/logging jenkins.maven3.agent.Maven35Main D:\apache-maven-3.6.1-bin C:\Users\??\.jenkins\war\WEB-INF\lib\remoting-4.13.2.jar C:\Users\阿蒙\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven35-interceptor-1.14.jar C:\Users\阿蒙\.jenkins\plugins\maven-plugin\WEB-INF\lib\maven3-interceptor-commons-1.14.jar 64314
Exception in thread "main" java.lang.ClassNotFoundException: hudson.remoting.Launcher
at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
at jenkins.maven3.agent.Maven35Main.main(Maven35Main.java:136)
at jenkins.maven3.agent.Maven35Main.main(Maven35Main.java:66)
[TeamDesigner] $ cmd.exe /C "D:\apache-maven-3.6.1-bin\bin\mvn.cmd clean package && exit %%ERRORLEVEL%%"
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< org.example:citest >-------------------------
[INFO] Building citest 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # citest ---
[INFO] Deleting C:\Users\阿蒙\.jenkins\workspace\test\TeamDesigner\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # citest ---
[WARNING] Using platform encoding (GBK 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) # citest ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\阿蒙\.jenkins\workspace\test\TeamDesigner\target\classes
[WARNING] /C:/Users/阿蒙/.jenkins/workspace/test/TeamDesigner/src/main/java/org/example/Main.java:[15,13] 编码GBK的不可映射字符
[WARNING] /C:/Users/阿蒙/.jenkins/workspace/test/TeamDesigner/src/main/java/org/example/Main.java:[22,18] 编码GBK的不可映射字符
[WARNING] /C:/Users/阿蒙/.jenkins/workspace/test/TeamDesigner/src/main/java/org/example/Main.java:[26,18] 编码GBK的不可映射字符
[WARNING] /C:/Users/阿蒙/.jenkins/workspace/test/TeamDesigner/src/main/java/org/example/Main.java:[26,34] 编码GBK的不可映射字符
[WARNING] /C:/Users/阿蒙/.jenkins/workspace/test/TeamDesigner/src/main/java/org/example/Main.java:[27,93] 编码GBK的不可映射字符
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # citest ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\阿蒙\.jenkins\workspace\test\TeamDesigner\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # citest ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # citest ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # citest ---
[INFO] Building jar: C:\Users\阿蒙\.jenkins\workspace\test\TeamDesigner\target\citest-1.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.156 s
[INFO] Finished at: 2022-10-21T14:20:59+08:00
[INFO] ------------------------------------------------------------------------
ERROR: Failed to parse POMs
java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
at hudson.remoting.ChannelBuilder.negotiate(ChannelBuilder.java:457)
at hudson.remoting.ChannelBuilder.build(ChannelBuilder.java:404)
at hudson.slaves.Channels.forProcess(Channels.java:119)
at hudson.maven.AbstractMavenProcessFactory.newProcess(AbstractMavenProcessFactory.java:296)
at hudson.maven.ProcessCache.get(ProcessCache.java:236)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.doRun(MavenModuleSetBuild.java:802)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:524)
at hudson.model.Run.execute(Run.java:1897)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE
I can't understand why my jdk can't support running maven
Secondly, it is clear that the compilation has been successful and the jar package has also been generated, but why does the final result still fail
By the way, I pull files from TortoiseSVN
Related links do not solve my problem because I only have one machine working, no msater and slave

Related

Quarkus : com.google.protobuf-protoc-linux-x86_64-exe: 1: cannot open !--: No such file

Quarkus maven install command doesn't work after platform version 2.6.3.Final.
pom.xml ;
<properties>
<quarkus.platform.version>2.7.4.Final</quarkus.platform.version>
</properties>
Everything is normal in version 2.6.3.Final, but for versions after 2.7.**, even if it is exist in the /target, it's getting an error as follows;
com.google.protobuf-protoc-linux-x86_64-exe: 1: cannot open !--: No such file
ROG-PC:/Projects/$ mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------< microservice:configurator >------------
[INFO] Building Configurator Microservice 1.0.0.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # configurator ---
[INFO] Deleting /Projects/Source/configurator-microservice/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # configurator ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- quarkus-maven-plugin:2.7.4.Final:generate-code (default) # configurator ---
/Projects/Source/configurator-microservice/target/com.google.protobuf-protoc-linux-x86_64-exe: 1: cannot open !--: No such file
/Projects/Source/configurator-microservice/target/com.google.protobuf-protoc-linux-x86_64-exe: 3: Copyright: not found
/Projects/Source/configurator-microservice/target/com.google.protobuf-protoc-linux-x86_64-exe: 5: Syntax error: "(" unexpected
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.602 s
[INFO] Finished at: 2022-03-17T17:30:45+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.7.4.Final:generate-code (default) on project configurator:
Quarkus code generation phase has failed: InvocationTargetException: Failed to generate Java classes from proto files:
[/Projects/Source/configurator-microservice/src/main/proto/customer_configuration.proto] to
/Projects/Source/configurator-microservice/target/generated-sources/grpc with command /Projects/Source/configurator-microservice/target/com.google.protobuf-protoc-linux-x86_64-exe
mvn version;
ROG-PC:/Projects/$ mvnq -v
Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /Projects/Applications/apache-maven-3.8.4
Java version: 17.0.1, vendor: GraalVM Community, runtime: /usr/lib/jvm/graalvm-ce-java17-21.3.0
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "5.13.0-19-generic", arch: "amd64", family: "unix"
NOTE: This error occurs only if there are .proto files in the project.
All Quarkus Dependencies added to pom.xml.
I don't know what is difference between quarkus platform version 2.6.3 and 2.7.** and why this getting this error.
Thank you for your help.

Not able to deploy to Websphere Application server 8.5 through Jenkins

I am getting below error:
"No deployable artifacts found in path" while doing deploy through Jenkins.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Activation 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # Activation ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Activation ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # Activation ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 9 source files to C:\Users\.jenkins\workspace\TestBuild\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Activation ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # Activation ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Activation ---
[JENKINS] Recording test results
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # Activation ---
[INFO] Packaging webapp
[INFO] Assembling webapp [Activation] in [C:\Users\.jenkins\workspace\TestBuild\target\Activation-0.1]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\.jenkins\workspace\TestBuild\src\main\webapp]
[INFO] Webapp assembled in [462 msecs]
[INFO] Building war: C:\Users\.jenkins\workspace\TestBuild\target\Activation-0.1.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # Activation ---
[INFO] Installing C:\Users\.jenkins\workspace\TestBuild\target\Activation-0.1.war to C:\Users\.m2\repository\com\ibm\rest\Activation\0.1\Activation-0.1.war
[INFO] Installing C:\Users\.jenkins\workspace\TestBuild\pom.xml to C:\Users\.m2\repository\com\ibm\rest\Activation\0.1\Activation-0.1.pom
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.926 s
[INFO] Finished at: 2017-12-17T15:19:38+05:30
[INFO] Final Memory: 23M/254M
[INFO] ------------------------------------------------------------------------
channel stopped
Connecting to IBM WebSphere Application Server...
No deployable artifacts found in path: C:\Users\.jenkins\workspace\modules/**lastSuccessful/**/Activation-*.ear
Error deploying to IBM WebSphere Application Server: java.lang.Exception: No deployable artifacts found!
at org.jenkinsci.plugins.websphere_deployer.WebSphereDeployerPlugin.gatherArtifactPaths(WebSphereDeployerPlugin.java:286)
at org.jenkinsci.plugins.websphere_deployer.WebSphereDeployerPlugin.perform(WebSphereDeployerPlugin.java:196)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1073)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1749)
at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Below are my Jenkins Configurations:
Someone please suggest me what I am missing. I downloaded Maven Pluggin and Websphere Deploy Pluggin. My build is getting successful and also project is being copied in .jenkins/workplace folder but when it is trying to deploy to WAS , I am getting this error. Please guide me.
Just use **/*.ear if you're only deploying 1 EAR file for the "EAR Path". It should find it. If you're deploying a WAR use **/*.war and it will generate the EAR for you.

Maven failing to assemble WAR - Java Heap Space Issue - Stanford Core NLP

So i'm getting this error when trying to Clean Install with Maven. I've attempted increasing MAVEN_OPTS with Xmx-512m or w/e it was called, similarly fiddled with Eclipse ini to increase heap space, but all of this to no avail, I keep getting this error:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building DiaryAppREST 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # DiaryAppREST ---
[INFO] Deleting C:\Users\Administrator\workspace\DiaryAppREST\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # DiaryAppREST ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Administrator\workspace\DiaryAppREST\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) # DiaryAppREST ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\Administrator\workspace\DiaryAppREST\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # DiaryAppREST ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\Administrator\workspace\DiaryAppREST\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) # DiaryAppREST ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # DiaryAppREST ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:3.0.0:war (default-war) # DiaryAppREST ---
[INFO] Packaging webapp
[INFO] Assembling webapp [DiaryAppREST] in [C:\Users\Administrator\workspace\DiaryAppREST\target\DiaryAppREST-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\Administrator\workspace\DiaryAppREST\WebContent]
[INFO] Webapp assembled in [8913 msecs]
[INFO] Building war: C:\Users\Administrator\workspace\DiaryAppREST\target\DiaryAppREST-0.0.1-SNAPSHOT.war
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 27.019 s
[INFO] Finished at: 2017-02-28T09:52:30+00:00
[INFO] Final Memory: 86M/247M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:3.0.0:war (default-war) on project DiaryAppREST: Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrupt but I could not delete it): Java heap space -> [Help 1]
[ERROR]
I can't understand what is causing this, tried to find information online but can't seem to find this specific problem that anyone else is having. If anyone would be able to help i'd be very much appreciated.
Just figured it out,
Firstly, I had set MAVEN_OPTS incorrectly, I had them set as:
set MAVEN_OPTS="Xmx 512m"
After changing this to:
set MAVEN_OPTS="-Xmx512m"
You can also add this line into your profile (.profile, .bash_profile, etc) for this to be set in every terminal you open.
export MAVEN_OPTS="-Xmx512m"
And then went into the directory the project was in using CMD,
I ran:
mvn clean install -U
This seemed to do the trick and everything went successfully.
Hope this helps anyone else having problems!
I had the same issue running maven via ant from Jenkins on a Windows box.
The issue was how to pass the memory parameter. Here is the updated ant script showing how to pass the parameter "<jvmarg value="-Xmx1024m" />":
<target name="web.package" depends="init" if="warName">
<artifact:mvn mavenHome="${maven.home}" failonerror="true" fork="true">
<jvmarg value="-Dmaven.multiModuleProjectDirectory=$M2_HOME" />
<jvmarg value="-Xmx1024m" />
<arg value="package" />
<arg value="-Pwar" />
<arg value="-DwarName=${warName}" />
<arg value="-Denv=${env}" />
<arg value="-e" />
</artifact:mvn>
</target>
For info, here is the crash output:
[artifact:mvn] [INFO] Building war: D:\Jenkins\workspace\DEPLOY_SVN\atl_dev_trunk\src\tomcat\target\abc##6_4_6_0.war
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] BUILD FAILURE
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [INFO] Total time: 01:50 min
[artifact:mvn] [INFO] Finished at: 2017-11-09T02:35:50+01:00
[artifact:mvn] [INFO] Final Memory: 99M/247M
[artifact:mvn] [INFO] ------------------------------------------------------------------------
[artifact:mvn] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:3.0.0:war (default-war) on project abc: Error assembling WAR: Problem creating war: Execution exception (and the archive is probably corrupt but I could not delete it): Java heap space -> [Help 1]

maven copy test resources into jar fails

I need some resources that are under:
src/main/resources/__files/
Now when creating my jar with maven those are not included.
This is my pomfile:
http://pastebin.com/xMtJDei2
when creating my app I get this:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building wiremock 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # wiremock ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # wiremock ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to /Users/betauser/Documents/Development/wiremock/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # wiremock ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/betauser/Documents/Development/wiremock/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # wiremock ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # wiremock ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.2:jar (default-jar) # wiremock ---
[INFO] Building jar: /Users/betauser/Documents/Development/wiremock/target/WiremockServer.jar
[INFO]
[INFO] --- maven-dependency-plugin:2.9:copy-dependencies (copy-dependencies) # wiremock ---
[INFO] Copying slf4j-api-1.7.6.jar to /Users/betauser/Documents/Development/wiremock/target/dependency-jars/slf4j-api-1.7.6.jar
[INFO] Copying wiremock-1.52-standalone.jar to /Users/betauser/Documents/Development/wiremock/target/dependency-jars/wiremock-1.52-standalone.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.229 s
[INFO] Finished at: 2014-12-11T14:40:16+01:00
[INFO] Final Memory: 14M/81M
[INFO] ------------------------------------------------------------------------
Process finished with exit code 0
and when I run my program and I ask the file I get:
java.io.FileNotFoundException: /Users/betauser/Documents/Development/wiremock/target/src/main/resources/__files/test-long.mp3 (No such file or directory)
I wonder about the output ".../target/src/main/resources/..." .
The directory structure "src/main/resources" can't exist below "target", if your artifact builds properly.
The files you create in /src/main/resources and below belong to the classpath of your application.
Open your artifact (jar) which was created during the build process. There you should find a directory entry named "__files".

Compile maven netbeans project in terminal

I would like compile a Netbeans Maven - Java Application in my linux terminal.
This is because I would like to work with Git CVS and be able to compile the project in a server being IDE independent.
But I'm having trouble understanding really how dependencies work, or that's what I think.
I'm using a simple java application code to connect to a mysql database and get some information.
I'm using this code:
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver");
try (Connection connect = DriverManager.getConnection("jdbc:mysql://192.168.2.21/altadb?" + "user=marco&password=Marco19")) {
Statement statement = connect.createStatement();
ResultSet resultSet = statement.executeQuery("select idCuentaConcentradora, noCliente, nombreCliente, noCuenta, nombreCuenta from altadb.catCuentaConcentradora");
while (resultSet.next()) {
int idCuentaConcentradora = resultSet.getInt("idCuentaConcentradora");
String noCliente = resultSet.getString("noCliente");
String nombreCliente = resultSet.getString("nombreCliente");
String noCuenta = resultSet.getString("noCuenta");
String nombreCuenta = resultSet.getString("nombreCuenta");
System.out.println("idCuentaConcentradora: " + idCuentaConcentradora);
System.out.println("noCliente: " + noCliente);
System.out.println("nombreCliente: " + nombreCliente);
System.out.println("noCuenta: " + noCuenta);
System.out.println("nombreCuenta: " + nombreCuenta);
System.out.println("---------------------------------------------------");
}
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
Then added the mysql-connector-java to the project dependencies, the pom.xml looks like this:
<?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.alta.MySQLAccess_Mvn</groupId>
<artifactId>MySQLAccess_Mvn</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.31</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>
If I use the netbeans IDE with clean and build and then run the project there is no error and the information is fetched from the database.
If I try to do the same from terminal I get an error:
[marko#mark-laptop MySQLAccess_Mvn]$ mvn clean install
[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 MySQLAccess_Mvn 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # MySQLAccess_Mvn ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # MySQLAccess_Mvn ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # MySQLAccess_Mvn ---
[INFO] Compiling 1 source file to /home/marko/NetBeansProjects/MySQLAccess_Mvn/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # MySQLAccess_Mvn ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/marko/NetBeansProjects/MySQLAccess_Mvn/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # MySQLAccess_Mvn ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # MySQLAccess_Mvn ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # MySQLAccess_Mvn ---
[INFO] Building jar: /home/marko/NetBeansProjects/MySQLAccess_Mvn/target/MySQLAccess_Mvn-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # MySQLAccess_Mvn ---
[INFO] Installing /home/marko/NetBeansProjects/MySQLAccess_Mvn/target/MySQLAccess_Mvn-1.0-SNAPSHOT.jar to /home/marko/.m2/repository/com/alta/MySQLAccess_Mvn/MySQLAccess_Mvn/1.0-SNAPSHOT/MySQLAccess_Mvn-1.0-SNAPSHOT.jar
[INFO] Installing /home/marko/NetBeansProjects/MySQLAccess_Mvn/pom.xml to /home/marko/.m2/repository/com/alta/MySQLAccess_Mvn/MySQLAccess_Mvn/1.0-SNAPSHOT/MySQLAccess_Mvn-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.866 s
[INFO] Finished at: 2014-06-18T18:46:28-06:00
[INFO] Final Memory: 12M/144M
[INFO] ------------------------------------------------------------------------
[marko#mark-laptop MySQLAccess_Mvn]$ java -cp target/MySQLAccess_Mvn-1.0-SNAPSHOT.jar com.marco.mysql.first.test.test
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at com.marco.mysql.first.test.test.main(test.java:23)
Thought since the dependency is being declared in the pom.xml the mysql driver would have been added to the project libraries... but it doesn't.
I would like to achieve the same output from Netbeans from terminal, from build to run.
I don't know how to do it.
If you have maven added to the system path then you can simply compile it using the maven commands on the prompt:
mvm clean install

Categories

Resources