How to specify the platform when generating POMs with Tycho? - maven

My company has been building their Eclipse RCP Application with Ant as a PDE-build. I'm trying to migrate the build process to Tycho but I am getting several errors of the same kind. I only want to build for Windows 64-bit but Tycho keeps looking for Cocoa plugins, which are marked as optional in the features.
How can I tell Tycho not to bother about anything that is not related to Windows 64 bit?
The manifest files do already exist, and I tried to generate the POMs with:
mvn org.eclipse.tycho:maven-tycho-plugin:generate-poms -Dtycho.targetPlatform=<path to target> -DgroupId=myGroupId
The error I get is:
[ERROR] Internal error: java.lang.RuntimeException: Could not resolve plugin org.eclipse.e4.ui.workbench.renderers.swt.cocoa_0.11.0.v20120716-173435;
I'm using Java 1.7.0_11, Maven 3.1.0, and Tycho 0.18.1.

I think you just need to set the platform in the target-platform-configuration plugin configuration as follows:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version>
<configuration>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
</configuration>
</plugin>

Related

What Build Module in IntelliJ actually does for maven module

When I run
mvn clean install
for my maven module then it compiles fine. No issues.
But when I open my pom.xml file in IntelliJ and I choose to Build -> Build module then I get following issues:
Information:javac 1.8.0_144 was used to compile java sources
Information:Module "mymodule" was fully rebuilt due to project configuration/dependencies changes
Information:09.10.2017 21:16 - Compilation completed with 3 errors and 3 warnings in 23s 991ms
C:\somepath\mymodule\pom.xml
Error:Error:osgi: [mymodule] Exception: java.lang.ClassNotFoundException: org.apache.sling.bnd.models.ModelsScannerPlugin not found, parent: java.net.URLClassLoader#29453f44 urls:[] exception:java.lang.ClassNotFoundException: org.apache.sling.bnd.models.ModelsScannerPlugin
Error:Error:osgi: [mymodule] Failed to load plugin org.apache.sling.bnd.models.ModelsScannerPlugin;generatePackagesHeader=true, error: java.lang.ClassNotFoundException: org.apache.sling.bnd.models.ModelsScannerPlugin not found, parent: java.net.URLClassLoader#29453f44 urls:[] exception:java.lang.ClassNotFoundException: org.apache.sling.bnd.models.ModelsScannerPlugin
Error:Error:osgi: [mymodule] Cannot load the plugin org.apache.sling.bnd.models.ModelsScannerPlugin
This is a module with AEM code and it uses maven-sling-plugin. It works fine for other developers in the project. Because it's working when executed directly from maven I'm trying to understand what IntelliJ does in the background. But actually, my problem is those compilation issues.
From what I've found IntelliJ does not call maven when Build is done. Any ideas how can I find differences between running from IntelliJ and directly from Maven?
What happens here is that the ModelScanner plugin can't be found using the current ClassLoader. The reason for this can be that you are using IntelliJ IDEA Ultimate which comes with a OSGI plugin already pre-installed called 'Osmorc'. If this OSGI plugin is active it will determine the classloader to be used for building OSGI related projects.
So simply de-activating this Osmorc plugin in IntelliJ should allow your build to revert to the classloader from the ModelScannerPlugin mentioned in the configuration of your the maven-bundle-plugin in your projects POM.xml file which should solve the problem.
If this still results in a similar Maven build error, then make sure to add a Maven dependency 'org.apache.sling.bnd.model' to your maven-bundle-plugin in your POM.xml file.
<!-- Apache Felix Bundle Plugin -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
<inherited>true</inherited>
<extensions>true</extensions>
<executions>
<!-- Configure extra execution of 'manifest' in process-classes phase to make sure SCR metadata is generated before unit test runs -->
<execution>
<id>scr-metadata</id>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<supportIncrementalBuild>true</supportIncrementalBuild>
</configuration>
</execution>
</executions>
<configuration>
<exportScr>true</exportScr>
<instructions>
<!-- Enable processing of OSGI DS component annotations -->
<_dsannotations>*</_dsannotations>
<!-- Enable processing of OSGI metatype annotations -->
<_metatypeannotations>*</_metatypeannotations>
<_plugin>org.apache.sling.bnd.models.ModelsScannerPlugin;generatePackagesHeader=true</_plugin>
</instructions>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.bnd.models</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</plugin>
could you please check your core pom file. it should contain a plugin section like this:
<plugin> <!-- Enable registration of Sling Models classes via bnd plugin --> org.apache.sling.bnd.models.ModelsScannerPlugin, <!-- Allow the processing of SCR annotations via a bnd plugin --> org.apache.felix.scrplugin.bnd.SCRDescriptorBndPlugin;destdir=${project.build.outputDirectory} </plugin>
but if you created a project using aem archetype the tag looks like' <_plugin>

Create an EAR using Maven

I want to create an EAR using Maven, but since I'm in a pure Tycho world, I can't use the maven-ear-plugin, just the maven-assembly-plugin (which is fine).
There are multiple questions even on this very site that indicate that the maven-assembly-plugin can build EARs, even though the documentation says no.
However, when I use define the EAR format like this:
<formats>
<format>ear</format>
</formats>
I get the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:3.0:single (make-assembly) on project org.acme.application: Failed to create assembly: Error creating assembly archive default: appxml attribute is required -> [Help 1]
(I tried a couple of versions for the maven-assembly-plugin, so it's not that.)
Since a EAR is just a renamed JAR, I'm now using the JAR format and this other Maven plug-in:
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>rename-ear</id>
<phase>verify</phase>
<goals>
<goal>rename</goal>
</goals>
<configuration>
<sourceFile>${basedir}/target/${earName}.jar</sourceFile>
<destinationFile>${basedir}/target/${earName}.ear</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
Which works nicely in creating an EAR, however with mvn install it brings the following exception:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.5.2:install (default-install) on project org.acme.application: Failed to install artifact group:org.acme.application:jar:1.9.126-SNAPSHOT: C:\workspace\Application\target\Application.jar (Das System kann die angegebene Datei nicht finden) -> [Help 1]
(It's German for "Cannot find file", one day I'll get him to print out readable error messages.)
Of course, now I could copy the JAR to an EAR instead of just renaming it, but I thought I get a 2nd oppinion first: Is it possible to create an EAR with the maven-assembly-plugin? If so, how?

ERROR [WsdlTestCase] Failed to create test step for [X]

I get this error ERROR [WsdlTestCase] Failed to create test step for [X] when executing my soapui project from Maven.
Tests work fine from the SOAPUI client software. My Soap-ui.error log is empty.
There doesn't seem to be enough information to let me debug this - I'm guessing there's some dependency I'm missing, but my tests are fairly simple (REST requests with a few assertions on the HTTP response). I assumed the core maven plugin would suffice.
My maven config is as below (I've also included the eviware repository -http://www.eviware.com/repository/maven2/)
<plugin>
<groupId>eviware</groupId>
<artifactId>maven-soapui-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<phase>integration-test</phase>
<id>soapui-tests</id>
<configuration>
<projectFile>${basedir}/src/test/resources/MyTestSuite.xml</projectFile>
<outputFolder>${basedir}/target/soapui</outputFolder>
<junitReport>true</junitReport>
<exportwAll>true</exportwAll>
<printReport>true</printReport>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
the preceeding messages are :
[DefaultSoapUICore] Missing folder [/var/lib/jenkins/jobs/Build-Mule-Configuration/workspace/ext] for external libraries 2015-07-01 15:10:48,961 INFO
[DefaultSoapUICore] Creating new settings at [/var/lib/jenkins/jobs/Build-Mule-Configuration/workspace/soapui-settings.xml]
I've moved up to the 4.6.1 version of the soapui plugin as detailed here
(http://www.soapui.org/test-automation/maven/maven-2-x.html), the tests are now at least attempting to execute. As I understand it the version I've outlined above should work but perhaps it doesn't recognise the current SOAP UI project syntax.
As an aside the 4.6.1 version of the plugin seems to have a much larger number of dependancies and for me is causing memory issues.

Got NoClassDefFoundError when invoking Axis2 webservice deployed with maven in weblogic

I'm trying to deploy axis2 webservices in weblogic server using maven. The project has maven modules and one of that is a war that i have defined the axis servlet in. The wsdl was there, so i used wsdl2code plugin to generate the xmlbean and schema and put that in a jar module. Structure is as below.
--lv-ear (ear with dependency on war)
|
--lv-ws
|
--lv-ws-ccid (jar module with skeleton and xmlbeans)
|
--lv-ws-ecs (jar module with skeleton and xmlbeans)
|
--lv-ws-web (war module with dep on jar modules)
|
--WEB-INF
|
--conf/axis2.xml
--services/ccid/services.xml
I built and deployed the ear to weblogic domain. The war was deployed successfully as part of ear and services were deployed. I am able to access wsdl files. When I tried to call the service, i got the below ClassNotFoundException for a schema file.
Caused by: java.lang.ClassNotFoundException: schemaorg_apache_xmlbeans.system.s2104B1E6E09A2A85656B3E630BA151C1.TypeSystemHolder
I saw that the random string in that path differed fo me. So I tried to call again and got below NoClassDefFoundError, which persists even after I tried with different approaches.
java.lang.NoClassDefFoundError: Could not initialize class com.lv.ws.ccid.xmlbean.InputDocument
at com.lv.ws.ccid.xmlbean.InputDocument$Factory.parse(InputDocument.java:463)
at com.lv.ws.ccid.CcidMessageReceiverInOut.fromOM(CcidMessageReceiverInOut.java:332)
at com.lv.ws.ccid.CcidMessageReceiverInOut.invokeBusinessLogic(CcidMessageReceiverInOut.java:46)
at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:114)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:173)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:173)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:144)
I searched for this and found something that told to configure app server for axis2 based on http://axis.apache.org/axis2/java/core/docs/app_server.html . When I tried it I got below error.
weblogic.xml.stax.XmlStreamInputFactory can not be cast to javax.xml.stream.XmlInputFactory
After discarding that configuration, I did some other possible deployments by having the webservice skeleton and xmlbean files in an aar and put the aar inside WEB-INF/services. I also tried putting Class-Path entry in MANIFEST.MF in ear / war for the jar files, to no avail. Still I got the same NoClassDefFoundError. Can you please give me suggestions on fixing that?
Fixed it now. This was due to my lack of experience with Axis. Issue was that, I had the generated schema and xmlbean files moved to src folder and then just tried to use normal jar function and dependency to deploy.
Now, I removed them from src folder and use wsdl2code and axis2-aar plugins to generate the xmlbean and schema files dynamically and then package them in aar. Then I deployed the aar to webapp and it worked fine. I have listed the plugin configuration inside <build> below.
<plugins>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-wsdl2code-maven-plugin</artifactId>
<version>1.5.4</version>
<executions>
<execution>
<id>ccid-ws</id>
<goals>
<goal>wsdl2code</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.lv.ws.ccid</packageName>
<wsdlFile>${basedir}/src/main/resources/META-INF/ccid.wsdl</wsdlFile>
<databindingName>xmlbeans</databindingName>
<syncMode>sync</syncMode>
<unpackClasses>true</unpackClasses>
<namespaceToPackages>https://mdm.com/portal/ws/services/ccid=com.lv.ws.ccid.xmlbean</namespaceToPackages>
<outputDirectory>${basedir}/target/generated-sources</outputDirectory> <generateServerSide>false</generateServerSide>
<generateServicesXml>true</generateServicesXml>
<skipWSDL>true</skipWSDL>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-aar-maven-plugin</artifactId>
<version>1.6.2</version>
<extensions>true</extensions>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>aar</goal>
</goals>
</execution>
</executions>
<configuration>
<aarName>ccid</aarName>
<includeDependencies>false</includeDependencies>
<outputDirectory>${project.build.directory}/aar</outputDirectory>
</configuration>
</plugin>
</plugins>

Howto use Maven Cargo Plugin to deploy a Web Application Bundle (WAB, OSGI + JavaEE) into Glassfish 3.x

I'm trying to use the Maven Cargo Plugin to deploy a set of OSGI bundles and an hybrid application .war (Webapplication with Restservice which uses OSGI) also called a Web Application Bundle (or WAB) (e.g. see https://glassfish.java.net/public/GF-OSGi-Features.pdf).
Deploying of OSGI bundles into a Glassfish 3.1.x works fine, but I haven't found a way to deploy the Web Application Bundle.
It's packaging is "war", but I have to deploy it as OSGI bundle. So how can I tell this the Cargo Plugin?
The maven configuration I tried to use:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<wait>false</wait>
<container>
<containerId>glassfish3x</containerId>
<home>${glassfish.home}</home>
<type>installed</type>
</container>
<configuration>
<type>existing</type>
<home>${glassfish.home}</home>
<properties>
<cargo.hostname>localhost</cargo.hostname>
<cargo.rmi.port>4848</cargo.rmi.port>
<cargo.domain.name>${glassfish.domain}</cargo.domain.name>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>com.acme.rest</groupId>
<artifactId>rest-api</artifactId>
<type>bundle</type>
</deployable>
</deployables>
</configuration>
</plugin>
But the following error shows up:
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:redeploy (default-cli) on project rest-api: Artifact [com.acme.rest:rest-api:bundle] is not a dependency of the project. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.4.0:redeploy (default-cli) on project rest-api: Artifact [com.acme.rest:rest-api:bundle] is not a dependency of the project.
Deploying as component type "web" works, but then I can't use the OSGI bundles...
Does anybody have experience with deploying Web Application Bundle and OSGI bundles?
I don't know about cargo plugin, but to deploy a wab using asadmin client, one has to pass a --type=osgi option as shown below:
asadmin deploy --type=osgi foo.war
So, see if you can configure cargo plugin to pass this option.
Sahoo
The trick is :
<deployable>
<groupId>com.acme.rest</groupId>
<artifactId>rest-api</artifactId>
<type>war</type>
<implementation>org.codehaus.cargo.container.deployable.Bundle</implementation>
</deployable>
You still have a WAR artifact, but Bundle will trick Cargo to deploy it as OSGi.
Try using version 1.4.7 which added support for sending asadmin params in conjunction with the param that #Sahoo mentioned.
<cargo.glassfish.deploy.arg.1>--type=osgi foo.war</cargo.glassfish.deploy.arg.1>
Allow passing extra parameters for glassfish deployment
https://jira.codehaus.org/browse/CARGO-1245

Resources