Failure in running maven - java

i've installed maven in my PC. and i've followed the instruction on this web http://books.sonatype.com/mvnref-book/reference/installation.html , but when i would try to run it in command line (as written), i've got BUILD FAILURE error just like this picture below.
How can i solve this problem? Thanks for any response
Btw, my other question, is there any documentation of configurating java application into guvnor? i'm so grateful if anyone knows about this. :)

You should specify a goal for the build. Check this for more info http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

You did not specify a goal for maven to run, so it does not know what to do with the project.
Maven relies on a certain lifecycle, ie an order of so called goals to accomplish its tasks, for example "clean" to empty the current target folder, "install" to compile, test, package and copy the jars into your local respository. To get into the details, read up this documentation.
Since the error message does not differ, another error might be that you entered the command in a folder where no valid pom file is located. If you entered a complete maven command with goals, this would be the next bet.

Related

Jenkinsfile path location "#2 converted to %402" and build is failing

I have one Jenkins job which does following things
Checks out the Jenkinsfile from github at some location (c:\jenkins\workspace\my_build)
Jenkinsfile checks out java source code to (c:\jenkins\workspace\my_build#2)
mvn clean install
When I run "mvn clean install" on my build machine it works perfectly fine.
But when I run it thorough Jenkisnfile I have few unit test cases which runs when building my project, those units tests are failing with java.io.FileNotFoundException(The system cannot find the path specified) exception/error.
When I ran maven in debug mode(using -X) I found out the workspace path(c:\jenkins\workspace\my_build#2) is being converted to c:\jenkins\workspace\my_build%402 hence maven is unable to find the file which is required for my unit test cases to pass.
How can I fix this issue?
I managed to fix the issue by using a custom workspace. Something like this
ws("c:\jenkins\my_custom_location") {
// git checkout
// mvn clean install
}
Jenkins didn't create any directory with #2 or #3 when using custom workspace.
#user3847894,
You did not fix the issue, merely worked around the problem (avoidance). Now, if you run builds in parallel, they will all use the same workspace, probably with horribly unintended consequences.
You can try choose a different symbol:
hudson.slaves.WorkspaceList
Since: 1.424 Default:
# Description: When concurrent builds is
enabled, a unique workspace directory name is required for each
concurrent build. To create this name, this token is placed between
project name and a unique ID, e.g. "my-project#123".
Or figure out the real problem:
where your system is pulling the wrong character set (ANSI vs UTF-8 ? locale), encoding or something is wrongly "sanitizing the path" (eg: OWASP Sanitizer).
You'd have to provide way more info re: OS, jdk, system and startup parameters, etc to diagnose, list of plugins (maven and Jenkins), so can't help further. Check controller and agent system info (${JENKINS_URL}/systemInfo and ${JENKINS_URL}/computer/myNode/systemInfo) and also see what maven reports in the settings and help:system. On your own; good luck

How to avoid calling javadoc more than once if creating a site?

I would like to deploy an artifact together with javadoc and a Maven site. I use
clean javadoc:jar site deploy site:deploy
(the split between site and site:deploy is just to avoid the deployment of a site if deploy fails).
Now the javadoc is created twice - once in javadoc:jar and once in site. Is it possible to create it just once and use it both for the javadoc-jar in Nexus and the Maven site?
I'm pretty sure the plugin is missing a check if the output is already generated as part of the Maven session. Would be a nice improvement to verify if the output is generated after Maven had started. (and let's add a force-parameter to enforce the creation anyway).
Possible solution that may you use is creation two different scripts for build/deploy and run them one by one:
Firstly - full build with with -Dmaven.javadoc.skip=true, that avoids you to create javadoc
Another - only run mvn javadoc:javadoc command to get actual javadoc
Also, maybe next link help you:
https://maven.apache.org/plugins/maven-javadoc-plugin/examples/selective-javadocs-report.html
https://maven.apache.org/plugins/maven-javadoc-plugin/examples/test-javadocs.html
So, you can specify execution phase of javadoc plugin and specify reportSet.

Code doesn't execute in debug mode, asks for source

I am executing a code that does some database operations.
It performs well when I execute it using the Run command in Eclipse.
But when I execute it in debug mode, I get the source not found
The JAR file mysql-connector-java-5.1.39-bin.jar has no source attachment
You're trying to step into code provided by mysql-connector-java, and you haven't linked in an source code for Eclipse to actually step-in-to.
The easiest thing to do would be to step over that line (since you probably don't care about it) rather than trying to debug the connector code. You may also want to tweak your debugger settings to prevent exceptions from pausing your execution.
As #nitind points out you can also filter types, packages, and patterns so the debugger avoids stepping through them.
If that doesn't work or you do need to step into the connector code you'll need to download a source jar (from Maven) and attach it in your project's build configuration.
Debugging in eclipse program works with the class actually loaded.
The problem you posted looks like the class you are using was not found in the project, but is present without debug info in a distribution jar.
This can be solved most likely by altering the build path of the project to stop using this jar and have the JVM using the project.
or you can try mvn clean eclipse:eclipse
This is happening because the debugger is running into some class file...
To view this, either download the source code and attach it or install some class decompiler plugin (I am using JAD Eclipse Plugin). The first solution is better.

Command works in terminal but not with java [duplicate]

What are the possible causes of a "java.lang.Error: Unresolved compilation problem"?
Additional information:
I have seen this after copying a set of updated JAR files from a build on top of the existing JARs and restarting the application. The JARs are built using a Maven build process.
I would expect to see LinkageErrors or ClassNotFound errors if interfaces changed. The above error hints at some lower level problem.
A clean rebuild and redeployment fixed the problem. Could this error indicate a corrupted JAR?
(rewritten 2015-07-28)
Summary: Eclipse had compiled some or all of the classes, and its compiler is more tolerant of errors.
Long explanation:
The default behavior of Eclipse when compiling code with errors in it, is to generate byte code throwing the exception you see, allowing the program to be run. This is possible as Eclipse uses its own built-in compiler, instead of javac from the JDK which Apache Maven uses, and which fails the compilation completely for errors. If you use Eclipse on a Maven project which you are also working with using the command line mvn command, this may happen.
The cure is to fix the errors and recompile, before running again.
The setting is marked with a red box in this screendump:
try to clean the eclipse project
you just try to clean maven by command
mvn clean
and after that following command
mvn eclipse:clean eclipse:eclipse
and rebuild your project....
Your compiled classes may need to be recompiled from the source with the new jars.
Try running "mvn clean" and then rebuild
The major part is correctly answered by Thorbjørn Ravn Andersen.
This answer tries to shed light on the remaining question: how could the class file with errors end up in the jar?
Each build (Maven & javac or Eclipse) signals in its specific way when it hits a compile error, and will refuse to create a Jar file from it (or at least prominently alert you). The most likely cause for silently getting class files with errors into a jar is by concurrent operation of Maven and Eclipse.
If you have Eclipse open while running a mvn build, you should disable Project > Build Automatically until mvn completes.
EDIT:
Let's try to split the riddle into three parts:
(1) What is the meaning of "java.lang.Error: Unresolved compilation
problem"
This has been explained by Thorbjørn Ravn Andersen. There is no doubt that Eclipse found an error at compile time.
(2) How can an eclipse-compiled class file end up in jar file created
by maven (assuming maven is not configured to used ecj for
compilation)?
This could happen either by invoking Maven with no or incomplete cleaning. Or, an automatic Eclipse build could react to changes in the filesystem (done by Maven) and re-compile a class, before Maven proceeds to collect class files into the jar (this is what I meant by "concurrent operation" in my original answer).
(3) How come there is a compile error, but mvn clean succeeds?
Again several possibilities: (a) compilers don't agree whether or not the source code is legal, or (b) Eclipse compiles with broken settings like incomplete classpath, wrong Java compliance etc. Either way a sequence of refresh and clean build in Eclipse should surface the problem.
I had this error when I used a launch configuration that had an invalid classpath. In my case, I had a project that initially used Maven and thus a launch configuration had a Maven classpath element in it. I had later changed the project to use Gradle and removed the Maven classpath from the project's classpath, but the launch configuration still used it. I got this error trying to run it. Cleaning and rebuilding the project did not resolve this error. Instead, edit the launch configuration, remove the project classpath element, then add the project back to the User Entries in the classpath.
I got this error multiple times and struggled to work out. Finally, I removed the run configuration and re-added the default entries. It worked beautifully.
Just try to include package name in eclipse in case if you forgot it
Import all packages before using it, EX: import java.util.Scanner before using Scanner class.
These improvements might work and it will not give Java: Unresolved compilation problem anymore.
Also make sure to check compiler compliance level and selected jdk version is same
As a weird case, I encountered such an exception where the exception message (unresolved compilation bla bla) was hardcoded inside of generated class' itself. Decompiling the class revealed this.
I had the same issue using the visual studio Code. The root cause was backup java file was left in the same directory.
Removed the backup java file
When the build failed, selected the Fix it, it cleaned up the cache and restarted the workSpace.

Compiling Bukkit plugin from GitHub

I am trying to compile a plugin for Bukkit and I cant seem to get it to work. I have copied some code from github "GitHub Code" and have imported it into eclipse as a maven project. When I try and do run-as 'Maven Build' it displays lot of text but finally gives me these errors.
Failed to execute goal on project BlockHunt: Could not resolve dependencies for project nl.Steffion:BlockHunt:jar:0.2.1-
b${env.BUILD_NUMBER}: Failed to collect dependencies at org.bukkit:bukkit:jar:1.7.9-R0.2-SNAPSHOT:
Failed to read artifact descriptor for org.bukkit:bukkit:jar:1.7.9-R0.2-SNAPSHOT: Could not transfer artifact org.bukkit:bukkit:pom:1.7.9-
R0.2-SNAPSHOT from/to bukkit-maven (http://repo.bukkit.org/content/repositories/releases/): Access denied
to http://repo.bukkit.org/content/repositories/releases/org/bukkit/bukkit/1.7.9-R0.2-SNAPSHOT/bukkit-1.7.9-R0.2-SNAPSHOT.pom.
I read in another post that I can put "dependency:copy-dependencies" in my run configurations for maven and its supposed try and download the stuff i need but it says access denied. I have never used maven or github so this is all new to me but it seems it should be really simple. All I really want to do is download the the code and create a jar file with it so I can use it. If anyone can point me in the right direction to making a jar from the code that would be great.
The plugin developer was getting the JavaDocs from the bukkit website, instead of downloading the jar and accessing it locally.
You may want to take a look at this, it may not specifically solve this problem, but it could help you get the code off of Github and into Eclipse correctly. – Jojodmo yesterday
His example showed you how to link to it locally.
Sometimes bukkit make some of their builds 'private', they do this to stop people downloading builds that did not pass the testing phase.
Remember that the link they are using is 1.7.9. At this time 1.8.1 is out so you might want to use the latest version.

Categories

Resources