Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jaxp issue #12799

Closed
dufoli opened this issue Oct 19, 2020 · 11 comments
Closed

jaxp issue #12799

dufoli opened this issue Oct 19, 2020 · 11 comments
Labels
kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.

Comments

@dufoli
Copy link
Contributor

dufoli commented Oct 19, 2020

The code is inside cxf extension for quarkus. I try to fix the native support. But I am stuck on an issue with jaxp.
I have added a substitution to debug and my schema seems right but the namespace is not returned.

Utilisation of JAXP in native with Document()
Code executed
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());
2020-10-19 14:19:53,770 INFO  [org.apa.cxf.end.dyn.TypeClassInitializer] (executor-thread-1) DOCUMENT :<?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" elementFormDefault="qualified" 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>
2020-10-19 14:19:53,770 INFO  [org.apa.cxf.end.dyn.TypeClassInitializer] (executor-thread-1) DOCUMENT element :[schema: null]
2020-10-19 14:19:53,771 INFO  [org.apa.cxf.end.dyn.TypeClassInitializer] (executor-thread-1) DOCUMENT namespace :null
@dufoli dufoli added the kind/bug Something isn't working label Oct 19, 2020
@dufoli
Copy link
Contributor Author

dufoli commented Oct 19, 2020

I have added many class which seems loaded by reflection in cxf or in jab jaxp but still failing.

reflectiveItems.produce(new ReflectiveClassBuildItem(true, true,
"com.sun.org.apache.xpath.internal.domapi.XPathEvaluatorImpl",
"com.sun.xml.internal.stream.events.XMLEventFactoryImpl",
"com.sun.xml.internal.bind.marshaller.NoEscapeHandler",
"com.sun.xml.internal.bind.marshaller.MinimumEscapeHandler",
"com.sun.xml.bind.marshaller.NoEscapeHandler",
"com.sun.xml.bind.marshaller.MinimumEscapeHandler",
"org.apache.cxf.common.jaxb.NamespaceMapper",
"org.apache.cxf.jaxb.NamespaceMapper",
"com.sun.tools.internal.xjc.api.XJC",
"com.sun.tools.xjc.api.XJC",
"com.sun.xml.internal.bind.api.JAXBRIContext",
"com.sun.xml.bind.api.JAXBRIContext",
"com.sun.xml.bind.v2.runtime.LeafBeanInfoImpl",
"com.sun.xml.bind.v2.runtime.ArrayBeanInfoImpl",
"com.sun.xml.bind.v2.runtime.ValueListBeanInfoImpl",
"com.sun.xml.bind.v2.runtime.AnyTypeBeanInfo",
"com.sun.xml.bind.v2.runtime.JaxBeanInfo",
"com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl",
"com.sun.xml.bind.v2.runtime.CompositeStructureBeanInfo",
"com.sun.xml.bind.v2.runtime.ElementBeanInfoImpl",
"com.sun.xml.bind.v2.runtime.MarshallerImpl",
"com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl",
"com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl",
"com.sun.org.apache.xerces.internal.dom.DOMXSImplementationSourceImpl",
"com.sun.xml.internal.bind.v2.ContextFactory",
"com.sun.xml.bind.v2.ContextFactory",
"com.sun.xml.bind.v2.runtime.BridgeContextImpl",
"com.sun.xml.bind.v2.runtime.JAXBContextImpl",
"com.sun.xml.bind.subclassReplacements",
"com.sun.xml.bind.defaultNamespaceRemap",
"com.sun.xml.bind.c14n",
"com.sun.xml.bind.v2.model.annotation.RuntimeAnnotationReader",
"com.sun.xml.bind.XmlAccessorFactory",
"com.sun.xml.bind.treatEverythingNillable",
"com.sun.xml.bind.retainReferenceToInfo",
"com.sun.xml.internal.bind.subclassReplacements",
"com.sun.xml.internal.bind.defaultNamespaceRemap",
"com.sun.xml.internal.bind.c14n",
"com.sun.xml.internal.bind.v2.model.annotation.RuntimeAnnotationReader",
"com.sun.xml.internal.bind.XmlAccessorFactory",
"com.sun.xml.internal.bind.treatEverythingNillable",
"com.sun.xml.bind.marshaller.CharacterEscapeHandler",
"com.sun.xml.internal.bind.marshaller.CharacterEscapeHandler",
"com.sun.org.apache.xerces.internal.dom.ElementNSImpl",
"com.sun.xml.internal.bind.retainReferenceToInfo"

@Postremus
Copy link
Member

Have you tried adding a dependency to quarkus-jaxp? as far as I can see, that extensions should be native ready already.
https://github.com/quarkusio/quarkus/tree/master/extensions/jaxp

@dufoli
Copy link
Contributor Author

dufoli commented Oct 19, 2020

yes I have already added it ;-)

@dufoli
Copy link
Contributor Author

dufoli commented Oct 19, 2020

the whole project is in https://github.com/dufoli/quarkus-cxf

@dufoli
Copy link
Contributor Author

dufoli commented Oct 19, 2020

I have nother exception upper:
2020-10-19 14:19:53,767 FINE [com.sun.xml.bin.v2.sch.XmlSchemaGenerator] (executor-thread-1) Writing XML Schema for com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator@7fcae7477c78[http://cxf.it.quarkus.io/=com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator$Namespace@7fcae7477ef8]: com.sun.xml.bind.v2.util.StackRecorder
at com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write(XmlSchemaGenerator.java:425)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.generateSchema(JAXBContextImpl.java:790)
at org.apache.cxf.common.jaxb.JAXBUtils.generateJaxbSchemas(JAXBUtils.java:813)
at org.apache.cxf.jaxb.JAXBDataBinding.generateJaxbSchemas(JAXBDataBinding.java:467)
at org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:384)
at org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)

@Postremus
Copy link
Member

@dufoli If I understand correctly, the problem is that d.getDocumentElement().getNamespaceURI() returns null, even though the namespace is set using xmlns:xs="http://www.w3.org/2001/XMLSchema".

I am myself not that familiar with jaxp / jaxb apis, but managed to find a place a bit earlier where the nsUri is returned as blank:
https://github.com/eclipse-ee4j/jaxb-ri/blob/master/jaxb-ri/txw/runtime/src/main/java/com/sun/xml/txw2/TXW.java#L59

(localname is schema, so that is the right tag).

I started a bit of cleanup in https://github.com/Postremus/quarkus-cxf/commits/try-fix-native-tests.

@dufoli
Copy link
Contributor Author

dufoli commented Oct 20, 2020

@dufoli
Copy link
Contributor Author

dufoli commented Oct 24, 2020

OK, I have gone further...
issue is located in
com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.write
com.sun.xml.bind.v2.schemagen.XmlSchemaGenerator.Namespace.writeTo
com.sun.xml.bind.v2.schemagen.xmlschema.Schema._namespace
indeed com.sun.xml.bind.v2.schemagen.xmlschema.Schema implement TypedXmlWriter which is a proxy interface

com.sun.xml.txw2.ContainerElement handle the invoke method
I have declared TypedXmlWriter as proxy interface and all inherited interface too but it is still not enough.

@dufoli
Copy link
Contributor Author

dufoli commented Oct 25, 2020

ok got the point. Indeed, I end exactly to the same place. So XMLNamespace target (package) must be loaded.
for (AnnotationInstance xmlNamespaceInstance : index.getAnnotations(DotName.createSimple("com.sun.xml.txw2.annotation.XmlNamespace"))) {
reflectiveClass.produce(new ReflectiveClassBuildItem(false, false, xmlNamespaceInstance.target().asClass().name().toString()));
}

@dufoli
Copy link
Contributor Author

dufoli commented Nov 20, 2020

I have sent a pull request for that and few other things:
#13408

@geoand
Copy link
Contributor

geoand commented Sep 13, 2024

Is this still an issue?

@geoand geoand added the triage/needs-feedback We are waiting for feedback. label Sep 13, 2024
@dufoli dufoli closed this as completed Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working triage/needs-feedback We are waiting for feedback.
Projects
None yet
Development

No branches or pull requests

3 participants