JMHTest ERROR: Unable to find the resource: /META-INF/BenchmarkList - jmh

use Jmh occur enter image description here
even though i change pom
enter image description here

First of all you should move annotation processor to maven-compiler-plugin:
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</plugin>
Then if you build the project with IDE you should add annotation processor in IntelliJ settings.
Also I'd upgrade the version of JMH from 1.28 to the latest 1.35.

Related

how to config "--enable-preview" when using javafx:jlink in javafx-maven-plugin

I use this plugin in my javafx project: https://github.com/openjfx/javafx-maven-plugin ,
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
...
<launcher>launcher</launcher>
<mainClass>xxx/com.xxx.Main</mainClass>
</configuration>
</plugin>
I use java 14 preview features in my code, and use javafx:jlink command to generate Runtime image, but when I run Runtime image, error:
java.lang.UnsupportedClassVersionError: Preview features are not enabled for com/xxx/Main (class file version 58.65535). Try running with '--enable-preview'.
how to config --enable-preview when using javafx:jlink in javafx-maven-plugin
Change your javafx-maven-plugin's configuration
<configuration>
...
<launcher>launcher</launcher>
<mainClass>xxx/com.xxx.Main</mainClass>
<options>
<option>--enable-preview</option>
</options>
</configuration>
Note : Options are also added to jlink image script

Maven javadoc plugin won't use my stylesheet

I'm trying to run the javadoc:javadoc goal for Maven for my Java 1.7 project. I'd like to specify my customized stylesheet in /src/main/java/stylesheet.css to use when running the goal, but the default javadoc stylesheet is used instead.
I've tried adding the following to my pom.xml file, as the https://maven.apache.org/plugins/maven-javadoc-plugin/examples/stylesheet-configuration.html documentation on the Apache Maven site suggests:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<stylesheetfile>src/main/java/stylesheet.css</stylesheetfile>
</configuration>
</plugin>
</plugins>
</reporting>
But this doesn't get the desired result when I run the maven javadoc:javadoc goal. Any suggestions?
Update: I've tried with
<configuration>
<stylesheetfile>theme-irvine.css</stylesheetfile>
</configuration>
And with
<configuration>
<stylesheetfile>${basedir}/src/main/java/theme-irvine.css</stylesheetfile>
</configuration>
in my pom.xml file, and neither of those worked, either.

Generate feature xml with feature dependencies using maven plugin

I am using the maven-feature-plugin
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>features-maven-plugin</artifactId>
<version>2.3.6</version>
<executions>
<execution>
<id>generate</id>
<phase>generate-resources</phase>
<goals>
<goal>generate-features-xml</goal>
</goals>
<configuration>
<bundles>src/main/resources/bundle.properties</bundles>
<kernelVersion>2.3.6</kernelVersion>
<outputFile>target/features.xml</outputFile>
</configuration>
</execution>
</executions>
</plugin>
This works pretty well but one of my generated features depends on the pax-cdi feature is there a way for me to get the plugin to add this for me? For example I have some dependencies defined in the bundle.properties file that cannot be resolved automatically, could I add a feature in this file as well?
You can add the feature as a maven dependency in your pom:
<dependency>
<groupId>org.ops4j.pax.cdi</groupId>
<artifactId>pax-cdi-features</artifactId>
<version>0.8.0</version>
<classifier>features</classifier>
<type>xml</type>
</dependency>
This will result a feature.xml containing the pax-cdi features (providing that karaf-maven-plugin is configured with <aggregateFeatures>true</aggregateFeatures>).
You can also leave it to the container to pull in the pax-cdi feature. Just edit $KARAF_HOME/etc/org.apache.karaf.features.cfg where you can enlist your pax-cdi-features by adding the maven url to the list of featuresRepositories.
featuresRepositories=....
....,\
mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features
Then add pax-cdi to the list of boot features
featuresBoot=.....,pax-cdi,...
Karaf will start the bundles of pax-cdi when it boots, so that your bundles can find those cdi packages available.
I think that the karaf convention is that the pax-cdi feature should be provided by the container itself, so you don't need to add those bundles to your feature descriptor.
To use pax-cdi feature in karaf enter the following in your Karaf shell
features:addurl mvn:org.ops4j.pax.cdi/pax-cdi-features/0.8.0/xml/features

Getting JNotify into Maven/Archiva

I am currently working on a project that includes using JNotify to monitor when a directory/file has been created, renamed/modified, and deleted. The project is being built in Java 6, not Java 7. JNotify uses JNI to hook into the native OS to monitor the directory/file. My problem is that I need to get JNotify into our repo but I want it to be built so that the java.library.path (DLL) is packaged with the JNI JAR. How would I go about doing that in Maven?
I was able to find the solution I needed using the following maven plugin: http://code.google.com/p/mavennatives/
You must probably upload the jar manually to your archiva instance.
The repository format is fixed, so you will need to perform the rename after retrieving the artifact. That depends how you intend to use it after it is retrieved.
This is a common pattern is something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<stripVersion>true</stripVersion>
</configuration>
<executions>
<execution>
<id>copy-jnotify</id>
<configuration>
<includeArtifactIds>JNotify</includeArtifactIds>
<outputDirectory>${project.build.directory}/my-app</outputDirectory>
</configuration>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
You can use this with the appropriate list of artifacts that will all be copied into the target/my-app directory

NoClassDefFoundError with EJB classloader

I'm getting a "java.lang.NoClassDefFoundError: br/com/company/comum/entity/api/MyEntity" on deploying my .ear. This "MyEntity" is on "ejb-commo"n module and is a interface that JPA entities implement. The module "ejb-testapp" has some JPA entities which implements "MyEntity".
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<configuration>
<version>6</version>
<generateApplicationXml>true</generateApplicationXml>
<defaultJavaBundleDir>lib/</defaultJavaBundleDir>
<modules>
<ejbModule>
<groupId>br.com.company</groupId>
<artifactId>ejb-common</artifactId>
</ejbModule>
<ejbModule>
<groupId>br.com.company</groupId>
<artifactId>ejb-testapp</artifactId>
</ejbModule>
<webModule>
<groupId>br.com.company</groupId>
<artifactId>web-testapp</artifactId>
<contextRoot>/desktop</contextRoot>
</webModule>
</modules>
</configuration>
</plugin>
I've checked the dependencies in the poms and it's all right.
Any suggestions?
If you're talking about in eclipse (m2e-wtp) then try right clicking on the project and doing export -> EAR and see what comes out. I did this and noticed the jars were being output into the root of the EAR (m2e-wtp was effectively ignoring <defaultJavaBundleDir>).
I changed it to use <defaultLibBundleDir> instead (maven have changed the name of the setting to this, but kept defaultJavaBundleDir valid for backwards compatibility) and it worked as expected.

Resources