phax / phoss-smp

phoss SMP - a Peppol and OASIS BDXR SMP Server, CEF eDelivery compliant
132 stars 37 forks source link

Jaxb exception on RegistrationHookImpl.createServiceGroup #18

Closed elfogre closed 8 years ago

elfogre commented 8 years ago

Hello!

I use some of your libraries for a smp server. I have a problem when I try to register a service group, because there is a element name in xml namespace that has more than one mapping. It is "{http://busdox.org/transport/identifiers/1.0/}ParticipantIdentifier" and is defined in:

com.helger.peppol.identifier.ObjectFactory.createParticipantIdentifier (peppolCommons 4.3.4) com.helger.peppol.smlclient.participant.ObjectFactory.createParticipantIdentifier (peppol-sml-client 4.3.4)

As far I can see, your peppol-smp-server-library is using both dependencies and use RegistrationHookImpl to register serviceGroups in SML. So how did you avoid the problem with multiple mappings in xml??

phax commented 8 years ago

Are you using Wildfly in production? There are known issues with this OSGI container. A workaround is described in https://github.com/phax/peppol-smp-server/wiki/WildFly hth

elfogre commented 8 years ago

No, I'm using Tomcat. But I don't run your server as is, we have develope a different smp server that uses com.helger:peppol-sml-client:jar:4.3.4 and com.helger:peppol-commons:jar:4.3.4

I can see that your peppol-smp-server-library have also both dependencies, you don't have a problem with jaxb and the multiple definition of "{http://busdox.org/transport/identifiers/1.0/}ParticipantIdentifier" ? Because it is defined in both packages as I said in the previous message.

By the way, and unrelated to the issue, we have changed the database model. We have deleted ownership table (relation 1-1 with serviceGroup), we have merge servicemetadata and servicemetadata-redirection, and change PK of tables to incremental IDs to avoid to have that big foreign key on AP table. If you see as an improvement I could send our datamodel.

phax commented 8 years ago

Hi! The problem occurs only if you are using JAXBContext.newInstance with multiple package names separated by String. In my implementation it is ensured to call that only with a single package, but I know that Apache CXF (used in Wildfly) uses the different initialization routine that causes problems.

Please provide me with your stacktrace so that I can tell you more.

Concerning the new DB scheme: I left the old scheme as it was for compatibility to the CIPA SMP server (which is the reference implementation - but is not as advanced as mine ;-) ). I added the XML data model because it is much simpler to handle in operations and does not require an additional tool to be running. But if you send me your data model I will investigate it, and maybe we can create a separate subproject like "peppol-smp-server-sql" but "peppol-smp-server-sql2" which can than be integrated into the main peppol-smp-server. Would that be of interest for your?

// Philip

elfogre commented 8 years ago

Maybe that's the problem, that I'm not using custom version of jaxb. I'm using Apache CXF and jaxb for webservices. I also attached our model classes.

The stacktrace:

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions The element name {http://busdox.org/transport/identifiers/1.0/}ParticipantIdentifier has more than one mapping. this problem is related to the following location: at public javax.xml.bind.JAXBElement com.helger.peppol.identifier.ObjectFactory.createParticipantIdentifier(com.helger.peppol.identifier.ParticipantIdentifierType) at com.helger.peppol.identifier.ObjectFactory this problem is related to the following location: at public javax.xml.bind.JAXBElement com.helger.peppol.smlclient.participant.ObjectFactory.createParticipantIdentifier(com.helger.peppol.identifier.ParticipantIdentifierType) at com.helger.peppol.smlclient.participant.ObjectFactory

com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:472)
com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:302)
com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1140)
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:154)
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:121)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:483)
javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:247)
javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:234)
javax.xml.bind.ContextFinder.find(ContextFinder.java:441)
javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:641)
org.apache.cxf.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:268)
org.apache.cxf.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:267)
java.security.AccessController.doPrivileged(Native Method)
org.apache.cxf.jaxb.JAXBContextCache.createContext(JAXBContextCache.java:266)
org.apache.cxf.jaxb.JAXBContextCache.getCachedContextAndSchemas(JAXBContextCache.java:172)
org.apache.cxf.jaxb.JAXBDataBinding.createJAXBContextAndSchemas(JAXBDataBinding.java:424)
org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:292)
org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:401)
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:506)
org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:242)
org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:205)
org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:155)
org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:155)
org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:465)
org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:332)
org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:319)
javax.xml.ws.Service.getPort(Service.java:119)
com.helger.peppol.smlclient.participant.ManageBusinessIdentifierService.getManageBusinessIdentifierServicePort(ManageBusinessIdentifierService.java:54)
com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller.createWSPort(ManageParticipantIdentifierServiceCaller.java:123)
com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller.create(ManageParticipantIdentifierServiceCaller.java:192)
com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller.create(ManageParticipantIdentifierServiceCaller.java:157)
com.edicom.edicomnet.asxserver.peppolServices.smlhook.impl.RegistrationHookImpl.createServiceGroup(RegistrationHookImpl.java:62)

model.zip

phax commented 8 years ago

That is exactly the same problem we had with Wildfly:

org.apache.cxf.jaxb.JAXBContextCache$2.run(JAXBContextCache.java:268)

-> it calls the JAXBContext initialization with multiple packages.

What I did was to add the following dependencies to peppol-smp-serever-library so that it works:

        <dependency>
          <groupId>javax.activation</groupId>
          <artifactId>activation</artifactId>
          <version>1.1.1</version>
        </dependency>
        <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
          <version>2.2.11</version>
        </dependency>
        <dependency>
          <groupId>com.sun.xml.ws</groupId>
          <artifactId>jaxws-rt</artifactId>
          <version>2.2.10</version>
        </dependency>

-> it forces the use of JAXWS and not CXF.

elfogre commented 8 years ago

Finally I got it working.

I have needed to add a file: //src/main/resources/META-INF/services/javax.xml.ws.spi.Provider to define what jax-ws implementation use (I can't delete cxf reference in my pom). I select com.sun.xml.ws.spi.ProviderImpl and now it works great.

Thank you very much!

phax commented 8 years ago

Thanks for the hint. You added this to your webapp project or to a library?

phax commented 8 years ago

Would you please be so kind a test whether it works with com.sun.xml.internal.ws.spi.ProviderImpl (the version contained in the runtime) as well? Thanks for your effort!

elfogre commented 8 years ago

I've merged SMP Server to our AS2 Server implementation so I've added on a webapp project. I've tested with com.sun.xml.internal.ws.spi.ProviderImpl but it has a problem (JDK8). A class that not implements the expected interface.

java.lang.RuntimeException: MASM0015: Class [ com.sun.xml.ws.assembler.jaxws.HandlerTubeFactory ] does not implement [ com.sun.xml.internal.ws.assembler.dev.TubeFactory ] interface
com.sun.xml.internal.ws.assembler.TubeCreator.<init>(TubeCreator.java:63)
com.sun.xml.internal.ws.assembler.TubelineAssemblyController.initializeTubeCreators(TubelineAssemblyController.java:116)
com.sun.xml.internal.ws.assembler.TubelineAssemblyController.getTubeCreators(TubelineAssemblyController.java:79)
com.sun.xml.internal.ws.assembler.MetroTubelineAssembler.createClient(MetroTubelineAssembler.java:103)
com.sun.xml.internal.ws.client.Stub.createPipeline(Stub.java:328)
com.sun.xml.internal.ws.client.Stub.<init>(Stub.java:295)
com.sun.xml.internal.ws.client.Stub.<init>(Stub.java:228)
com.sun.xml.internal.ws.client.Stub.<init>(Stub.java:243)
com.sun.xml.internal.ws.client.sei.SEIStub.<init>(SEIStub.java:84)
com.sun.xml.internal.ws.client.WSServiceDelegate.getStubHandler(WSServiceDelegate.java:814)
com.sun.xml.internal.ws.client.WSServiceDelegate.createEndpointIFBaseProxy(WSServiceDelegate.java:803)
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:436)
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:404)
com.sun.xml.internal.ws.client.WSServiceDelegate.getPort(WSServiceDelegate.java:386)
javax.xml.ws.Service.getPort(Service.java:119)
com.helger.peppol.smlclient.participant.ManageBusinessIdentifierService.getManageBusinessIdentifierServicePort(ManageBusinessIdentifierService.java:54)
com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller.createWSPort(ManageParticipantIdentifierServiceCaller.java:123)
com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller.create(ManageParticipantIdentifierServiceCaller.java:192)
com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller.create(ManageParticipantIdentifierServiceCaller.java:157)
com.edicom.edicomnet.asxserver.peppolServices.smlhook.impl.RegistrationHookImpl.createServiceGroup(RegistrationHookImpl.java:62)
phax commented 8 years ago

Thanks for the information. That means I wil add your information to the Wiki and will refer to it, if others have a problem. Btw. did you add the 3 dependencies I've mentioned above or did you have them already included? Big thanks for your help!

elfogre commented 8 years ago

I have added it.

Now I can connect to SMK server, and there's no problem with TLS. But it's not working, maybe a problem with the SMK.

My request is:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <CreateParticipantIdentifier xmlns="http://busdox.org/serviceMetadata/locator/1.0/" xmlns:ns2="http://busdox.org/transport/identifiers/1.0/">
            <ServiceMetadataPublisherID>SMP2000000195</ServiceMetadataPublisherID>
            <ns2:ParticipantIdentifier scheme="iso6523-actorid-upis">9906:edicomtestes</ns2:ParticipantIdentifier>
        </CreateParticipantIdentifier>
    </S:Body>
</S:Envelope>

But the server instead of return a xml with ok or error is returning:

HTTP/1.1 200 OK
Date: Thu, 25 Feb 2016 18:11:09 GMT
Transfer-Encoding: chunked
Content-Type: text/html
Server: Europa
Connection: Keep-Alive

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <title>CIPA BDMSL</title>
</head>
<body>
<h1>CIPA eDelivery BDMSL is waiting for you</h1>
<ul>
    <li>Version: 3.2.0-SNAPSHOT</li>
    <li><a href="listDNS">List DNS</a></li>
    <li><a href="services">Services</a></li>
</ul>
</body>
</html>

Do you have an idea about it? I start to dig https://joinup.ec.europa.eu/svn/cipaedelivery/tags/3.2.0-alpha-1/sml/cipa-sml-server-library/ and it uses some of your libraries, so maybe you have some clues

phax commented 8 years ago

Did you add the /manageparticipantidentifier WS endpoint to your URL?

elfogre commented 8 years ago

That's it. When I reviewed the code at https://joinup.ec.europa.eu/svn/cipaedelivery/tags/3.2.0-alpha-1/sml/cipa-sml-server-library/src/main/java/eu/europa/ec/cipa/sml/server/management/bi/ManageParticipantIdentifierImpl.java I get the problem about the path (I also saw that you had written it, great job!).

Finally it's working http://peppol.helger.com/public/menuitem-tools-participant?idschemepredef=9906&idscheme=9906&idvalue=edicomtestes&sml=digittest&action=perform

Thank you very much for your great support.

phax commented 8 years ago

It was a pleasure :) Happy PEPPOLing and spread the word about my SMP :)

In case I would add your data model to this SMP server, would you use it than?