WSWS4104E: SOAP 1.2 protocol not supported by SAAJ 1.2 - soap

I have a JAXWS client in a standalone application that is throwing:
Caused by: java.lang.UnsupportedOperationException: WSWS4104E: SOAP 1.2 Protocol is not supported by SAAJ 1.2.
at com.ibm.ws.webservices.engine.xmlsoap.SOAPFactory.setSOAPConstants(SOAPFactory.java:143)
at com.ibm.ws.webservices.engine.xmlsoap.SOAPFactory.<init>(SOAPFactory.java:111)
at com.ibm.ws.webservices.engine.soap.SAAJMetaFactoryImpl.newSOAPFactory(SAAJMetaFactoryImpl.java:68)
at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:297)
at com.sun.xml.internal.ws.api.SOAPVersion.<init>(SOAPVersion.java:176)
at com.sun.xml.internal.ws.api.SOAPVersion.<clinit>(SOAPVersion.java:94)
I have added the following jar com.ibm.jaxws.thinclient_8.0.0.jar but still throws the same error.
Also tried adding these dependencies:
<dependency>
<groupId>com.sun.xml.messaging.saaj</groupId>
<artifactId>saaj-impl</artifactId>
<version>1.3.25</version>
</dependency>
<dependency>
<groupId>javax.xml.soap</groupId>
<artifactId>saaj-api</artifactId>
<version>1.3.5</version>
</dependency>
Even running under Oracle's JDK 1.8 and IBM JDK 1.7.
This is driving me crazy, any idea why it doesn't work?

After strugging with this I finally understood what was going on:
when using SOAP 1.2, the thin client tries to determine if SAAJ 1.3 is available.
com.ibm.ws.webservices.engine.xmlsoap.Utils
private static final boolean isSAAJ13Available = discoverSAAJ13Availability();
discoverSAAJ13Availability() ends up trying to load com.ibm.ws.webservices.engine.xmlsoap.saaj13only.SOAPDynamicConstants which isn't on the classpath and finally raises the exception.
To solve it you also have to add the jar that contains that class: com.ibm.jaxws.thinclient_8.0.0.jar.

Related

[io.r2dbc.spi.ConnectionFactory]: java.lang.NoSuchFieldError: LOCK_WAIT_TIMEOUT

My Java Spring Boot project fails at startup with the given error:
Failed to instantiate [io.r2dbc.spi.ConnectionFactory]: Factory method 'connectionFactory' threw exception; nested exception is java.lang.NoSuchFieldError: LOCK_WAIT_TIMEOUT
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-r2dbc</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>com.oracle.database.r2dbc</groupId>
<artifactId>oracle-r2dbc</artifactId>
<version>0.4.0</version>
</dependency>
How do I fix it?
tl;dr: As of this writing, use oracle-r2dbc 0.1.0 in Spring projects.
oracle-r2dbc 0.4.0 depends on a newer version of io.r2dbc:r2dbc-spi than spring-data-r2dbc 1.4.3.
You may have to clear your build tool or IDE's cache for the change to take effect. (In my case mvn clean and IntelliJ "Invalidate Caches...")
Btw, when I downgraded, I think it broke using descriptors in the rdbc URL so I had to switch to a URL like this: r2dbc:oracle://<host>:<port>/<service-name>
Update, just saw on Oracle's driver docs for r2dbc, it says:
Use the 0.1.0 version of Oracle R2DBC if you are programming with
Spring. The later versions of Oracle R2DBC implement the 0.9.x
versions of the R2DBC SPI. Currently, Spring only supports drivers
that implement the 0.8.x versions of the SPI.
https://github.com/oracle/oracle-r2dbc
DO NOT USE 0.2.0 with Spring - even worse than no error, queries just hang forever. I spent over a day trying to debug it. Not only I had the wrong version, but when I actually did try changing the version, my IDE was caching the old version out of sync with Maven.

Optaplanner - drools file cannot be compiled when project is deployed

We developped a SpringBoot project with Java 11 using optaplanner-core and defining rules in a Drools file. We have no issue for running the app in intelliJ with JDK.
We then deployed the app onto Azure app service where a JRE is installed. We get the following error:
Caused by: org.kie.memorycompiler.KieMemoryCompilerException:
Cannot find the System's Java compiler. Please use JDK instead of JRE or add drools-ecj dependency to use in memory Eclipse compiler
We tried to add the following dependencies but we still get the same error:
<dependency>
<groupId>org.optaplanner</groupId>
<artifactId>optaplanner-core</artifactId>
<version>8.4.1.Final</version>
</dependency>
<dependency>
<groupId>org.drools</groupId>
<artifactId>drools-ecj</artifactId>
<version>7.51.0.Final</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.26.0</version>
</dependency>
Would anyone know how to solve this problem ?
Thank you
Adding drools-ecj won't really fix this. The error message is misleading.
Using a JDK instead of a JRE. The easiest way is to upgrade to Java 11 (or higher), as that only comes with a JDK.
If running optaplanner with a JDK is no option for you, you can change the solver config to
<solver>
<scoreDirectorFactory>
<droolsAlphaNetworkCompilationEnabled>false</droolsAlphaNetworkCompilationEnabled>
</scoreDirectorFactory>
</solver>
and if you're using unit tests for java constraints that use the ConstraintVerifier, instantiate it like this
new DefaultConstraintVerifier<>(new MyConstraints(), SolutionDescriptor.buildSolutionDescriptor(myModelClasses))
.withDroolsAlphaNetworkCompilationEnabled(false)
However: From what I understood, disabling the drools alpha network compiler usually comes with a performance impact.

Migration to Jakarta: ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl

While migrating from Java 8 to Java 11 and switching from EE to the newest Jakarta libraries according to https://wiki.eclipse.org/New_Maven_Coordinates and Maven central, we get the following runtime exception in our (still SOAP-based) client application:
Exception in thread "main" javax.xml.ws.WebServiceException: Provider com.sun.xml.internal.ws.spi.ProviderImpl not found
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:31)
at javax.xml.ws.spi.FactoryFinder$1.createException(FactoryFinder.java:28)
at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:73)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:82)
at javax.xml.ws.spi.Provider.provider(Provider.java:66)
at javax.xml.ws.Service.<init>(Service.java:82)
at [...]
Caused by: java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at javax.xml.ws.spi.ServiceLoaderUtil.nullSafeLoadClass(ServiceLoaderUtil.java:60)
at javax.xml.ws.spi.ServiceLoaderUtil.safeLoadClass(ServiceLoaderUtil.java:93)
at javax.xml.ws.spi.ServiceLoaderUtil.newInstance(ServiceLoaderUtil.java:71)
... 5 more
The solution described in Getting java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl despite the dependencies are defined doesn't work and doesn't use Jakarta.
If I'm not wrong, the Jarkarta libraries shouldn't contain "com.sun.xml."packages or reference such, but javax.xml.ws.spi.Provider obviously STILL DOES reference such class:
private static final String DEFAULT_JAXWSPROVIDER =
"com.sun"+".xml.internal.ws.spi.ProviderImpl";
So, does anyone know if there is a Jakarta equivalent to the missing library containing ProviderImpl, or how I could workaround the problem with Jakarta?
Thanks in advance!
I finally found a workaround for my problem. According to the answer given in How to use WebServices on Java 11? package javax.jws does not exist the reference implementation of JAX-WS should be included with Java 11:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
Unfortunately, compiling our project with this dependency using the latest maven-compile-plugin 3.8.0 causes the exception described in https://jira.apache.org/jira/browse/MCOMPILER-355. It should be fixed in 3.8.1 but the version is not available yet.
As a workaround I got our project working with the hint given in Getting java.lang.ClassNotFoundException: com.sun.xml.internal.ws.spi.ProviderImpl despite the dependencies are defined, combined with an additional dependency (namely resolver that is also linked in the pom.xml of jaxws-ri) to avoid an subsequent java.lang.ClassNotFoundException: com.sun.org.apache.xml.internal.resolver.CatalogManager:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.org.apache.xml.internal</groupId>
<artifactId>resolver</artifactId>
<version>20050927</version>
</dependency>
Maybe this helps someone running into the same problem.
Throwing my 5 cents into the ring as I had "the same problem". What resolved it to me was to stick with the version two of the jaxws-rt package, since version 3.0.0 did fail with the same results as mentioned above.
So what I used to get my JDK 8 source running without any modification was:
// https://mvnrepository.com/artifact/com.sun.xml.ws/jaxws-rt
implementation group: 'com.sun.xml.ws', name: 'jaxws-rt', version: '2.3.3' //3.0.0 did not work!
// https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api
implementation group: 'javax.xml.ws', name: 'jaxws-api', version: '2.3.1'
// https://mvnrepository.com/artifact/javax.jws/javax.jws-api
implementation group: 'javax.jws', name: 'javax.jws-api', version: '1.1'

StAXSource not accepted by validator in JBoss EAP 6.1

Issue while Validating StAXSource in JBoss Server,
What I Tried:
I try to do parsing and validation at a time using StAX.
As described in this example.
I am able to execute the program as standalone application, but when I try it as a web application in JBoss EAP 6.1 server got below exception.
Exception:
java.lang.IllegalArgumentException: Source parameter of type
javax.xml.transform.stax.StAXSource' is not accepted by this validator.
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
There are multiple frame works modified from StAXSource to StreamSource,
TEIID-2046, activiti..etc.
I am not sure, Why JBoss is not supporting StAXSource, any clues?
Issue got resolved by adding xercesImpl 2.11.0 dependency. (as mentioned in forums_activiti)
Solution: add xerces 2.11.0 dependency.
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
Details:
JBoss EAP 6.1 has Xerces 2.9.1-redhat-4, but StaxSource enhancement released in Xerces-J 2.10.0 (For more details refer JBoss EAP Component details).
Xerces-J 2.10.0 has implementation enhancement for java.xml.validation and supporting StAXSource for JAXP validator.
Update: Added Feature Request in JBoss EAP 1.6 project.
References:
http://comments.gmane.org/gmane.comp.apache.commons.general/1770
http://xerces.apache.org/xerces2-j/
http://people.apache.org/~edwingo/jaxp-faq.html

SOAP web services NPE on redeployment Tomcat 6

I'm using Tomcat 6 and I have a web application that uses a SOAP web service. I generated the client classes to use using cxf-codegen-plugin in maven, my dependencies are :
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-api</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.6.1</version>
</dependency>
Everything works until I redeploy my war on tomcat (or even doing a simple touch on it: no code modification at all). Using the same url to access my page that makes the SOAP service call I have this weird NPE:
java.lang.NullPointerException
at com.ctc.wstx.util.SymbolTable.findSymbol(SymbolTable.java:385)
at com.ctc.wstx.sr.StreamScanner.parseLocalName(StreamScanner.java:1831)
at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:2997)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:2941)
at com.ctc.wstx.sr.BasicStreamReader.handleRootElem(BasicStreamReader.java:2078)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2058)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1117)
at com.sun.xml.internal.ws.util.xml.XMLStreamReaderFilter.next(XMLStreamReaderFilter.java:81)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.next(XMLStreamReaderUtil.java:78)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextContent(XMLStreamReaderUtil.java:99)
at com.sun.xml.internal.ws.streaming.XMLStreamReaderUtil.nextElementContent(XMLStreamReaderUtil.java:89)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.hasWSDLDefinitions(RuntimeWSDLParser.java:209)
at com.sun.xml.internal.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:119)
at com.sun.xml.internal.ws.client.WSServiceDelegate.parseWSDL(WSServiceDelegate.java:254)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:217)
at com.sun.xml.internal.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:165)
at com.sun.xml.internal.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:93)
at javax.xml.ws.Service.<init>(Service.java:56)
at some.package.flightinfo.model.flightstatsv2.soap.AirportsV1SoapService.<init>(AirportsV1SoapService.java:48)
at some.package.flightinfo.adapter.FlightStatsV2ContentAdapter.getAirportsByGPSCoordinate(FlightStatsV2ContentAdapter.java:107)
The only way I can get my web application working again is to restart tomcat which is no option at all.
I am totally clueless on what's going on, has anyone ever experienced this problem before?
Cheers.
Well, you are missing the cxf-rt-frontend-jaxws dependency. Thus, you are ending up using the JAX-WS reference impl built into the JDK, not CXF. If you add the CXF dependencies, does that fix it? Could be a bug in the RI or something.