SOAP Client

Post here questions and problems related to oXygen frameworks/document types.
nhenel_sog
Posts: 13
Joined: Thu May 31, 2018 4:34 pm

SOAP Client

Post by nhenel_sog »

Hi,
I'm writing a plugin using some SOAP WS as client.
I have updated my oXygen's version from 20.1 to 21.
Now, my SOAP client throws an exception when I create the service:

Code: Select all

java.lang.Error: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factorycom.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl cannot be cast to javax.xml.soap.SAAJMetaFactory
at com.sun.xml.internal.ws.api.SOAPVersion.<init>(SOAPVersion.java:178) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.api.SOAPVersion.<clinit>(SOAPVersion.java:84) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseBinding(RuntimeWSDLParser.java:578) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:460) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:234) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:194) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:163) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:348) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:306) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:215) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:196) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:192) ~[?:1.8.0_101]
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:104) ~[?:1.8.0_101]
at javax.xml.ws.Service.<init>(Service.java:77) ~[?:1.8.0_101]
at javax.xml.ws.Service.create(Service.java:707) ~[?:1.8.0_101]
at com.sogitec.oxygen.server.WebServiceHelper.buildService(WebServiceHelper.java:26) ~[oxyPlugins.jar:?]
at com.sogitec.oxygen.plugin.WorkspaceAccessPlugin.applicationStarted(WorkspaceAccessPlugin.java:25) [oxyPlugins.jar:?]
at ro.sync.exml.MainFrame.ran(Unknown Source) [oxygen.jar:?]
at ro.sync.exml.MainFrame.<init>(Unknown Source) [oxygen.jar:?]
at ro.sync.exml.MainFrame.<init>(Unknown Source) [oxygen.jar:?]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) [?:1.8.0_101]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:1.8.0_101]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) [?:1.8.0_101]
at ro.sync.ui.application.ApplicationLauncher.d(Unknown Source) [oxygen.jar:?]
at ro.sync.ui.application.ApplicationLauncher.launch(Unknown Source) [oxygen.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]
at ro.sync.exml.Oxygen.main(Unknown Source) [oxygen.jar:?]
Caused by: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factorycom.sun.xml.messaging.saaj.soap.SAAJMetaFactoryImpl cannot be cast tojavax.xml.soap.SAAJMetaFactory
at javax.xml.soap.SAAJMetaFactory.getInstance(SAAJMetaFactory.java:80) ~[javax.xml.soap-api-1.4.0.jar:1.8.0_101]
at javax.xml.soap.MessageFactory.newInstance(MessageFactory.java:146) ~[javax.xml.soap-api-1.4.0.jar:1.8.0_101]
at com.sun.xml.internal.ws.api.SOAPVersion.<init>(SOAPVersion.java:175) ~[?:1.8.0_101]
... 30 more
I search a bit and found a classical fix, add this to my pom.xml:

Code: Select all

    <dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.5.0</version>
</dependency>
But it's solve nothing.
If I create and run a JUnit test, my service is correctly create.
The exception is throwed only if I create it during the oXygen execution.
Could you help me to solve.

Best regards,

Nhenel
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: SOAP Client

Post by Radu »

Hi Nhenel,

In Oxygen 21 we added some new libraries which may indeed interfere with your plugin?
What does your "plugin.xml" descriptor file look like? Can you post its contents here?
Also what is the precise list of JAR libraries you distribute with the plugin?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
nhenel_sog
Posts: 13
Joined: Thu May 31, 2018 4:34 pm

Re: SOAP Client

Post by nhenel_sog »

Hi Radu,
I have tried with a minimal project and have the same issue.
Here my pom.xml:

Code: Select all

 <?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example.oxygen</groupId>
<artifactId>test-soap-saaj</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
<dependencies>
<dependency>
<groupId>com.oxygenxml</groupId>
<artifactId>oxygen-sdk</artifactId>
<version>21.0.0.0</version>
<exclusions>
<!--<exclusion>-->
<!--<groupId>xerces</groupId>-->
<!--<artifactId>xercesImpl</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>com.oxygenxml</groupId>-->
<!--<artifactId>oxygen-patched-saaj</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>javax.xml.soap</groupId>-->
<!--<artifactId>javax.xml.soap-api</artifactId>-->
<!--</exclusion>-->
<!--<exclusion>-->
<!--<groupId>com.sun.xml.messaging.saaj</groupId>-->
<!--<artifactId>saaj-impl</artifactId>-->
<!--</exclusion>-->
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>com.sun.xml.messaging.saaj</groupId>-->
<!--<artifactId>saaj-impl</artifactId>-->
<!--<version>1.5.0</version>-->
<!--</dependency>-->

<!-- for test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.jfcunit</groupId>
<artifactId>jfcunit</artifactId>
<version>2.08</version>
<scope>test</scope>
</dependency>

</dependencies>
</project>
As comment, some test to resolve my issue.

And here, the plugin.xml:

Code: Select all

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plugin SYSTEM "../plugin.dtd">
<plugin id="com.example.oxygen.plugin.PluginExtensions" name="PluginExtensions" description="Test"
version="1.0.0" vendor="Us" class="com.example.oxygen.plugin.ToolPlugin"
classLoaderType="preferReferencedResources">
<runtime>
<library name="D:/oxygen/TestSoapSaaj/target/oxyPlugins.jar"/>
</runtime>

<extension type="WorkspaceAccess" class="com.example.oxygen.plugin.WorkspaceAccessPlugin"/>
</plugin>
I have tried to play with <plugin classLoaderType="something"/> and with a <librariesFolder scope="something_else"/> too.

I'm not a SOAP expert technologies, maybe the fix is very trivial, but I can't found it.

Best regards,
Nhenel
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: SOAP Client

Post by alex_jitianu »

Hello,

Thank you for reporting this issue. I managed to reproduce it myself. It all comes from the presence of javax.xml.soap-api-1.4.0.jar inside the Oxygen's classpath. To fix it you should remove javax.xml.soap-api-1.4.0.jar from {oxygenInstallDir}/lib. I will add an issue on our side to see what we should do with that jar. I think that it was added there because starting with openjdk11 the packages javax.xml.soap and javax.xml.ws are no longer distributed. The Oxygen build you are using comes with jre8 so it doesn't really needs it.

Best regards,
Alex
nhenel_sog
Posts: 13
Joined: Thu May 31, 2018 4:34 pm

Re: SOAP Client

Post by nhenel_sog »

Thanks for the reply and the help.
IT works now. But my current client is now more compatible with your library.
I will looking for a solution for this new issue.

Thanks again,
Nhenel
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: SOAP Client

Post by alex_jitianu »

Hello,

In case it helps, what I've tested was to put all these jar files as dependencies:

Code: Select all

	<dependency>
		<groupId>javax.xml.ws</groupId>
		<artifactId>jaxws-api</artifactId>
		<version>2.2.1</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.xml.messaging.saaj/saaj-impl -->
	<dependency>
		<groupId>com.sun.xml.messaging.saaj</groupId>
		<artifactId>saaj-impl</artifactId>
		<version>1.5.1</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/javax.xml.soap/javax.xml.soap-api -->
	<dependency>
		<groupId>javax.xml.soap</groupId>
		<artifactId>javax.xml.soap-api</artifactId>
		<version>1.4.0</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt -->
	<dependency>
		<groupId>com.sun.xml.ws</groupId>
		<artifactId>jaxws-rt</artifactId>
		<version>2.1.4</version>
	</dependency>
	<!-- https://mvnrepository.com/artifact/com.sun.org.apache.xml.internal/resolver -->
	<dependency>
		<groupId>com.sun.org.apache.xml.internal</groupId>
		<artifactId>resolver</artifactId>
		<version>20050927</version>
	</dependency>
And change the context class loader before invoking my code.

Code: Select all

try {
  Thread.currentThread().setContextClassLoader(CustomWorkspaceAccessPluginExtension.class.getClassLoader());

  javax.xml.ws.Service service = javax.xml.ws.Service.create(new URL(wsdlURL), serviceQN);

} catch (MalformedURLException e) {
  e.printStackTrace();
} finally {
  Thread.currentThread().setContextClassLoader(contextClassLoader);
}
This way you don't have to touch any jars distributed with Oxygen.

Best regards,
Alex
nhenel_sog
Posts: 13
Joined: Thu May 31, 2018 4:34 pm

Re: SOAP Client

Post by nhenel_sog »

Hi,
Thanks for the trick, but it doesn't fix my issue;
When I add the libraries to my project, the complete and the example, I have this new issue:

Code: Select all

 java.util.ServiceConfigurationError: javax.xml.ws.spi.Provider: Provider com.sun.xml.ws.spi.ProviderImpl could not be instantiated
        at java.util.ServiceLoader.fail(ServiceLoader.java:232)
        at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
        at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
        at java.util.ServiceLoader$LazyIterator.access$700(ServiceLoader.java:323)
        at java.util.ServiceLoader$LazyIterator$2.run(ServiceLoader.java:407)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:409)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
        at javax.xml.ws.spi.Provider.getProviderUsingServiceLoader(Provider.java:165)
        at javax.xml.ws.spi.Provider.provider(Provider.java:125)
        at javax.xml.ws.Service.<init>(Service.java:77)
        at javax.xml.ws.Service.create(Service.java:707)
        at com.example.oxygen.server.WebServiceHelper.buildService(WebServiceHelper.java:19)
        at com.example.oxygen.plugin.WorkspaceAccessPlugin.applicationStarted(WorkspaceAccessPlugin.java:20)
        at ro.sync.exml.MainFrame.ran(Unknown Source)
        at ro.sync.exml.MainFrame.<init>(Unknown Source)
        at ro.sync.exml.MainFrame.<init>(Unknown Source)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at ro.sync.ui.application.ApplicationLauncher.d(Unknown Source)
        at ro.sync.ui.application.ApplicationLauncher.launch(Unknown Source)
        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 ro.sync.exml.Oxygen.main(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at java.lang.Class.newInstance(Class.java:442)
        at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
        ... 25 more
Caused by: javax.xml.ws.WebServiceException: Error creating JAXBContext for W3CEndpointReference.
        at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:278)
        at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:273)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.xml.ws.spi.ProviderImpl.getEPRJaxbContext(ProviderImpl.java:273)
        at com.sun.xml.ws.spi.ProviderImpl.<clinit>(ProviderImpl.java:98)
        ... 31 more
Caused by: javax.xml.bind.JAXBException
 - with linked exception:
[com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.w3c.dom.Element is an interface, and JAXB can't handle interfaces.
        this problem is related to the following location:
                at org.w3c.dom.Element
                at public java.util.List com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements.elements
                at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
                at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties
                at com.sun.xml.ws.developer.MemberSubmissionEndpointReference
]
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:262)
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:584)
        at com.sun.xml.ws.spi.ProviderImpl$2.run(ProviderImpl.java:276)
        ... 35 more
Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
org.w3c.dom.Element is an interface, and JAXB can't handle interfaces.
        this problem is related to the following location:
                at org.w3c.dom.Element
                at public java.util.List com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements.elements
                at com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements
                at public com.sun.xml.ws.developer.MemberSubmissionEndpointReference$Elements com.sun.xml.ws.developer.MemberSubmissionEndpointReference.referenceProperties
                at com.sun.xml.ws.developer.MemberSubmissionEndpointReference

        at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:106)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:471)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:303)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:139)
        at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1156)
        at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:165)
        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 javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
        ... 40 more
Any ideas to solve this new issue ?
Thanks again,
Nhenel
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: SOAP Client

Post by alex_jitianu »

Hello,

I'm sorry for taking a long time to answer. Last week we celebrated Easter and I was away for the entire week.

Let's see where we are at.

1. My first suggestion was to:
To fix it you should remove javax.xml.soap-api-1.4.0.jar from {oxygenInstallDir}/lib
I didn't quite understood your answer. Can you please give me more details?
IT works now. But my current client is now more compatible with your library.
2. My second suggestion was to add all the required libraries in the plugin. I was able to create a javax.xml.ws.Service object afterwards. Can you please send me on support@oxygenxml.com a sample project? I want to look at pom.xml and the at the Java code that gets invoked. By the way, with which version of Java is Oxygen running? You can see that if you go to Help->About, on the System properties tab.

Best regards,
Alex
nhenel_sog
Posts: 13
Joined: Thu May 31, 2018 4:34 pm

Re: SOAP Client

Post by nhenel_sog »

Hello Alex,
During I make the sample project, I have found a new ‎line of thought.

So, I play with my maven's scopes and copied libs.
I using your hack with class loader, but not with the WorkspaceAccesPluginExtension extended class but with my generated by JAXB WebService interface.
And last, but not the least, I must copy my jar and its lib into "plugins" directory. If I use my building directory, I have some weird exception.

So my issue is solve
Thanks for your help,
Nhenel
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: SOAP Client

Post by alex_jitianu »

Hello,

It's good to hear that you've found a solution.
And last, but not the least, I must copy my jar and its lib into "plugins" directory. If I use my building directory, I have some weird exception.
Perhaps you had more libraries in the building directory and they all got loaded (it depends on how plugin.xml is written).
Best regards,
Alex
nhenel_sog
Posts: 13
Joined: Thu May 31, 2018 4:34 pm

Re: SOAP Client

Post by nhenel_sog »

Hello,
Sorry for the long time, my turn to go away for vacations :)
I copy exactly the "lib" directory.
But in the root directory, there are some anotherworking directories.
So, now it's done.
Thanks for the help.
Best regards,
Nhenel
Post Reply