You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by olivier dufour <ol...@gmail.com> on 2020/10/22 11:40:07 UTC

CXF issue with integration in quarkus/ grallvm in native

  Hello,

I am writing the extension on quarkus for cxf. I have read a lot of the
code on github cxf and fixed a lot of issues but I still failed with native
compilation.
I am not sure if it comes from jaxp or jaxb or cxf reflection. Anyway, an
exception is thrown from cxf.

I have an exception:

*java.lang.RuntimeException: Invalid schema document passed to
AbstractDataBinding.addSchemaDocument, not in W3C schema namespace: schema
at *
org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:111)
at
org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:68)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:408)
at
org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
at
org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:469)
at
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:693)

Analyze show that in AbstractDataBinding.addSchemaDocument the Document
contain:
<?xml version="1.0" encoding="UTF-8" standalone="no"?><schema xmlns:tns="
http://cxf.it.quarkus.io/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://cxf.it.quarkus.io/" version="1.0">
<element name="reply" type="tns:reply"/>
<element name="replyResponse" type="tns:replyResponse"/>
<complexType name="reply"><sequence><element minOccurs="0" name="text"
type="xs:string"/></sequence></complexType>
<complexType name="replyResponse"><sequence><element minOccurs="0"
name="return" type="xs:string"/></sequence></complexType>
</schema>

Document.getDocumentElement() return a node Schema
but .getNamespaceURI() return null.

DOMSource domSource = new DOMSource(d);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = null;
try {
    transformer = tf.newTransformer();
    transformer.transform(domSource, result);
} catch (Exception e) {
}

Logger LOG = LogUtils.getL7dLogger(org.apache.cxf.endpoint.dynamic.TypeClassInitializer.class);
LOG.info("DOCUMENT :"+ writer.toString());
LOG.info("DOCUMENT element :"+ d.getDocumentElement().toString());
LOG.info("DOCUMENT namespace :"+ d.getDocumentElement().getNamespaceURI());

return:
DOCUMENT : [previous schema xml]
DOCUMENT element :[schema: null]
DOCUMENT namespace :null

So, my question is:
- is my schema badly valid ?
- What is class which parse Document to produce the namespaceUri ?

I was thinking the issue may come from package-info generation but it seems
oki.
Here is class decompilation from intelij:

package io.quarkus.it.cxf.jaxws_asm;

@javax.xml.bind.annotation.XmlSchema(namespace =
"http://cxf.it.quarkus.io/", elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
interface $$package-info /* Real name is 'package-info' */ {
}


Here you have limitation of Graal in native:
https://www.graalvm.org/reference-manual/native-image/Limitations/

First, here is my work:
https://github.com/dufoli/quarkus-cxf

2 classes are very important:
https://github.com/dufoli/quarkus-cxf/blob/master/deployment/src/main/java/io/quarkus/cxf/deployment/QuarkusCxfProcessor.java
this one lists native documents and classname which need to been reflected.

https://github.com/dufoli/quarkus-cxf/blob/master/runtime/src/main/java/io/quarkus/cxf/graal/CXFSubstitutions.java
This one does substitution to remove class generation in CXF.

Cheers,
Olivier

Re: CXF issue with integration in quarkus/ grallvm in native

Posted by Andriy Redko <dr...@gmail.com>.
Hi Olivier,

We have an issue in the tracker [1] regarding GraalVM, the CXF team 
have not invested much into GraalVM's native image support just yet but it
seems like it becomes increasingly more important. Would you mind please
to add the details to the existing ticket so we could understand the problems
and scope better. Which version of GraalVM and Java (8 or 11) are you using?
Thank you.


[1] https://issues.apache.org/jira/browse/CXF-8340

Thursday, October 22, 2020, 7:40:07 AM, you wrote:

od>   Hello,

od> I am writing the extension on quarkus for cxf. I have read a lot of the
od> code on github cxf and fixed a lot of issues but I still failed with native
od> compilation.
od> I am not sure if it comes from jaxp or jaxb or cxf reflection. Anyway, an
od> exception is thrown from cxf.

od> I have an exception:

od> *java.lang.RuntimeException: Invalid schema document passed to
od> AbstractDataBinding.addSchemaDocument, not in W3C schema namespace: schema
od> at *
od> org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:111)
od> at
od> org.apache.cxf.databinding.AbstractDataBinding.addSchemaDocument(AbstractDataBinding.java:68)
od> at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:408)
od> at
od> org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
od> at
od> org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:469)
od> at
od> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:693)

od> Analyze show that in AbstractDataBinding.addSchemaDocument the Document
od> contain:
od> <?xml version="1.0" encoding="UTF-8" standalone="no"?><schema xmlns:tns="
od> http://cxf.it.quarkus.io/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
od> targetNamespace="http://cxf.it.quarkus.io/" version="1.0">
od> <element name="reply" type="tns:reply"/>
od> <element name="replyResponse" type="tns:replyResponse"/>
od> <complexType name="reply"><sequence><element minOccurs="0" name="text"
type="xs:string"/>></sequence></complexType>
od> <complexType name="replyResponse"><sequence><element minOccurs="0"
od> name="return" type="xs:string"/></sequence></complexType>
od> </schema>

od> Document.getDocumentElement() return a node Schema
od> but .getNamespaceURI() return null.

od> DOMSource domSource = new DOMSource(d);
od> StringWriter writer = new StringWriter();
od> StreamResult result = new StreamResult(writer);
od> TransformerFactory tf = TransformerFactory.newInstance();
od> Transformer transformer = null;
od> try {
od>     transformer = tf.newTransformer();
od>     transformer.transform(domSource, result);
od> } catch (Exception e) {
od> }

od> Logger LOG = LogUtils.getL7dLogger(org.apache.cxf.endpoint.dynamic.TypeClassInitializer.class);
od> LOG.info("DOCUMENT :"+ writer.toString());
od> LOG.info("DOCUMENT element :"+ d.getDocumentElement().toString());
od> LOG.info("DOCUMENT namespace :"+ d.getDocumentElement().getNamespaceURI());

od> return:
od> DOCUMENT : [previous schema xml]
od> DOCUMENT element :[schema: null]
od> DOCUMENT namespace :null

od> So, my question is:
od> - is my schema badly valid ?
od> - What is class which parse Document to produce the namespaceUri ?

od> I was thinking the issue may come from package-info generation but it seems
od> oki.
od> Here is class decompilation from intelij:

od> package io.quarkus.it.cxf.jaxws_asm;

od> @javax.xml.bind.annotation.XmlSchema(namespace =
od> "http://cxf.it.quarkus.io/", elementFormDefault =
od> javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
od> interface $$package-info /* Real name is 'package-info' */ {
od> }


od> Here you have limitation of Graal in native:
od> https://www.graalvm.org/reference-manual/native-image/Limitations/

od> First, here is my work:
od> https://github.com/dufoli/quarkus-cxf

od> 2 classes are very important:
od> https://github.com/dufoli/quarkus-cxf/blob/master/deployment/src/main/java/io/quarkus/cxf/deployment/QuarkusCxfProcessor.java
od> this one lists native documents and classname which need to been reflected.

od> https://github.com/dufoli/quarkus-cxf/blob/master/runtime/src/main/java/io/quarkus/cxf/graal/CXFSubstitutions.java
od> This one does substitution to remove class generation in CXF.

od> Cheers,
od> Olivier