I am trying to convert a project from compiling with Java 6 to Java 8. We are using the webstart-maven-plugin for which there is currently a workaround (http://mojo.10943.n7.nabble.com/jira-MWEBSTART-269-Java-8-support-td44357.html) for compiling with Java 8 by adding the following dependencies to the plugin definition.
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-6</version>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-pack200-impl</artifactId>
<version>1.0-beta-6</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-api-1.7</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
...
</plugin>
</plugins>
</pluginManagement>
</build>
...
This got me past my initial issues.
I am now receiving the following error.
[ERROR] Failed to execute goal org.codehaus.mojo:webstart-maven-plugin:1.0-beta-6:jnlp-inline (default) on project <redacted>: Unable to parse configuration of mojo org.codehaus.mojo:webstart-maven-plugin:1.0-beta-6:jnlp-inline for parameter pack200: Cannot find default setter in class org.codehaus.mojo.webstart.Pack200Config -> [Help 1]
The Help link goes to the following page.
https://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException
As far as I can figure out, the webstart-pack200-impl dependency requires some configuration to define which setter is used. Any information regarding setters that I have found online seems to be a different issue from this. I can't figure out if there is a way to set a configuration for a dependency.
Or am I looking at this in a completely incorrect way?
Many thanks in advance
the error points to pack200 which was configured as <pack200>false</pack200>in older version of webstart plugin configuration.
This can be resolved by changing pack200 configuration to this instead (within <configuration> section of the plugin settings)
<pack200><enabled>false</enabled></pack200>
for more details please refer http://www.mojohaus.org/webstart/webstart-maven-plugin/upgrade.html section "Important changes since 1.0-beta-3"
Related
I would like to use the #Tag available in JUnit 5 in order to easily filter my tests.
I have found in this blog input from September 2016 that IntelliJ was not supporting #Tag. Not sure what the current status is though.
Also, I am very new to using Maven but I have tried modifying the POM file in order to filter tests when executing mvn test in a command prompt. No luck.
Now it is possible with Intellij IDEA 2018.1, take a look at this answer for details (including screenshot).
Also, you can see Build Support with Maven in JUnit official documentation for a proper configuration of maven-surefire-plugin. The section Filtering by Tags can be especially useful to filter tests by tags.
Example (excluding all tests with the "integration" tag):
...
<build>
<plugins>
...
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<properties>
<excludeTags>integration</excludeTags>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
...
</dependencies>
</plugin>
</plugins>
</build>
...
Here's the solution I found: changing the JUnit versions in the POM file from ...
<junit.jupiter.version>5.0.0-M2</junit.jupiter.version>
<junit.vintage.version>4.12.0-M2</junit.vintage.version>
<junit.platform.version>1.0.0-M2</junit.platform.version>
to
<junit.jupiter.version>5.0.0-M3</junit.jupiter.version>
<junit.vintage.version>4.12.0-M3</junit.vintage.version>
<junit.platform.version>1.0.0-M3</junit.platform.version>
allowed Maven to recognize the #Tag.
I am deploying webapp to the openshift cloud.
While compiling the resources by maven automatically after deploying, it shows Base64: symbol not found
However when I maven compile it on my Pc, their are no errors and build is successfull. I tried to change Base64 from java.util to apache.commons.codecs. The error is still there while deploying and it successfully runs at my local machine
Following is the pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
Should I place the commons-codec jar in WEB_INF directory. i read the solution somewhere but was not sure about it.
please suggest a solution. Thank you
</dependencies>
My guess is that you're using JDK 8 on your machine, but JDK 7 where the error is happening as java.util.Base64 is only available since Java SE 8.
I recommend to use the same Java version on both machines.
Otherwise you should consider cross-compiling. Just setting the source and target level is not enough, as you can see, as you're still able to call new APIs.
I have a maven project(POM.xml) having java and Js files.I want to call sonar analysis from Jenkins.Please let me know how can I do to analyse both Java and Javascript files.I have done it for Java using sonar runner but the problem is Javascripts files are in different locations in Project directory.Hence,
sonar.src=src/main/java will not work here.I think I need to go with Maven POM.xml to do the analysis as using POM.xml the project is getting build so analysis may be possible also?
1)I know using mvn sonar:sonar is possible but what I need to add in POM.xml for Sonar?
2)What I need to change in MAVEN settings.xml?
3)Please let me know the exact step by step if possible.
Thanks in advance!
You can try this here
<project>
...
<build>
<!-- To define the plugin version in your parent POM -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
...
</plugins>
</pluginManagement>
<!-- To use the plugin goals in your POM or parent POM -->
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.5</version>
</plugin>
...
</plugins>
</build>
...
</project>
the website that has information to help you is this one here.
There is something I don't understand with maven and I didn't find any answer out there. So I ask it here, hoping to get an answer.
I added a jar as a maven dependency for a project as system scope.
When I run analyze-only goal on dependency plugin, it does find it. But whenever I want to use classes located in default package in this jar, it won't compile.
I did the same with a jar from same provider with same classes but this time located in one package other than default and it compiles.
Is there something obvious I missed or has someone already encountered the same problem ?
It is not worth posting the code as I just try to import one of the class of system dependency.
My POM (system dependency)
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>edu.algo</groupId>
<artifactId>algorithms</artifactId>
<version>1.0</version>
<properties>
<lib.path>C:/lib</lib.path>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>edu.princeton.cs</groupId>
<artifactId>stdlib</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${lib.path}/stdlib/stdlib.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Sorry to bother you guys and thanks for your help.
I found the answer to my question and it has nothing to do with maven. You just cannot import classes in default package from named package for java versions above 1.4, I was using 1.7 version for compilation.
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4989710
Have you supplied the JAR it's looking for? It sounds like it can't find the JAR against which to compile against.
Have you read this?
http://docs.codehaus.org/display/MAVENUSER/Dependency+Scopes
It states:
system: This dependency is required in some phase of your project's
lifecycle, but is system-specific. Use of this scope is discouraged:
This is considered an "advanced" kind of feature and should only be
used when you truly understand all the ramifications of its use, which
can be extremely hard if not actually impossible to quantify. This
scope by definition renders your build non-portable. It may be
necessarry in certain edge cases. The system scope includes the
element which points to the physical location of this
dependency on the local machine. It is thus used to refer to some
artifact expected to be present on the given local machine an not in a
repository; and whose path may vary machine-to-machine. The systemPath
element can refer to environment variables in its path: ${JAVA_HOME}
for instance.
So, unless you have a solid reason for using this, maybe it's better to deploy the artifact into the repository and reference it like any other artifact?
CI-server (Hudson), for which I am responsible, builds Maven project. After the last commit, the build failed:
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \hudson\jobs\path to my class\MyClass.java:[33,62] package com.sun.xml.internal.messaging.saaj.packaging.mime.util does not exist
[ERROR] \hudson\jobs\path to my class\MyClass.java:[75,5] cannot find symbol
symbol : class BASE64EncoderStream
location: class |fullname of MyClass|
[ERROR] \hudson\jobs\path to my class\MyClass.java:[75,38] cannot find symbol
symbol : class BASE64EncoderStream
location: class |fullname of MyClass|
[INFO] 3 errors
Required class (com.sun.xml.internal.messaging.saaj.packaging.mime.util.BASE64EncoderStream) is situated in rt.jar.
I tried (In accordance with the instructions at http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies) to add system dependency in project's pom.xml:
<dependency>
<groupId>dummy</groupId>
<artifactId>dummy</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
It did not help.
The most interesting is that all files compiled fine on the local machine of my collegue (he use Eclipse build-in compiler).
In internet I found the same question (link: http://maven.40175.n5.nabble.com/Why-can-t-Maven-find-com-sun-xml-internal-messaging-saaj-util-ByteOutputStream-class-td107361.html). The last answer was that the reason for this trouble is Oracle's Java compiler.
So, I changed Oracle's jdk to OpenJDK, but it did not help.
Does someone have any suggestions on how to solve this problem?
Need to specify -XDignore.symbol.file and add rt.jar dependency and <fork>true</fork> as the compiler plugin will otherwise silently drop any -XD flags: e.g.
...
<dependency>
<groupId>groupid</groupId>
<artifactId>artifiactId</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${java.home}/lib/rt.jar</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgs>
<arg>-XDignore.symbol.file</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
...
The missing class seems to be JRE internal (as indicated in its namespace), and should not be referenced from your code. It is probably only available on specific platforms or JRE versions.
Consider replacing it with another Base64 encoder class, e.g. one from the Apache Commmons Codec project.
Java 8 update
Java 8 finally introduced a Base64 class in the public part of the JDK: java.util.Base64.