WebSphere problems with webservices when build/deploy with Maven - web-services

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.

Related

Apache CXF - How can I automate WSDL relative path resolution for Client Stubs generation?

In my maven project in order to generating client stubs using apache cxf, I've configured the pom as follows:
<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>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<frontEnd>jaxws21</frontEnd>
<markGenerated>true</markGenerated>
<xjcargs>
<xjcarg>-Xts</xjcarg>
</xjcargs>
</defaultOptions>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/MyServiceA_v1.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/MyServiceA_v1.wsdl</wsdlLocation>
</wsdlOption>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/MyServiceB_v1.wsdl</wsdl>
<wsdlLocation>classpath:wsdl/MyServiceB_v1.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.cxf.xjcplugins</groupId>
<artifactId>cxf-xjc-ts</artifactId>
<version>2.6.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
Then I've downloaded "manually" all the WSDLs from the server, which exposes the web services, into my resource project folder "\my-project\src\main\resources\wsdl" and all the related XSDs inside my xsd project folder "\my-project\src\main\resources\wsdl\xsd".
After that I've changed manually all the schemaLocation inside the WSDLs file in order to have only relative path (then running cxf generation the java client stubs are correctly generated).
Example:
Inside a wsdl I've changed:
<xs:import namespace="http://ws.myproject.priv.schema/MyServiceA/v1" schemaLocation="http://161.29.123.124:8080/web-1.0/ws/MyServiceA_v1?myServiceA_v1.0.xsd"/>
with the relative path (related to the folder \my-project\src\main\resources\wsdl\xsd)
<xs:import namespace="http://ws.myproject.priv.schema/MyServiceA/v1" schemaLocation="xsd/myServiceA_v1.0.xsd"/>
Is there a way (with maven, apache cxf, ant or something else...) to download automatically all the WSDLs and XSDs from the server to my folders and then automatically changing the server paths with my project relative paths?
How can I automate this process?

jax-ws maven plugin sets wsdlLocation to absolute path

I generate web service client using
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<target>2.1</target>
<xnocompile>false</xnocompile>
</configuration>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
</plugin>
my EndpointService.wsdl is in src/main/wsdl. Plugin generates EndointServiceService.java with annotation
#WebServiceClient(name = "EndpointServiceService", targetNamespace = "http://soap.endpoint.fsg.ftc/", wsdlLocation = "file:/D:/Source/java/branches/9.3.0/camel-smev/wscapi/src/wsdl/EndpointService.wsdl")
so if wsdl
D:/Source/java/branches/9.3.0/camel-smev/wscapi/src/wsdl/EndpointService.wsdl
not exist(on another machine), it throw exception in runtime.
if i copy wsdl to this dir it runs successfully. How can i include wsdl into my target jar and make client use it? Or how to exclude wsdl dependency at runtime at all? Maybe try older version or another plugin?
add the < wsdllocation > tag in the plugin configuration to a relative path for your wsdl.
you can find an example here

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

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.

maven wsimport throwing security exception with PKIX path building failed:

I have an ejb which is annotated with #Webserivce. Everything in glassfish4.
The wsdl is generated correctly, soapUi can also send requests.
But when I try to generate client artifacts using jax ws maven plugin which is configured as following.
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>${basedir}/src/main/resources/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>transactionService.wsdl</wsdlFile>
</wsdlFiles>
<packageName>com.me.backend.connector.ws</packageName>
<sourceDestDir>${basedir}/target/generated-sources/main/java</sourceDestDir>
</configuration>
</execution>
</executions>
</plugin>
I get sun.security.validator.ValidatorException: PKIX path building failed:
So I need to know
How can I tell jax ws plugin to use the certificates ?
How can I get the certificates, currently the webservice and the client are both on localhost for development purpose
How can I tell glassfish4 not to use https and use http when exposing the webservice ?
Just noticed. Glassfish generates both http and https wsdl locations. So the http one works

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>