build fail with cxf-codegen-plugin - eclipse

I imported an existing project with modules into eclipse and this is existing code created by a third party that I need to try and understand. But one project keeps failed on mvn clean install and the following error keeps occurring; which seems to be related to a webservice issue:
ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-
plugin:2.7.6:wsdl2java (xxxxxxxxxx) on project
xxxxxxxxxx:
com/sun/tools/xjc/BadCommandLineException:
com.sun.tools.xjc.BadCommandLineException -> [Help 1]
This is user security project that verifies credentials using a webservice.

If you activate "DEBUG"-mode for Maven and "Print exception stack traces", and the error is a NoClassDefFoundError for the BadCommandLineException, then I solved it by providing a dependency to the cxf-codegen-plugin:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
...
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.4.0-b180725.0644</version>
</dependency>
</dependencies>
</plugin>

Related

org.osgi import cannot be resolved

I am trying to get started with OSGI and create a basic bundle.
I created a bundle with activator in Eclipse (2019-06) and selected Liberty as the target runtime (the end goal is to create a Liberty extension)
It works fine, but when I convert it to Maven, Eclipse complains the org.osgi package cannot be resolved
I see this dependency is defined:
<dependency>
<groupId>net.wasdev.maven.tools.targets</groupId>
<artifactId>liberty-target</artifactId>
<version>19.0.0.9</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
I tried adding this to the felix plugin with no luck.
<Import-Package>
org.osgi.framework
</Import-Package>
After trying thing for a while I am ready to give up. Any help would be appreciated.
Add these maven dependencies for the OSGi specs.
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>6.0.0</version>
<scope>provided</scope>
</dependency>
You also have to configure the bnd-maven-plugin. So your imports are computed automatically. Alternatively you can use the maven-bundle-plugin. (You might already use this).
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>4.2.0</version>
<executions>
<execution>
<goals>
<goal>bnd-process</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
This covers the compile time resolution of your packages.
In addition you need to provide the correct bundles at runtime. This highly depends on how you define your runtime.
Some org.osgi package come from the OSGi framework itself. Others have to be installed as bundles. Be aware that you normally do not install the specs as bundles. Instead you install implementations that also bring the specs.

Exclude Maven Dependency during Eclipse Application Runtime

When I try to run a Java Application on Eclipse, a conflict between two dependencies is causing the application to fail.
I am trying to upgrade my project Java version from OracleJDK 8 to OpenJDK 11. As a result, I also had to also needed to update a GWT dependency from 2.6.0 to 2.8.2, as well as switch from MOJO gwt-maven-plugin to the tboyer version as well. Additionally, the build is done on Maven 4.0.0 on Eclipse IDE 4.9.0.
Snippet of the pom.xml
<properties>
<gwt.version>2.8.2</gwt.version>
...
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>${gwt.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
...
<build>
<plugins>
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-10</version>
<executions>
<execution>
<id>compile-common</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
<execution>
<id>XXXX</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
<execution>
<id>XXXX</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
<execution>
<id>XXXX</id>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
<configuration>
<moduleName>XXXXModule</moduleName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
So when I run the application on Eclipse, I get the following error:
SEVERE: Application encountered an exception during Start.
XXXX.ApplicationException: Failed to reflect on start method.
at XXXX.ApplicationLauncher.startApplication(ApplicationLauncher.java:471)
at XXXX.ApplicationLauncher.doRun(ApplicationLauncher.java:185)
at XXXX.ApplicationLauncher.main(ApplicationLauncher.java:67)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at XXXX.ApplicationLauncher.startApplication(ApplicationLauncher.java:469)
... 2 more
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.ExceptionUtils.preload()V
at org.apache.catalina.startup.Tomcat.<init>(Tomcat.java:181)
....
After investigating, I discovered that two of my dependencies tomcat-embed-core-7.0.91 & apache-jsp-8.0.9.M3 both contain ExceptionUtils with several difference, hence the Exception. Furthermore, the apache-jsp is being pulled by the gwt-dev dependency which is only required during the Maven build to run the gwt-maven-plugin.
gwt-dev:2.8.2
apache-jsp:9.2.14.v20151106
apache-jsp:8.0.9.M3
But for some reason, Eclipse is including gwt-dev and it's dependency as part of the runtime path even though I have the 'provided' scope tag in the pom.xml.
I have tried excluding the apache-jsp dependency, but a compile issue occurs because apparently gwt-dev is still being added which depends on apache-jsp.
Summary
The TBroyer GWT-Maven-Plugin requires the pom file to include gwt-dev as a dependency in order to run correctly during a build.
However, when running the application on Eclipse, a NoSuchMethodException occurs on org.apache.tomcat.util.ExceptionUtils.preload()V
The issue is there are two ExceptionUtil classes with same package from different jars and methods.
One of the jars is apache-jsp which is a dependency of gwt-dev. Gwt-dev and it's dependencies should not be part of the runtime classpath.
Question: Is there a way to ensure the gwt-dev is only used during the Maven build and not part of the Eclipse Java Application runtime classpath?
Yes, you can ensure isolated classpath for client and server sides. You need to apply the multimodule layout. This is also the main difference between the old MOJO gwt maven plugin and the new generation tbroyer gwt maven plugin, the new one support multimodule correctly. Check this archetype as a reference for the multimodule layout. Also, use the packaging:gwt-app to configure the gwt maven plugin executions automatically.
Making it work with eclipse run action (tomcat or gwt) is a bit more difficult. Until you correctly apply the tbroyer gwt maven plugin and the multimodule layout, you will be able to use mvn tomcat7:run and mvn gwt:codeserver in the terminal. Then, the recommended strategy to use it in your IDE is to configure this maven goal and run it using the maven tooling of your IDE. This makes it work exactly the same in all your environments (terminal, CI, eclipse, intellij, etc).

Why does executing Structured Streaming application fail with "Failed to find data source: kafka"? [duplicate]

This question already has answers here:
Why does format("kafka") fail with "Failed to find data source: kafka." (even with uber-jar)?
(8 answers)
Closed 4 years ago.
I am trying to connect Spark Structured Streaming with kafka and it throws the below error:
Exception in thread "main" java.lang.ClassNotFoundException: Failed to find data source: kafka. Please find packages at ...
Based on the documentation I have added the required dependencies
and my kafka and zookeeper servers are running.
Not sure what the issue is.
Also, I am using it this way
import spark.implicits._
val feedback =spark.readStream.format("kafka").option("kafka.bootstrap.servers", "localhost:2181").option("subscribe", "kafka_input_topic")
.load().as[InputMessage].filter(_.lang.equals("en"))
Any help is appreciated. Thank you
The problem, as you mentioned in your comments, is this:
<scope>provided</scope>
Remove the provided scope for sql-kafka, as it is not provided by the Spark installation.
you could use the kafka data source by the fully-qualified name (not the alias) as follows:
spark.readStream.format("org.apache.spark.sql.kafka010.KafkaSourceProvider").load
The issue is that the necessary jar is not included in CLASSPATH at runtime (not build time).
Based on the documentation you linked to you added the required dependencies to your build definition file (pom.xml or build.sbt or build.gradle), but the exception happens while you try to run the application which is after it is built, doesn't it?
What you miss is that part of the documentation about deployment, i.e. Deploying:
As with any Spark applications, spark-submit is used to launch your application. spark-sql-kafka-0-10_2.11 and its dependencies can be directly added to spark-submit using --packages, such as,
./bin/spark-submit --packages org.apache.spark:spark-sql-kafka-0-10_2.11:2.2.0 ..
You have to add this --packages or you'd have to create an uber-jar that would make the dependency part of your jar file.
If using maven then the following way of building jar with dependencies might solve your issue.
Add the spark dependencies like below:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.2.1</version>
<scope>${spark.scope}</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql-kafka-0-10_2.11</artifactId>
<version>2.2.1</version>
</dependency>
Then configure your maven profiles as below:
<profiles>
<profile>
<id>default</id>
<properties>
<profile.id>dev</profile.id>
<spark.scope>compile</spark.scope>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<profile.id>test</profile.id>
<spark.scope>provided</spark.scope>
</properties>
</profile>
<profile>
<id>online</id>
<properties>
<profile.id>online</profile.id>
<spark.scope>provided</spark.scope>
</properties>
</profile>
</profiles>
Add the followign plugin:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Then buld your jar using mvn clean install -Ponline -DskipTests. This should solve your issue

Import soapui tests to eclipse

How do I take imported SoapUI project and tie it to my current Maven Eclipse project, and be able to see this SoapUI project when I am in the Java Perspective view?
I have a SoapUI project that I would like to import into my Eclipse Maven project.
I can import this SoapUI project to eclipse when I go to the soapUI Perspective view and do a 'Import Project.' This works great.
I want to have my maven plugin to execute the projects/testCases/testSuites in my current soapUI project file.
It is probably simple, I am just not seeing how to make this final connection between the soapUI and eclipse projects to run all projects and get reports.
enter link description hereYou are probably looking for maven-soapui-plugin - configure it in your pom.xml build - block:
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<executions>
<execution>
<id>soap-integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<projectFile>${basedir}/target/path/to/your/soapUIprojectFile.xml</projectFile>
<!-- move reports directly to surefire-reports-->
<outputFolder>${basedir}/target/surefire-reports</outputFolder>
<junitReport>true</junitReport>
<printReport>true</printReport>
<!--move soapui-logs into target dir-->
<soapuiProperties>
<property>
<name>soapui.logroot</name>
<value>${project.build.directory}/soapui/logs/${soapui.testsuite.version}/</value>
</property>
</soapuiProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.junit_version}</version>
<scope>runtime</scope>
</dependency>
...
</dependencies>
</plugin>
Look for more info here

The maven project generated by gwt-maven-plugin can't be imported into eclipse via import existing maven project

I firstly generated a gwt maven project by executing --
mvn archetype:generate -DarchetypeGroupId=org.codehaus.mojo
-DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.7.0
After that, the pom.xml is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.boye.games</groupId>
<artifactId>games-gwt</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GWT Maven Archetype</name>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt</artifactId>
<version>${gwtVersion}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<!-- Output classes directly into the webapp, so that IDEs and "mvn process-classes" update them in DevMode -->
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
<plugins>
<!-- GWT Maven Plugin -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<!-- Plugin configuration. There are many available options, see
gwt-maven-plugin documentation at codehaus.org -->
<configuration>
<runTarget>LineThree.html</runTarget>
<modules>
<module>com.boye.games.linethree.LineThree</module>
</modules>
</configuration>
</plugin>
</plugins>
</build>
</project>
Then I imported this project into eclipse via built-in eclipse function -- import existing Maven project.
However, the process failed due to several reasons:
GreetingServiceAsync cannot be resolved to a type
Execution default of goal org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync failed:
Plugin org.codehaus.mojo:gwt-maven-plugin:2.7.0 or one of its
dependencies could not be resolved: Failed to collect dependencies for
org.codehaus.mojo:gwt-maven-plugin:jar:2.7.0 ()
(org.codehaus.mojo:gwt-maven-plugin:2.7.0:generateAsync:default:generate-sources)
google plugin can't identify this project as gwt web application automatically.
My environment as follows:
java version 1.7.0_03
eclipse version Kepler Service Release 2
gwt version 2.7.0
Please advice, thanks a lot!
I did another attempt to try in a win32 computer, the problem re-appeared even if I set up the environment as aforementioned working in my win64 computer.
So I really got confused, like Klarki said, I have to do some tweaks to get it work. I generated GreetingServiceAsync via mvn gwt:generateAsync then manually copy GreetingServiceAsync to source folder, then I remove <goal>generateAsync</goal> in pom.xml, then import project via eclipse's existing maven project. It works again!
Sadly see it not working intelligently.
The problem was with generateAsync, which in your case generates GreetingServiceAsync on execution. Eclipse probably wasn't configured to handle it properly and this class was not generated and eclipse reported the missing class warning.
Another thing that could be done to get the project to work was to run mvn package from command line and add the generated dir in target dir as source dir in eclipse (vie right clicking the project and selecting New -> source folder > browsing folder name > target > generated-sources > the right folder)
Also you may run into same issue after you do mvn clean - the generated GreetingServiceAsync will be deleted and the problem may come back.
The problem exists because eclipse isn't tightly integrated with maven and uses its own build system ignoring maven targets that you don't have plugins for. What you could do is to open eclipse preferences > maven > lifecycle mappings and there you can enable generateAsync to execute.
If you copy the generated class manually you have to keep in mind that you need to update it when needed, where as it is intended to generate automatically. So you loose this convenience.
This work for me:
I deleted the local maven gwt repository, in windows 7 it's in C:\Users\.m2\repository\com\google\gwt, and then make a
mvn clean complile
so maven re-import al dependencys.
After I changed my environment as follows:
java version "1.8.0_05"
eclipse Version: Luna Release (4.4.0)
Google plugin for Eclipse 4.4
I works like a charm.
Probably, it's a version incompatibility issue.