Apache CXF wadl2java could not find main class WADLToJava - cxf

I need to convert wadl to java pojo, for that i have downloaded apache cxf 3.0.1 version. But when i run wadl2java bat file in my command prompt, i am getting following exception
D:\software\apache-cxf-3.0.1\bin>wadl2java -h
Error: Could not find or load main class org.apache.cxf.tools.wadlto.WADLToJava
Here this script file is looking for WADLToJava class. i have downloaded the apache cxf source distribution, i can see that wadl2java class is there. Please suggest me how i can use apache cxf to generate java files from wadl url.

You need to set CFX_HOME and CLASSPATH environments variables.
CXF_HOME should be your installation dir, in your example;
CXF_HOME=D:\software\apache-cxf-3.0.1\
CLASSPATH is variable used for setting java classpath for wadl2java script, in your windows example;
CLASSPATH=.;%CXF_HOME%\lib\*

Related

Concordion Unable to find specification

java.lang.RuntimeException: Unable to find specification: com/concordion/Concordion.html
I'm using Concordion 2.2.0 with Junit 5 jupiter using the Junit 4 vintage engine and a TFS build agent using maven. The maven surefire picks up the Concordion java file but simply can't find the corresponding Concordion html and so the auto-tests fail.
The html specification file is in the resources directory but it doesn't matter where I put it, the surefire / concordion libraries can't find it!
The specification files need to be on the classpath in the same package as the Java class. Typically this is under the src/test/resources folder. See https://concordion.org/coding/java/markdown/#locating-the-specification for more details.
Are you able to provide a simplified test case showing the issue?
Moving the specifications to the same location as the java files (src/test/java or src/main/java) should get it working in the short term.

Integrate Saxon-PE in Camel using camel-saxon

I use Camel 2.22.1 with springboot 2.0.4.RELEASE. The camel component camel-saxon use default Saxon-HE. I have some Xquery files, which call Java method, so I want to replace Saxon-HE with Saxon-PE. I requested one test license for Saxon-PE and tried different ways and didn't get it work. The Saxon-PE jar file saxon9pe.jar is already loaded, however, it is still working as Saxon HE edition. I guess, the license is not correctly loaded by Saxon-PE.
I tried following ways, none of them has worked.
put license file saxon-license.lic and saxon9pe.jar in the same folder
define an environment variable SAXON_HOME, and put saxon-license.lic and saxonpe.jar in SAXON_HOME\bin
modify org.apache.camel.component.xquery.XQueryBuilder.configuration in class XqueryBuild.java in package org.apache.camel.component.xquery to set LICENSE_FILE_LOCATION ( I got Error: Unknown configuration property http://saxon.sf.net/feature/licenseFileLocation)
The Saxon Documentation mentioned to create an XML configuration file, but I don't know where should I put this XML configuration file.
When running an Xquery with Java call I got the error:
Caused by: net.sf.saxon.trans.XPathException: Cannot find a 0-argument function named Q{java:java.lang.Double}MAX_VALUE(). Reflexive calls to Java methods are not available under Saxon-HE at net.sf.saxon.query.UnboundFunctionLibrary.bindUnboundFunctionReferences(UnboundFunctionLibrary.java:166) ~[saxon9pe.jar!/:na]
at net.sf.saxon.query.QueryModule.bindUnboundFunctionCalls(QueryModule.java:1172) ~[saxon9pe.jar!/:na]
at net.sf.saxon.expr.instruct.Executable.fixupQueryModules(Executable.java:462) ~[saxon9pe.jar!/:na]
at net.sf.saxon.query.XQueryParser.makeXQueryExpression(XQueryParser.java:176) ~[saxon9pe.jar!/:na]
at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:597) ~[saxon9pe.jar!/:na]
at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:658) ~[saxon9pe.jar!/:na]
at org.apache.camel.component.xquery.XQueryBuilder$3.createQueryExpression(XQueryBuilder.java:276) ~[classes!/:2.23.1]
at org.apache.camel.component.xquery.XQueryBuilder.initialize(XQueryBuilder.java:745) ~[classes!/:2.23.1]
at org.apache.camel.component.xquery.XQueryBuilder.evaluateAsDOM(XQueryBuilder.java:190) ~[classes!/:2.23.1]
at org.apache.camel.component.xquery.XQueryBuilder.evaluate(XQueryBuilder.java:151) ~[classes!/:2.23.1]
... 40 common frames omitted
Can some share some experience with setting up Saxon-PE with camel to get calling Java working within Xquery?
Thanks!
From the extra information supplied, it looks as if you're picking up the Saxon JAR file but not the license file.
Putting the license file in the same folder as the JAR file is often enough, but it only works with some classloaders.
In general you either need to ensure that the directory containing the JAR file is on the classpath, or you need to (somehow) set Saxon's configuration property LICENSE_FILE_LOCATION.
According to https://github.com/apache/camel/blob/master/components/camel-saxon/src/main/docs/xquery-component.adoc, you can set Saxon configuration properties using configuration and configurationProperties, but I don't see any further explanation of how this works. I'll have a dig around.

Running Solr with Jetty

I'm having a little trouble understanding how Solr fits in with Jetty, and why I can't seem to get the start.jar in the distribution package to work.
I can run all of the example configurations via java -jar start.jar. However, when I try to run something like the follwing --
java -Dsolr.solr.home=/Users/jwwest/solr -jar $(brew --prefix solr)/libexec/example/start.jar
-- the following error occurs:
java.io.FileNotFoundException: No XML configuration files specified in start.config or command line.
at org.eclipse.jetty.start.Main.start(Main.java:506)
at org.eclipse.jetty.start.Main.main(Main.java:95)
I opened up the start.jar file, and there is a start.config file located inside of the jar which I'm assuming should handle this configuration for me. I'm not understanding why it will work when run from inside of the distribution examples directory, but not outside of it.
You also need to define the jetty.home property. Try:
java -Dsolr.solr.home=/Users/jwwest/solr -jar $(brew --prefix solr)/libexec/example/start.jar -Djetty.home=$(brew --prefix solr)/libexec/example
You can see the effective command line start.jar generates by using the --dry-run command line flag.
java -jar start.jar --dry-run
That will output everything with full path names so you can run it from outside the directory.
Source: http://www.eclipse.org/jetty/documentation/9.0.0.M3/advanced-jetty-start.html
The start.jar is a jetty specific mechanism that works to build out all the classpath requirements for starting up Jetty. It is generally only used in the scope of the jetty distribution. Pulling the start.jar out of the configuration and placing it somewhere else renders the default configuration of the start.config rather moot.
My understanding of Solr is that it bundles itself with a distribution of jetty, placing what it needs to run into the distribution and repackages it as its own. They may have a custom start.config file that further adds its own locations for classpath resources and the like, or not.
The exception you are seeings stems from the start.config file expecting an etc/ directory containing jetty.xml formatted xml files which are used to configure the jetty process.
Jetty being often used in an embedded format has little to do with this issue, it is simply a common use case because jetty is incredibly easy to embed into an application. Embedded instances of jetty rarely (if ever) leverage a start.jar...instead it is up to the embedding application to manage its own classpath.
First, you need to change your folder where start.jar is located, then execute the same command.
Jetty is often used as embedded container. If you want to use the jetty, then a good start would be to copy the example directory and rename it to what you want it to be. The solr directory is the one for basic configuration.
Else it is recommended to use tomcat and the solr.war file.

Using JSVC to daemonize a Java app packaged with the Maven One-Jar Plugin

Here is the problem:
I have packaged my Java application into a single jar using the Maven plugin One-Jar.
Now I want to run the application as a Unix Daemon using JSVC, i.e. Apache Commons Daemon.
I am using JSVC as follows (which works for Jars made with the Maven assembly plugin, etc):
jsvc -user $USER -home $HOME -pidfile $PID_PATH -cp $PATH_TO_ONE_JAR my.package.MyClass
The error is this:
jsvc.exec error: Cannot find daemon loader org/apache/commons/daemon/support/DaemonLoader
jsvc.exec error: Service exit with a return value of 1
Does anyone know if it is even possible to use JSVC and One-Jar together, since One-Jar uses a custom class loader? The jar runs just fine when I run java -jar my-one-jar.jar.
What can be done?
Thank you for any insight!
I had to add all jars dependencies to the classpath option from jsvc. It seems jsvc doesn't use the jars inside another jar
If you use the (poorly-documented) Maven Shade Plugin instead of One-jar (they can achieve similar results as each other), it should solve your problems. It unpacks the dependent jars and stores the class files directly in the fat Jar (rather than having jars within the jar). I have used it to create an executable jar for running under JSVC with some success.
Of course, things are seldom as simple as they sound. With the Shade plugin, you may have to do some work to relocate classes when there are conflicts in your dependency tree, or use resource transformers to handle your non-Java resource files. But hopefully not.
(Of course Mkyong.com has a guide on this)

apache-cxf client works with exec-maven-plugin, but not from outside

I am having problems triying to create a WS client in java.
The libraries I'm using is apache-cxf 2.12. This is an old version but I want the web service to be added to a JBoss application that is already running and uses Spring 2.5.6, so this org.apache.cxf version uses same spring version.
But the question is (I know is quite generic, is related to maven, netbeans and apache-cxf)
When I execute my client project (maven proyect) from netbeans, it works sort of Ok.
When I try to run this class with a script (bot windows an linux) it gives me this error:
"Invocation failed with the following: org.apache.cxf.ws.policy.PolicyException: None of the policy alternatives can be satisfied."
Java versions are the same, I've copied all the dependency jar into lib dir and added then to %classpath%
So, what can be different that when I execute my sample program with maven org.codehaus.mojo:exec-maven-plugin:1.2.1:exec it works and it doesn't when I run it with a srcipt? (I have checked all dependencies, java version, ... )
I guess it has to be related to JAX-WS o JCE (Java Cryptography Architecture) initialization.
¿Is there a way to see what %classpath maven is creating when in runs java.exe?
Maven script that works:
JAVA_HOME=D:\\LOCAL\\Java\\jdk1.5.0_15
D:\\LOCAL\\apache-maven-2.0.9\\bin\\mvn.bat
-Dexec.classpathScope=runtime
-DskipTests=true
"-Dexec.args=-Djavax.net.debug=all -classpath %classpath es.webservice.aaTest TESTFILE"
-Dexec.executable=D:\\LOCAL\\Java\\jdk1.5.0_15\\bin\\java.exe
-Dmaven.repo.local=D:\\bsrepo\\.m2 process-classes
org.codehaus.mojo:exec-maven-plugin:1.2:exec
Thanks

Resources