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
ServiceMix's documentation on creating a custom distribution merely states the steps to creating a custom karaf distribution. I understand that Karaf is the backbone of ServiceMix and ServiceMix is a custom distribution of Karaf.
Has anyone actually built a custom esb on top of servicemix rather than on top of karaf? If so how did you do it?
How did you stage the project with servicemix's src?
Here are some steps that I wish I had when trying to figure this out...
Download the sources for the version of service mix you want to build on: https://github.com/apache/servicemix/releases
Unpack the sources zip into any folder.
Create a project with the following layout:
MyESB
pom.xml
src
main
java
Copy the contents from the pom.xml located in apache-service-mix-x.x.x-src/assembly to your pom.xml
In that pom.xml, replace the artifactId, and name to look something like this:
<parent>
<groupId>org.apache.servicemix</groupId>
<artifactId>parent</artifactId>
<version>5.4.0</version>
</parent>
<groupId>com.mycompany.esb</groupId>
<artifactId>mycustom-esb</artifactId>
<packaging>pom</packaging>
<name>Custom :: ESB</name>
Copy the resource directories of apache-service-mix-x.x.x-src/assembly/src/main to MyESB/src/main.
Make whatever customizations you want to the org.apache.karaf.tooling:features-maven-plugin or the configuratoin files in the resource directories you just copied over.
For example, If you wanted to add a particular feature you could do the following edits to your pom.xml:
Add a features.xml to add-features-to-repo configuration descriptors
Add myfeature to the add-features-to-repo features list
To have that feature started by default, add the feature to the featuresBoot property located here: MyESB\src\main\filtered-resources\etc\org.apache.karaf.features.cfg
Run the maven install target! This will build a zip file into the MyESB/target folder. Now you can unplack that and run servicemix.bat
After starting your ESB, verify that your feature is installed by entering the following command into the Karaf console:
features:list | grep myfeature
Well, just do it like servicemix itself it does. And tbh it's just the way it's described in the Karaf documentation.
For an example you might want to look here
In short define it in your custom assembly POM, take a look at the following snippet:
<plugins>
<plugin>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<version>${karaf.version}</version>
<executions>
<execution>
<id>add-features-to-repo</id>
<phase>compile</phase>
<goals>
<goal>features-add-to-repository</goal>
</goals>
<configuration>
<descriptors>
<descriptor>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.activemq/activemq-karaf/${activemq.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.camel.karaf/apache-camel/${camel.version}/xml/features</descriptor>
<descriptor>mvn:org.apache.cxf.karaf/apache-cxf/${cxf.version}/xml/features</descriptor>
<descriptor>file:${basedir}/target/classes/internal.xml</descriptor>
<descriptor>file:${basedir}/target/classes/features.xml</descriptor>
<descriptor>file:${basedir}/target/classes/examples.xml</descriptor>
</descriptors>
<features>
<feature>cxf</feature>
<feature>obr</feature>
<feature>config</feature>
<feature>standard</feature>
<feature>package</feature>
<feature>kar</feature>
<feature>ssh</feature>
<feature>management</feature>
<feature>eventadmin</feature>
<feature>activemq-broker-noweb</feature>
<feature>activemq-service</feature>
<feature>camel</feature>
<feature>camel-cxf</feature>
<feature>activemq-camel</feature>
<feature>camel-blueprint</feature>
<feature>war</feature>
<feature>jaxrs-api</feature>
</features>
<includeMvnBasedDescriptors>true</includeMvnBasedDescriptors>
<repository>target/features-repo</repository>
</configuration>
<inherited>false</inherited>
</execution>
</executions>
</plugin>
If you need your own custom bundles/features make sure you
a) have a feature descriptor for your own bundles
b) define the feature descriptor
c) tell the plugin to use the corresponding feature
I need to consume a web service in my project. I use NetBeans so I right-clicked on my project and tried to add a new "Web Service Client". Last time I checked, this was the way to create a web service client. But it resulted in an AssertionError, saying:
java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: jar:file:/path/to/glassfish/modules/jaxb-osgi.jar!/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
The default Java platform for NetBeans was JDK8 (Oracle's official version), so when I changed my netbeans.conf file and made JDK7 (from Oracle, as well) as my default, everything worked fine. So I think the problem is with JDK8. Here is my java -version output:
java version "1.8.0"
Java(TM) SE Runtime Environment (build 1.8.0-b132)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b70, mixed mode)
For now, I'm keeping JDK7 as my default Java platform. If there is a way to make JDK8 work please share.
Well, I found the solution. (based on http://docs.oracle.com/javase/7/docs/api/javax/xml/XMLConstants.html#ACCESS_EXTERNAL_SCHEMA)
Create a file named jaxp.properties (if it doesn't exist) under /path/to/jdk1.8.0/jre/lib and then write this line in it:
javax.xml.accessExternalSchema = all
That's all. Enjoy JDK 8.
Not an actual answer but more as a reference.
If you are using the jaxws Maven plugin and you get the same error message, add the mentioned property to the plugin configuration:
...
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<!-- Needed with JAXP 1.5 -->
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
</configuration>
</plugin>
I run ant builds within Eclipse IDE (4.4, Luna, on Windows 7 x64). Rather than modifying the installed JRE lib or any ant scripts (I have multiple projects that include XJC in their builds), I prefer to change Eclipse Settings "External Tools Configurations" and add the following to the VM arguments for the Ant build configuration:
-Djavax.xml.accessExternalSchema=all
The following works for wsimport 2.2.9 included in jdk 1.8.0_66:
wsimport -J-Djavax.xml.accessExternalSchema=all ....
In my case adding:
javax.xml.accessExternalSchema = all
to jaxp.properties didn't work, I've to add:
javax.xml.accessExternalDTD = all
My environment is linux mint 17 and java 8 oracle.
I'll put it there as an answer for people with the same problem.
I tested this for version 2.4 of artifact org.codehaus.mojo and that worked ~
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>path/to/dir/wsdl</wsdlDirectory>
</configuration>
<id>wsimport-web-service</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>${webservices-api-version}</version>
</dependency>
</dependencies>
<configuration>
<vmArgs>
<vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
</vmArgs>
<sourceDestDir>generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<sei>/</sei>
</configuration>
</plugin>
</plugins>
Here is a hint Hint for gradle users without admin rights: add this line to your jaxb-task:
System.setProperty('javax.xml.accessExternalSchema', 'all')
it will look like this:
jaxb {
System.setProperty('javax.xml.accessExternalSchema', 'all')
xsdDir = "${project.name}/xsd"
xjc {
taskClassname = "com.sun.tools.xjc.XJCTask"
args = ["-npa", "-no-header"]
}
}
If you are getting this problem when converting wsdl to jave with the cxf-codegen-plugin, then you can solve it by configuring the plugin to fork and provide the additional "-Djavax.xml.accessExternalSchema=all" JVM option.
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<fork>always</fork>
<additionalJvmArgs>
-Djavax.xml.accessExternalSchema=all
</additionalJvmArgs>
I was also getting similar type of error in Eclipse during testing a webservice program on glassfish 4.0 web server:
java.lang.AssertionError: org.xml.sax.SAXParseException; systemId: bundle://158.0:1/com/sun/tools/xjc/reader/xmlschema/bindinfo/binding.xsd; lineNumber: 52; columnNumber: 88; schema_reference: Failed to read schema document 'xjc.xsd', because 'bundle' access is not allowed due to restriction set by the accessExternalSchema property.
I have added javax.xml.accessExternalSchema = All in jaxp.properties, but doesnot work for me.
However I found a solution here below which work for me:
For GlassFish Server, I need to modify the domain.xml of the GlassFish,
path :<path>/glassfish/domains/domain1 or domain2/config/domain.xml) and add, <jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options>under the <java-config> tag
....
<java-config>
...
<jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options>
</java-config>
...and then restart the GlassFish server
Enabling Access to External Schema
You need to enable the IDE and the GlassFish Server to access external schema to parse the WSDL file of the web service. To enable access you need to modify the configuration files of the IDE and the GlassFish Server. For more details, see the FAQ How to enable parsing of WSDL with an external schema?
Configuring the IDE
To generate a web service client in the IDE from a web service or WSDL file you need to modify the IDE configuration file (netbeans.conf) to add the following switch to netbeans_default_options.
-J-Djavax.xml.accessExternalSchema=all
For more about locating and modifying the netbeans.conf configuration file, see Netbeans Conf FAQ.
Configuring the GlassFish Server
If you are deploying to the GlassFish Server you need to modify the configuration file of the GlassFish Server (domain.xml) to enable the server to access external schemas to parse the wsdl file and generate the test client. To enable access to external schemas, open the GlassFish configuration file (GLASSFISH_INSTALL/glassfish/domains/domain1/config/domain.xml) and add the following JVM option element (in bold). You will need to restart the server for the change to take effect.
</java-config>
...
<jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options>
</java-config>
Create a file named jaxp.properties (if it doesn’t exist) under path to your "JDK version/jre/lib" and then add the following line in it.
javax.xml.accessExternalSchema = all
When using Maven with IntelliJ IDE you can add -Djavax.xml.accessExternalSchema=all to Maven setting under JVM Options for Maven Build Tools Runner configuration
This works on jdk1.8.0_65
wsimport -J-Djavax.xml.accessExternalSchema=all -keep -verbose https://your webservice url?wsdl
For those using the ANT task wsimport, a way of passing the option as suggested by #CMFly and specified in the documentation is the following:
<wsimport
<!-- ... -->
fork="true"
>
<jvmarg value="-Djavax.xml.accessExternalSchema=all"/>
</wsimport>
It is now fixed in 2.5 version (released in jul/17). https://github.com/mojohaus/jaxws-maven-plugin/issues/8.
For the 2.4.x versions there is a workaround (as decribed in https://github.com/mojohaus/jaxws-maven-plugin/issues/4):
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.4.1</version>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.10</version>
</dependency>
</dependencies>
</plugin>
I used it with a regular maven project, and got it solved with this plugin dependency configuration for running the xjc plugin:
<plugin>
<!-- Needed to run the plugin xjc en Java 8 or superior -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<executions>
<execution>
<id>set-additional-system-properties</id>
<goals>
<goal>set-system-properties</goal>
</goals>
</execution>
</executions>
<configuration>
<properties>
<property>
<name>javax.xml.accessExternalSchema</name>
<value>all</value>
</property>
<property>
<name>javax.xml.accessExternalDTD</name>
<value>all</value>
</property>
</properties>
</configuration>
</plugin>
Another solution to address: wiki.netbeans.org
The Web Service Client wizard in the IDE parses the WSDL file when generating a web service client from a web service or WSDL file. You need to modify the IDE configuration file (netbeans.conf) to add the following switch to the netbeans_default_options. You will need to restart the IDE for the change to take effect.
-J-Djavax.xml.accessExternalSchema=all
When deploying to GlassFish you need to enable access to external schema to generate a test client for a web service. To enable access you need to modify the configuration file of the GlassFish Server (GLASSFISH_INSTALL/glassfish/domains/domain1/config/domain.xml) and add the following JVM option element. You will need to restart the server for the change to take effect.
</java-config>
...
<jvm-options>-Djavax.xml.accessExternalSchema=all</jvm-options>
</java-config>
I have just tried that if you use SoapUI (5.4.x) and use Apache CXF tool to generate java code, put javax.xml.accessExternalSchema = all in YOUR_JDK/jre/lib/jaxp.properties file also works.
If you are using ant you can add a jvmarg to your java calls:
<jvmarg value="-Djavax.xml.accessExternalSchema=all" />
Another alternative is to update wsimport.sh shell script by adding the following:
The wsimport.sh is located in this directory:
jaxws-ri.2.2.28/bin
exec "$JAVA" $WSIMPORT_OPTS -Djavax.xml.accessExternalSchema=all -jar "$JAXWS_HOME/lib/jaxws-tools.jar" "$#"
Another reference:
If you are using the maven-jaxb2-plugin, prior to version 0.9.0, you can use the workaround described on this issue, in which this behaviour affected the plugin.
NetBeans update their tutorial for JDK8 and this Issue:
Getting Started with JAX-WS Web Services -> Enabling Access to External Schema
A very simple portable solution would be, to place the following line of code somewhere in a crucial part of your code, a part of which you are sure that it will be run (for example right in the main method):
System.setProperty("javax.xml.accessExternalDTD", "all");
This sets the needed system property programmatically, without having to do tricky maven pom.xml changes (which for some reason didn't work for me).
If you are using Intellij IDEA, in the maven tool window
select Maven Settings and expand the Maven drop down and select Runner.
Under the VM Options add -Djavax.xml.accessExternalSchema=all
Using RAD 9.6 with JDK 1.8 websphere 8.5 runtime on Windows,
editing the xjc.bat as in Generate Java gives "Failed to read external schema..." error didn't work with me, adding/updating the jaxb.properties didn't work as well,
however I edited the wsimport as in below note
you may modify the wsimport.bat file to specify the property directly as one of the jvm arguments like below:-Djavax.xml.accessExternalSchema=all
Our customers reported that the above solution worked for them.
as mentioned in SAXParseException, and it was the solution in my case.
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
I have a simple Jenkins build that pulls down my project from github, builds it and reports the status of the build.
I want to have configure Jenkins to publish the resulting JAR file to a TARGET-SNAPSHOTS branch in my project.
Currently my project .gitignore's /target/*
I was looking at GitPublisher but this appears to push the entire build out, rather than just the jar file.
Thoughts on the best way to do this/if this is possible?
Thanks
I think you have many possibility. One of them is to run post-build script. It can be written is shell.
See Post build task
Simple script:
find . -name "*.jar" -exec scp {} user#myhost.com:/path/for/build/${BUILD_TAG} \;
Other:
Publish Over ... (ssh, ftp, cifs)
Since you're using maven and you said the github downloads section is acceptable, you can use the github downloads plugin - https://github.com/github/maven-plugins. I use this for deploying the Riak java client to our downloads section as part of the build.
In your ~/.m2/settings.xml you need:
<settings>
<profiles>
<profile>
<id>github</id>
<properties>
<github.global.userName>YourGithubUser</github.global.userName>
<github.global.password>YourGithubPass</github.global.password>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
</settings>
Then in your project's .pom something like:
<profile>
<id>githubUpload</id>
<activation>
<property>
<name>github.downloads</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>com.github.github</groupId>
<artifactId>downloads-maven-plugin</artifactId>
<version>0.4</version>
<configuration>
<description>${project.version} release of ${project.name}</description>
<override>false</override>
<includeAttached>true</includeAttached>
</configuration>
<executions>
<execution>
<goals>
<goal>upload</goal>
</goals>
<phase>install</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
(I'm doing it as part of the install phase - you can do however you'd like)
Then simply add -Dgithub.downloads=true to your maven build -
mvn install -Dgithub.downloads=true
The web page for the plugin lists all the options for including/excluding files, etc.