Why does cxf throw an unmarshalling error on elements that have no namespace prefix when the namespace should be inherited - jaxb

I am creating a SOAP client that runs in a Java 11 Spring Boot server and makes requests to a Java 8 server. I'm using cxf-rt-frontend-jaxws:3.4.3 and cxf-rt-transports:3.4.3 in a Gradle 6.9 build with the com.github.bjornvester.wsdl2java Gradle plugin version 1.1.
My client can call a simple echo test SOAP operation with no problem. That service passes a request object containing a single String and gets a response object containing the String. So I know the basic connection is working and the other end is responding.
My problem arises when I call an operation that has no input and returns a list of objects in the response. I get this error:
org.apache.cxf.interceptor.Fault: Unmarshalling Error: unexpected element (uri:"", local:"ProposalInfo"). Expected elements are <{http://V2.pub.proposal.server.ws.cayuse.com/}ProposalInfo>
I am told that other systems call these operations with no problem.
I have stepped through the cxf and JAXB code and notice that the IntelliJ shows this text associated with a BranchingReaderSource. Not sure if this is a true error or just a side-effect of the debugger trying to call toString() on this class (which has no such method).
Method threw 'java.lang.NullPointerException' exception. Cannot evaluate com.ctc.wstx.io.BranchingReaderSource.toString()
I also notice that a class called ValidationEventLocatorImpl gets a NullPointerException on this line because "toURL" is null. I think this is because toURL comes from the empty prefix of in the response.
this.url = toURL(loc.getSystemId());
I have tried using wrapping-style "false" but that does not change anything.
I also tried to use TransformInInterceptor to map elements with no prefix to the desired prefix, but that did not work. It seems the unmarshalling error gets thrown before the interceptor runs.
Here is the WSDL used for this service; the operation that I am calling is getUnpairedProposals. I also attach a copy of the response to this operation -- the operation that is not getting unmarshalled properly. My reading of this response is that the namespace defined on the ns2:getUnPairedProposalsResponse tag should apply to the child elements such as .
Additional info:
I made several attempts to use TransformInterceptor to map the elements:
Added a map entry for "getUnPairedProposalsResponse -> {http://V2.pub.proposal.server.ws.cayuse.com/}getUnPairedProposalsResponse". This did nothing.
Inserted the TransformInterceptor at Phase.PRE_STREAM. Also had no effect.
Changed the mapping from #1 to the same but added a prefix {}, as in {}getUnPairedProposalsResponse -> {http://V2.pub.proposal.server.ws.cayuse.com/}getUnPairedProposalsResponse. This got me a null pointer exception in cxf at TransformUtils line 128 in the convertToQnamesMap method.

Related

AutoMapper: continue on exception?

In my AutoMapper scenario, I have a string property on my source type but a Uri property on the destination. Occasionally, this conversion is expected to fail when the source data is bad:
UriFormatException: Invalid URI: The hostname could not be parsed.
at Uri.ctor(String uriString)
When this happens, I would like AutoMapper to set the problematic property to null on the destination & continue on with the process of mapping the other elements. Known solutions to this are:
Writing a custom converter (with try/catch) just for that element
Using BeforeMap() as described here
But I feel that if I have to take those extra steps, AutoMapper hasn't fulfilled its promise as a time-saving tool. Isn't there some global 'continue-on-error' flag that I can set? Note that I am less concerned about Uris in particular than I am about the lack of configurable error handling.
No special setup needed to repro this--just a vanilla CreateMap() call that registers two classes with differently typed properties.

No MessageBodyWriter for Single

I'm trying to use resteasy-rxjava2 to provide an XML document using jaxb, within a vertx application (using a non-vertx legacy library we have). But I get:
Could not find MessageBodyWriter for response object of type:
org.jboss.resteasy.rxjava2.propagation.ContextPropagatorOnSingleAssemblyAction$ContextPropagatorSingle of media type:
application/xml;charset=UTF-8
From what I can tell, this comes down to the difference between a MessageBodyWriter and the AsyncResponseProvider that is in the resteasy-rxjava2 dependency for a Single (SingleProvider).
I have the following resteasy service definition
#GET
#Path(FdsnwsPaths.QUERY)
#Produces(MediaType.APPLICATION_XML)
#Stream
// CHECKSTYLE:OFF too many parameters
public Response getQuery(...)
How do I get resteasy to properly serve the data asynchrously, using the SingleProvider or otherwise.
The #Get method must return the Single explicitly or it doesn't work. (Can't use Response or Object). In my case, the Single contains the jaxb xml root element.
#GET
#Path(FdsnwsPaths.QUERY)
#Produces(MediaType.APPLICATION_XML)
#Stream
public Single<FDSNStationXML> getQuery(...)
Then, to make things more complicated, in order to handle specific exception types and map them to specific response status codes, I have to create a custom ExceptionMapper which creates the Response object I used to be able to create directly in the method. (in resteasy-vertx, I found no documentation on how to do this, but in my case, I am creating my own VertxRestEasyDeployment object so I can register the class of the ExceptionMapper(s) like this:
VertxResteasyDeployment deployment = new VertxResteasyDeployment();
deployment.getActualProviderClasses().addAll(providerClasses);
For reference, this is all being done with:
RestEasy 5.0.3.Final (including resteasy-rxjava2)
RxJava 2.2.20
Vertx 3.9.5

Binding Exception with Ninject

We have a central logging component which I am now trying to use in a WebJob that I am developing. I am basically following this example. My Activator is identical, I have the bindingModule that has my Bind statements in it. One thing I have done differently here is to use the method versions:
Kernel.Bind(typeof(IExternalSystemLogger)).To(typeof(ExternalSystemLogger));
instead of the generic versions in the example. I currently have constructor injection implemented but I have also set up the parameter injection as per the example. Which ever way I try to do this I end up with the error:
Error indexing method 'Functions.ProcessQueueMessage' ---> System.InvalidOperationException: Cannot bind parameter
or
a null reference exception (with parameter injection). Further into the error I am told that
Make sure the parameter Type is supported by the binding
which is the part that I am finding it difficult to resolve. I have looked at the available method calls on the config object available in WebJob.program but none seems to work. What is it I need to call so that I am correctly resolving my type when I am using a QueueTrigger or BlobTrigger?

Oracle ADF Unexpected Null Pointer Exception When accessing view objects in a seperate thread

I have a webservice in adf that treats requests, I use methods from a jar that run through view object iterators and so on.
In treating a request I call a method from the said jar that initializes a separate thread that manipulates and compares rows from view objects in that separate thread,
I am getting random exceptions like the following:
## Detail 0 ##
java.lang.NullPointerException
at oracle.jbo.server.ViewRowSetIteratorImpl.initViewRowSetIteratorImpl(ViewRowSetIteratorImpl.java:227)
at oracle.jbo.server.ViewRowSetIteratorImpl.(ViewRowSetIteratorImpl.java:176)
at oracle.jbo.server.ViewRowSetImpl.createNewRowSetIterator(ViewRowSetImpl.java:1434)
at oracle.jbo.server.ViewRowSetImpl.createViewRowSetIterator(ViewRowSetImpl.java:1485)
at oracle.jbo.server.ViewRowSetImpl.getDefaultRowSetIterator(ViewRowSetImpl.java:1704)
at oracle.jbo.server.ViewRowSetImpl.setRangeSize(ViewRowSetImpl.java:2936)
at oracle.jbo.server.ViewObjectImpl.doCreateViewLinkAccessorRS(ViewObjectImpl.java:16080)
at oracle.jbo.server.ViewObjectImpl.createViewLinkAccessorRS(ViewObjectImpl.java:16171)
at oracle.jbo.server.AssociationDefImpl.get(AssociationDefImpl.java:472)
at oracle.jbo.server.ViewAttributeDefImpl.get(ViewAttributeDefImpl.java:949)
at oracle.jbo.server.ViewRowStorage.getViewLinkAccessorResult(ViewRowStorage.java:1528)
at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1827)
at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1923)
at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)
and
## Detail 0 ##
java.lang.NullPointerException
at oracle.jbo.server.ViewRowImpl.getUseViewLogicGroupDef(ViewRowImpl.java:6078)
at oracle.jbo.server.ViewRowStorage.getViewAttributeDef(ViewRowStorage.java:1432)
at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1778)
at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1923)
at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)
and
Caused by: java.lang.NullPointerException
at oracle.jbo.server.ViewRowSetIteratorImpl.initViewRowSetIteratorImpl(ViewRowSetIteratorImpl.java:227)
at oracle.jbo.server.ViewRowSetIteratorImpl.(ViewRowSetIteratorImpl.java:176)
at oracle.jbo.server.ViewRowSetImpl.createNewRowSetIterator(ViewRowSetImpl.java:1434)
at oracle.jbo.server.ViewRowSetImpl.createViewRowSetIterator(ViewRowSetImpl.java:1485)
at oracle.jbo.server.ViewRowSetImpl.getDefaultRowSetIterator(ViewRowSetImpl.java:1704)
at oracle.jbo.server.ViewRowSetImpl.setRangeSize(ViewRowSetImpl.java:2936)
at oracle.jbo.server.ViewObjectImpl.doCreateViewLinkAccessorRS(ViewObjectImpl.java:16080)
at oracle.jbo.server.ViewObjectImpl.createViewLinkAccessorRS(ViewObjectImpl.java:16171)
at oracle.jbo.server.AssociationDefImpl.get(AssociationDefImpl.java:472)
at oracle.jbo.server.ViewAttributeDefImpl.get(ViewAttributeDefImpl.java:949)
at oracle.jbo.server.ViewRowStorage.getViewLinkAccessorResult(ViewRowStorage.java:1528)
at oracle.jbo.server.ViewRowStorage.getAttributeInternal(ViewRowStorage.java:1827)
at oracle.jbo.server.ViewRowImpl.getAttributeValue(ViewRowImpl.java:1923)
at oracle.jbo.server.ViewRowImpl.getAttributeInternal(ViewRowImpl.java:866)
The same method when it runs without the jar ( same code like in the jar but as a part of the same project ), it executes perfectly fine.
Could you please tell me why a NullPointerException is raised?
Thanks
You can not use the Business Components(ViewObject,Entities... etc) inside a thread.
There is no context (FacesContext cannot be initialized ).So you have to pass the ApplicationModule as a paramter to your method. But it will take a lot of time for processing
So the best way to access your data is to use CallableStatments PreparedStatments with Java Data Source connection.

ASM is not loading object in class retransform but working fine with usual transform

I am trying to load some object through bytecode modification using asm bytecode instrumentation library.
I am retransforming the classes using retransformClasses() method.
I am loading the objects in this way :
super.visitVarInsn(Opcodes.ALOAD, 0);
super.visitFieldInsn(Opcodes.GETFIELD, owner, name, desc);
super.visitMethodInsn(org.objectweb.asm.Opcodes.INVOKESTATIC,
"com/coolcoder/MyClass",
"objectCheckTest",
"(Ljava/lang/Object;)V");`
The problem is that I the objects are getting loaded using usual tranform() of ClassTransformer , but when I am using Attach API's retranformClasses() , these objects are not getting loaded . Strange thing is that , I am not getting any bytecode error either.
Am I doing something wrong ? or am I missing some intricate part regarding retransform ?
I was be able to solve the issue , though I do not know why it happened in the first place.
(1) I was loading the object only on PUTFIELD or PUTSTATIC opcodes, i.e , when the object value is being set.
(2) Just after bytecode modification the class is getting redefined , as a result of which the code snippet did not work.
(3) Next time when the class loaded due to redefinition , the object is already being set , so it will not be called again.
(4) Now , when I checked for GETFIELD or GETSTATIC opcodes , i.e when the object's value is being retrieved and I loaded it , I was able to view its details.
The same approach which I mentioned above is working fine in usual transformation (i.e running with premain).
Any idea on this erratic behaviour of redefinition ?
First, in manifest.mf file,Can-Retransform-Classes attribute should be true.
And your ClassFileTransformer instance should be add with the true value for parameter canRetransform in method addTransformer .
Here is another additional tips:
If the transformer throws an exception (which it doesn't catch), subsequent transformers will still be called and the load, redefine or retransform will still be attempted. Thus, throwing an exception has the same effect as returning null. To prevent unexpected behavior when unchecked exceptions are generated in transformer code, a transformer can catch Throwable. If the transformer believes the classFileBuffer does not represent a validly formatted class file, it should throw an IllegalClassFormatException; while this has the same effect as returning null. it facilitates the logging or debugging of format corruptions.
from java api docs
So, there maybe some uncatched exception which will be just ignored by the jvm arised.
You can put a try..catch
Please forgive my poor English ...

Resources