Unable to activate bundle in Sling that consumes SOAP service using JAX WS RI - web-services

First the requirement:
I need to write code that consumes a SOAP service and build it as an OSGi bundle that can be deployed in Apache Sling. The build is done using Maven 3.0.3
What I have done so far:
I created a maven module and used this for generating SOAP client classes: https://jax-ws-commons.java.net/jaxws-maven-plugin/usage.html. I had to remove the plugin dependency jaxws-tools version 2.2.5 as it was not supporting the -encoding parameter to wsimport. Removing it automatically downloads version 2.2.8 and it works fine as it is a dependency for the POM.
Next, I changed the package type to bundle and included maven-bundle-plugin and maven-scr-plugin to package the generated code as a OSGi bundle and built it using Maven
Finally I deployed it to Sling running locally as a standalone application.
Following are the issues I faced in the given order:
javax.jws package unresolved - I included this as a private-package under configurations for the maven-bundle-plugin
Similar packages that were unresolved were added which includes:
javax.xml.ws
javax.xml.ws.handler
javax.xml.ws.spi
javax.xml.ws.spi.http
javax.xml.ws.wsaddressing
After adding these to the private-package, I started getting this error:
(javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found) javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
Root Cause: java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl not found by org.apache.felix.http.jetty
This is where I hit a roadblock which I am not able to move past.
What I have tried so far to fix this based on numerous answers on google
tried to include this line in the sling.properties file:
sling.bootdelegation.com.sun=com.sun.*
Tried adding this line
sling.system.packages.simple=com.sun.xml.internal.ws.spi.ProviderImpl
Tried adding this line
sling.bootdelegation.class.com.sun.xml.internal.ws.spi.ProviderImpl=com.sun.xml.internal.ws.spi
Tried adding all the packages mentioned earlier to the org.osgi.framework.system.packages property as well as to the jre-1.6 property
After doing this, I can see that these packages are now being exposed by the system bundle. But only the javax.jws is showing as resolved. All other bundles still show as unresolved.
Tried all possible combinations of export-packages.
Even tried to remove unresolved packages as suggested by some posts
I am using Maven 3.0.3, JDK 1.6.0_43, Apache Sling org.apache.sling.launchpad.base.jar 2.4.0 all of which is running on my Mac Book Pro with OSX 10.8.5
Here is my POM snippet that is relevant to this question. If more information is needed I can provide the same as well
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Private-Package>
<!--javax.jws,-->
javax.xml.ws,
javax.xml.ws.handler,
javax.xml.ws.spi,
javax.xml.ws.spi.http,
javax.xml.ws.wsaddressing
</Private-Package>
<!--
<Export-Package>
com.sun.xml.internal.ws.spi
</Export-Package>
<Import-Package>
!javax.xml.ws,*
</Import-Package>
-->
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- The name of your generated source package -->
<packageName>com.mycompany.mypackage</packageName>
<wsdlUrls>
<wsdlUrl>http://localhost/mysoapservice?WSDL</wsdlUrl>
</wsdlUrls>
<extension>true</extension>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.7</version>
<type>jar</type>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.9</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Any help would be greatly appreciated. Waiting for a response in anticipation.

Related

gwt-maven-plugin does load the "main" log4j configuration instead of the "test" one

On my maven project, I have a different log4j configuration for development and integration environment and also different ones for test purposes than for the main usage of my webapp. Located in :
src/main/resources/dev/log4j.properties
src/main/resources/int/log4j.properties
src/test/resources/dev/log4j_test.properties
src/test/resources/int/log4j_test.properties
So I have different profiles (DEV / INT) to manage thoses differences...
And for surefire (used for unit testing) and failsafe (used for integration testing) plugin I added some configuration :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<log4j.configuration>file:${basedir}/${profile.test.resource}/log4j_test.properties</log4j.configuration>
</systemPropertyVariables>
<!-- Stop the integration tests after the first failure to keep in database
the content of the failed test. -->
<skipAfterFailureCount>1</skipAfterFailureCount>
<includes>
<!-- Include only integration tests -->
<include>**/*IntegrationTest.java</include>
</includes>
<skip>${skip.integration.tests}</skip>
</configuration>
</plugin>
But now I'm adding gwt-maven-plugin for GWT specific unit testing in DEV mode.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.7.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>i18n</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>Appication.html</runTarget>
<webappDirectory>${webappDirectory}</webappDirectory>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<i18nMessagesBundles>
...
</i18nMessagesBundles>
<extraJvmArgs>${gwt.extra.args}</extraJvmArgs>
<style>${compile.style}</style>
<module>${module.name}</module>
</configuration>
</plugin>
Is it possible to configure it to point on a specific / filtered lop4j as I did for surefire and failsafe ?*
Thanks,
You can pass system properties in extraJvmArgs

Jacoco Show Source Code

I have some code which reads the exec file and creates html pages for all of my projects running on a webspehre server. The server is on a remote machine, I have all the source code running on the remote machine copied to my local machine. I need to know how, with the html file generated and the exec file how I can view the source code.
Is this even possible?
To successfully create coverage reports with Jacoco from Maven you should add the jacoco maven plugin to your POM.
As explained on the Jacoco Maven Plugin page you need to add the plugin (with the latest version as of this posting):
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6-SNAPSHOT</version>
</plugin>
And then you need to add extra configuration to tell jacoco what phase to instrument tests and then when to generate the reports
This configuration was taken from one of the example jacoco poms for a JAR project that runs JUnit tests under code coverage and creates a coverage report (target/site/jacoco/index.html).
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6-SNAPSHOT</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<!-- implementation is needed only for Maven 2 -->
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<!-- implementation is needed only for Maven 2 -->
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.60</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>

The #javax.jws.WebMethod annotation cannot be used in with #javax.jws.WebService.endpointInterface element in maven

I am trying to create a JWS web service from a WSDL file that's already defined/created by me.
I have followed a two step approach like:
wsimport - from "jaxws-maven-plugin" - to create wsdl artifact files - SUCESS
wsgen - from "jaxws-maven-plugin" - to compile my SEI and create a war file - FAILED
I am seeing issues with #2. The error is:
The #javax.jws.WebMethod annotation cannot be used in with #javax.jws.WebService.endpointInterface element in maven
Can someone help me to resolve this issue?
I used this configuration in my pom.xml. Additionally, avoid to use #WebParam for your parameters, in your #Webmethod. Hope this helps you.
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>wsgen</goal>
</goals>
<configuration>
<sei>service.CompanyImpl</sei>
<genWsdl>true</genWsdl>
<encoding>UTF-8</encoding>
<inlineSchemas>true</inlineSchemas>
<verbose>true</verbose>
</configuration>
</execution>
</executions>

WebSphere problems with webservices when build/deploy with Maven

I am in the process of migrating an application to be built and deployed with Maven. It's deployed on WebSphere 7. I've managed to get part of this application (HTML UI and such) working fine, but the web services are having a problem.
When I try to access the URL for the web service (such as localhost:9000/MyApplication/MyWebServiceProject/MyService), I expect to see a page that say something like "Hello, this is a web service!".
Instead, I see this exception:
[4/1/13 11:49:37:484 EDT] 0000001d WASAxis2Servl E The following exception was encountered while attempting to load the ConfigurationContext for the servlet: com.ibm.ws.websvcs.exception.ConfigurationException: Could not retrieve server module metadata in Axis servlet for module: MyWebServiceProject
com.ibm.ws.websvcs.exception.ConfigurationException: Could not retrieve server module metadata in Axis servlet for module: MyWebServiceProject
at com.ibm.ws.websvcs.transport.http.WASAxis2Servlet.init(WASAxis2Servlet.java:290)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:358)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.init(ServletWrapperImpl.java:171)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:739)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3935)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:83)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1613)
I'm guessing there's some IBM-specific configuration that is needed for deploying web services via Maven, but I'm not sure what it is.
Relevant sections from the POM for the EAR project:
<plugin>
<artifactId>maven-ear-plugin</artifactId>
<version>2.7</version>
<configuration>
<applicationName>PolicyGatewayEAR</applicationName>
<defaultLibBundleDir>lib/</defaultLibBundleDir>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>was6-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>integration-test</phase>
<id>uninstall</id>
<goals>
<goal>wsUninstallApp</goal>
</goals>
<configuration>
<wasHome>${was7Home}</wasHome>
<verbose>false</verbose>
<failOnError>false</failOnError>
<profileName>was70profile1</profileName>
<workingDirectory>${project.build.directory}/was6-maven-plugin</workingDirectory>
<applicationName>MyApplication</applicationName>
</configuration>
</execution>
<execution>
<phase>integration-test</phase>
<id>installation</id>
<goals>
<goal>installApp</goal>
</goals>
<configuration>
<wasHome>${was7Home}</wasHome>
<verbose>false</verbose>
<failOnError>true</failOnError>
<updateExisting>false</updateExisting>
<profileName>was70profile1</profileName>
<workingDirectory>${project.build.directory}/was6-maven-plugin</workingDirectory>
<applicationName>MyApplication</applicationName>
</configuration>
</execution>
</executions>
</plugin>
POM snippet for the web-service sub-project:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>true</failOnMissingWebXml>
<warSourceDirectory>WebContent</warSourceDirectory>
<packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
This wasn't a problem when I was deploying to WAS using RAD (v8.5) - it's only started since I tried build and deploy the application using Maven. Does anyone know how to resolve this error?
So it turns out that I had to use the same solution as desribed here:
Deployed webservice schema does not match what's in workspace
For some reason, WebSphere was unable to generate the WSDL from code when the WSDL and schema files were not provided in the Maven-build project. The error message I reported is similar to one that I saw when I was running tests with including the WSDL and schema in the EJB project.

How to deploy WAR on JBoss-5.1.0.GA using cargo-maven plugin and wait till it gets deployed before running Integration Tests?

I have a maven web application(Spring+ApacheCXF webservices) and have a couple of IntegrationTests(*IT.java). I want to run integration tests using failsafe plugin by deploying the war file using cargo-maven plugin.
Here is my pom configuration:
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.0.3</version>
<configuration>
<container>
<containerId>jboss51x</containerId>
<home>C:/jboss-5.1.0.GA</home>
<append>false</append>
<log>${project.build.directory}/logs/jboss51x.log</log>
<output>${project.build.directory}/logs/jboss51x.out</output>
<timeout>300000</timeout>
</container>
<configuration>
<type>existing</type>
<home>C:/jboss-5.1.0.GA/server/default</home>
<properties>
<cargo.servlet.port>8080</cargo.servlet.port>
<cargo.jboss.configuration>default</cargo.jboss.configuration>
<cargo.rmi.port>1099</cargo.rmi.port>
<cargo.logging>high</cargo.logging>
</properties>
<deployables>
<deployable>
<groupId>${project.groupId}</groupId>
<artifactId>admin-services</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-container</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deployer-deploy</goal>
</goals>
</execution>
<execution>
<id>stop-container</id>
<phase>post-integration-test</phase>
<goals>
<goal>deployer-undeploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>failsafe-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugin>
But the problem is cargo plugin deploys the WAR file and immediately failsafe plugin is trying to execute the IntegrationTests, and by that time application is not deployed so tests are failing.
With the same configuration I am able to run the integration tests in two steps successfully.
1. execute cargo:deployer-deploy
2. execute integration-test
Is there anyway to trigger failsafe plugin only after the application got deployed by cargo plugin?
I think you can use the pingURL parameter to provide an url to verify the deployment is completed: see http://cargo.codehaus.org/Maven2+Plugin+Reference+Guide
Using cargo you dont have to deploy the application, there is also support for: http://cargo.codehaus.org/Functional+testing (but that depends on your tests of course)