Scope request cxf jaxrs - scope

I would like to ask you a question about the scoping of the beans with cxf.
According to the documentation all the bean will in scope singleton. However I would like to have them in scope request.
In the doc here http://cxf.apache.org/docs/jaxrs-services-configuration.html
I found:
When service classes and providers are registered this way, the default life-cycle is 'singleton'. You can override it by setting a "jaxrs.scope" parameter with the value of 'prototype' (equivalent to per-request).
I tried thousand of stuff and I was not able to make them working:
Here is my web xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>CxfRestService</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/beans.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/resource/log4j.properties</param-value>
</context-param>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<init-param>
<param-name>jaxrs.scope</param-name>
<param-value>request</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
</web-app>
I did a simple test with this:
#Path("/")
#WebService(name = "profile", targetNamespace = "")
#Named
public class ProfileCXFService {
private String thisIsAValue;
/**
* Create a profile
*/
#POST
#Path("")
#Produces({ MediaType.APPLICATION_JSON })
#Consumes({ MediaType.APPLICATION_JSON })
public Response createProfile(Profile profile){
if(thisIsAValue == null){
thisIsAValue = "toto";
} else{
return Response.serverError().entity("NOOOOOO").build();
}
return Response.ok().entity("YESSSSS").build();
}
The first call is YESSS and the second NOOOOO.
I would like to have all my beans as request. Were can I find a common way to configure this.
In fact I do not have problem with singleton as the only fields I have are services which are as well singleton and the only moment where I need to use fields specific to the request I am doing a new MyObject. However I heard that Singleton can cause latency if the traffic grows on the server.
Do you have any idea of what can I do?
Thanks a lot in advance and best regards
Geoffrey

So basically found the solution:
In your beans.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">
<jaxrs:server id="profile" address="/profile">
<jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider" />
</jaxrs:providers>
<jaxrs:serviceBeans>
<ref bean="ProfileCXFServiceImpl"/>
</jaxrs:serviceBeans>
<jaxrs:extensionMappings>
<entry key="xml" value="application/xml" />
<entry key="json" value="application/json" />
</jaxrs:extensionMappings>
</jaxrs:server>
<bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"/>
<bean id="ProfileCXFServiceImpl" class="com.project.cxfrestservice.ProfileCXFServiceImpl" scope="prototype"><aop:scoped-proxy /></bean>
</beans>
And Voila!!!!

Related

Richfaces 3 on Payara 5: Request prolog cannot be read

I'm attempting to move an existing Richfaces 3.3.4 / JSF 1.2 application off Glassfish 3 (for a number of reasons) onto Payara 5.192. The application runs fine with a couple exceptions, the primary problem being rich:fileUpload doesn't work.
I added multipart-config to web.xml, but that didn't resolve the problem:
<context-param>
<param-name>javax.faces.DISABLE_FACELET_JSF_VIEWHANDLER</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<multipart-config>
<max-file-size>33554432</max-file-size>
<max-request-size>335544320</max-request-size>
</multipart-config>
</servlet>
Here is the error:
org.ajax4jsf.exception.FileUploadException: IO Error parsing multipart request
at org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:388)
at org.richfaces.component.FileUploadPhaselistener.beforePhase(FileUploadPhaselistener.java:63)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:201)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:74)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:109)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1628)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:339)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:367)
at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:251)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:209)
at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:822)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:688)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:527)
at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:496)
at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:378)
at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:507)
at org.apache.catalina.core.StandardHostValve.dispatchToErrorPage(StandardHostValve.java:701)
at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:385)
at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:319)
at org.apache.catalina.core.StandardHostValve.postInvoke(StandardHostValve.java:217)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:373)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:520)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:217)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:182)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:156)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:218)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:95)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:260)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:177)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:109)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:88)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:53)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:524)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:89)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:94)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:33)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:114)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Request prolog cannot be read
at org.ajax4jsf.request.MultipartRequest.readProlog(MultipartRequest.java:333)
at org.ajax4jsf.request.MultipartRequest.initialize(MultipartRequest.java:369)
at org.ajax4jsf.request.MultipartRequest.parseRequest(MultipartRequest.java:379)
... 47 more¡ëôwÍ$

Hazelcast + Spring(xml config) + hz map store error

Using hazelcast 3.8.2 (hazelcast-all jar) + IMap+ mapstore + Spring 4.3.8 (xml config). In Spring xml config, 'hz:map-store' throws an error saying:
17:49:40.519 ERROR [main] org.springframework.test.context.TestContextManager – Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener#1868ed54] to prepare test instance [com.twc.ctg.ecp.service.dataaccess.maps.EntitlementMapTest#1b9ea3e3] org.xml.sax.SAXParseException: cvc-complex-type.2.1: Element 'hz:map' must have no character or element information item [children], because the type's content type is empty.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203) ~[?:1.8.0_101]
What am I doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">
<hz:hazelcast id="hzInstance1">
<hz:config>
...
</hz:config>
</hz:hazelcast>
<hz:client id="hzInstance1Client">
...
</hz:client>
<hz:map id="entitlementCache" instance-ref="hzInstance1" name="entitlement">
<hz:map-store enabled="true" implementation="linearEntitlementMapStore"
write-delay-seconds="30000"/>
</hz:map>
<bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore" />
</beans>
You need to configure MapStore in <hz:config> section.
Correct config should look like this
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:hz="http://www.hazelcast.com/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.hazelcast.com/schema/spring
http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">
<hz:hazelcast id="hzInstance1">
<hz:config>
<hz:map name="entitlement">
<hz:map-store enabled="true" implementation="linearEntitlementMapStore"
write-delay-seconds="30000"/>
<!-- ... -->
</hz:map>
</hz:config>
</hz:hazelcast>
<hz:client id="hzInstance1Client">
<!--... -->
</hz:client>
<bean id="linearEntitlementMapStore" class="com.twc.ctg.ecp.service.dataaccess.maps.LinearEntitlementMapStore"/>

OC 2.0 Fedex shipping method not working

We tried to Fedex shipping method in our opencart website.
It Display the "Error" text.
ERRORERRORcrs691The PurposeOfShipmentType is null, empty or invalid.
The PurposeOfShipmentType is null, empty or invalid.crs1000
Use this xml
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://fedex.com/ws/rate/v13">
<SOAP-ENV:Body>
<RateRequest>
<WebAuthenticationDetail>
<UserCredential>
<Key>XXXXX</Key>
<Password>XXXXX</Password>
</UserCredential>
</WebAuthenticationDetail>
<ClientDetail>
<AccountNumber>XXXXX</AccountNumber>
<MeterNumber>XXXXX</MeterNumber>
</ClientDetail>
<TransactionDetail>
<CustomerTransactionId>MY-RATE-REQUEST</CustomerTransactionId>
</TransactionDetail>
<Version>
<ServiceId>crs</ServiceId>
<Major>13</Major>
<Intermediate>0</Intermediate>
<Minor>0</Minor>
</Version>
<ReturnTransitAndCommit>true</ReturnTransitAndCommit>
<RequestedShipment>
<ShipTimestamp>2012-10-09T14:28:07.9489435+05:30</ShipTimestamp>
<DropoffType>REGULAR_PICKUP</DropoffType>
<PackagingType>YOUR_PACKAGING</PackagingType>
<Shipper>
<Address>
<StreetLines>Sardarnagar Main Road, Rajkot</StreetLines>
<City>Rajkot</City>
<StateOrProvinceCode>GJ</StateOrProvinceCode>
<PostalCode>360001</PostalCode>
<CountryCode>IN</CountryCode>
</Address>
</Shipper>
<Recipient>
<Address>
<StreetLines>Radhekrishna App. Main Road , Rajkot</StreetLines>
<City>Bhuj</City>
<StateOrProvinceCode>GJ</StateOrProvinceCode>
<PostalCode>370001</PostalCode>
<CountryCode>IN</CountryCode>
</Address>
</Recipient>
<ShippingChargesPayment>
<PaymentType>SENDER</PaymentType>
<Payor>
<ResponsibleParty>
<AccountNumber>XXXXX</AccountNumber>
</ResponsibleParty>
</Payor>
</ShippingChargesPayment>
<CustomsClearanceDetail>
<DutiesPayment>
<PaymentType>RECIPIENT</PaymentType>
</DutiesPayment>
<DocumentContent>NON_DOCUMENTS</DocumentContent>
<CustomsValue>
<Currency>INR</Currency>
<Amount>299.000000</Amount>
</CustomsValue>
<CommercialInvoice>
<Purpose>NOT_SOLD</Purpose>
</CommercialInvoice>
</CustomsClearanceDetail>
<RateRequestTypes>ACCOUNT</RateRequestTypes>
<RateRequestTypes>LIST</RateRequestTypes>
<PackageCount>1</PackageCount>
<RequestedPackageLineItems>
<SequenceNumber>1</SequenceNumber>
<GroupPackageCount>1</GroupPackageCount>
<Weight>
<Units>KG</Units>
<Value>1</Value>
</Weight>
</RequestedPackageLineItems>
</RequestedShipment>
</RateRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Ajax4jsf in JSF 2.1 myfaces

Our team is upgrading my very big Webapplication from Myfaces-1.1.5 to Myfaces-2.1.9
and from Tomahawk-1.1.3 to Tomahawk-1.1.14.
Problem is my current application using ajax4jsf filter..
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
<filter>
<filter-name>ajax4jsf</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
I have changed the value of context param as follows
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>org.apache.myfaces.view.facelets.FaceletViewHandler</param-value>
</context-param>
Because of this I am getting exception. I have read at multiple places that with JSF 2.1, ajax4jsf filter is not required but could you please tell what should I use and how...
Feb 26, 2015 4:45:48 PM org.apache.myfaces.view.facelets.compiler.TagLibraryConf
ig loadImplicit
SEVERE: Error Loading Library: jar:file:/C:/Projects/eMessaging/EM1.4M6-LibUpgra
de_new/web/target/emessaging-webapp-1.4M6/WEB-INF/lib/ajax4jsf-1.0.6.jar!/META-I
NF/a4j.taglib.xml
java.io.IOException: Error parsing [jar:file:/C:/Projects/eMessaging/EM1.4M6-Lib
Upgrade_new/web/target/emessaging-webapp-1.4M6/WEB-INF/lib/ajax4jsf-1.0.6.jar!/M
ETA-INF/a4j.taglib.xml]:
at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.create(Tag
LibraryConfig.java:805)
at org.apache.myfaces.view.facelets.compiler.TagLibraryConfig.loadImplic
it(TagLibraryConfig.java:839)
at org.apache.myfaces.view.facelets.compiler.Compiler.initialize(Compile
r.java:101)
at org.apache.myfaces.view.facelets.compiler.Compiler.compile(Compiler.j
ava:126)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory._createFa
celet(DefaultFaceletFactory.java:300)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.access$00
0(DefaultFaceletFactory.java:53)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory$1.newInst
ance(DefaultFaceletFactory.java:114)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory$1.newInst
ance(DefaultFaceletFactory.java:111)
at org.apache.myfaces.view.facelets.impl.FaceletCacheImpl.getFacelet(Fac
eletCacheImpl.java:83)
at org.apache.myfaces.view.facelets.impl.FaceletCacheImpl.getFacelet(Fac
eletCacheImpl.java:50)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacele
t(DefaultFaceletFactory.java:199)
at org.apache.myfaces.view.facelets.impl.DefaultFaceletFactory.getFacele
t(DefaultFaceletFactory.java:182)
at com.g1.emessaging.ui.EmsgFaceletViewHandler.buildView(EmsgFaceletView
Handler.java:550)
at com.g1.emessaging.ui.EmsgFaceletViewHandler.renderView(EmsgFaceletVie
wHandler.java:607)
at org.ajax4jsf.framework.ViewHandlerWrapper.renderView(ViewHandlerWrapp
er.java:101)
at org.ajax4jsf.framework.ajax.AjaxViewHandler.renderView(AjaxViewHandle
r.java:221)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderRes
ponseExecutor.java:116)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:
241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:208)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseXMLFilter.doXmlFilter(BaseX
MLFilter.java:75)
at org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.

How to force generation of #XmlSeeAlso annotation?

I am using JAXB to generate Java code from a couple of XSD files. Then, inside of an OSGi container I am unmarshalling XML files to the generated code. The XSD uses xsd:any element:
<xsd:complexType name="GetReservationRSType">
<xsd:sequence>
<xsd:element name="Errors" type="pnrb:Errors.PNRB"
minOccurs="0" />
<xsd:choice>
<xsd:element name="Reservation" type="pnrb:Reservation.PNRB"
minOccurs="0" />
<xsd:element name="Content" minOccurs="0">
<xsd:complexType>
<xsd:choice>
<xsd:any processContents="lax" />
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
I had several problems with making it working in the production code, but eventually I solved it when I manually added #XmlSeeAlso annotation (#XmlSeeAlso(value = { OTATravelItineraryRS.class }) in the code below):
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "GetReservationRSType", propOrder = {
"warnings",
"errors",
"reservation",
"content"
})
#XmlSeeAlso({
GetReservationRS.class
})
public class GetReservationRSType {
#XmlAccessorType(XmlAccessType.FIELD)
#XmlType(name = "", propOrder = {
"any"
})
#XmlSeeAlso(value = { OTATravelItineraryRS.class })
public static class Content {
// ...
}
// ...
}
Is there any way I can force JAXB to automatically add such annotation? For instance, by adding some JAXB bindings configuration option or by modifying XSD files?
EDIT:
My JAXBContext in OSGi env is initialized in the following way (it gets all the generated packages names as parameter) - they are listed with the usage of colon delimiter as it was suggested in several JAXB-related posts:
<bean id="jaxbContext" class="javax.xml.bind.JAXBContext" factory-method="newInstance">
<constructor-arg index="0" value="com.sabre.webservices.pnrbuilder:com.sabre.webservices.sabrexml._2003._07" />
</bean>
I am getting the following exception:
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[javax.xml.bind.JAXBException: class com.sabre.webservices.sabrexml._2003._07.OTATravelItineraryRS nor any of its super class is known to this context.]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:318)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(AbstractMarshallerImpl.java:105)
at org.apache.camel.converter.jaxb.FallbackTypeConverter.marshall(FallbackTypeConverter.java:174)
at org.apache.camel.converter.jaxb.FallbackTypeConverter.convertTo(FallbackTypeConverter.java:88)
... 94 more
Caused by: javax.xml.bind.JAXBException: class com.sabre.webservices.sabrexml._2003._07.OTATravelItineraryRS nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:246)
at com.sun.xml.bind.v2.runtime.XMLSerializer.reportError(XMLSerializer.java:261)
at com.sun.xml.bind.v2.runtime.property.SingleReferenceNodeProperty.serializeBody(SingleReferenceNodeProperty.java:113)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:332)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:699)
at com.sun.xml.bind.v2.runtime.property.SingleElementNodeProperty.serializeBody(SingleElementNodeProperty.java:152)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:332)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:328)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsSoleContent(XMLSerializer.java:593)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeRoot(ClassBeanInfoImpl.java:320)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:494)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:315)
... 98 more
Caused by: javax.xml.bind.JAXBException: class com.sabre.webservices.sabrexml._2003._07.OTATravelItineraryRS nor any of its super class is known to this context.
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:590)
at com.sun.xml.bind.v2.runtime.property.SingleReferenceNodeProperty.serializeBody(SingleReferenceNodeProperty.java:105)
... 107 more
I found a satisfying workaround. It uses jaxb annotate plugin. Maybe it's not the perfect solution, but - at least - it prevents me from committing the generated classes into SVN repository.
The mentioned plugin simply adds the wanted annotation.
Here is the required configuration in pom.xml:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<executions>
<execution>
<id>schema-pnr-service</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources/xsd</schemaDirectory>
<schemaIncludes>
<include>GetReservationSTLRQ_v0.01.xsd</include>
<include>GetReservationSTLRS_v0.01.xsd</include>
<include>OTA_TravelItineraryReadCDI1.0.5RQ.xsd</include>
<include>OTA_TravelItineraryReadCDI1.0.5RQRS.xsd</include>
<include>OTA_TravelItineraryReadCDI1.0.5RS.xsd</include>
<include>OTA_TravelItineraryReadPNR1.0.5RS.xsd</include>
</schemaIncludes>
<extension>true</extension>
<args>
<arg>-Xannotate</arg>
<arg>-Xannotate-defaultFieldTarget=setter</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>
And the wanted annotation is configured in in bindings.xjb file that should be in the same directory as *.xsd files - here goes its content:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
xmlns:annox="http://annox.dev.java.net"
extensionBindingPrefixes="annox" version="2.1">
<globalBindings typesafeEnumMaxMembers="600"/>
<bindings schemaLocation="GetReservationSTLRS_v0.01.xsd" node="/xsd:schema">
<bindings node="xsd:complexType[#name='GetReservationRSType']/xsd:sequence/xsd:choice/xsd:element[#name='Content']/xsd:complexType">
<annox:annotate target="class">
<annox:annotate annox:class="javax.xml.bind.annotation.XmlSeeAlso" value="com.sabre.webservices.sabrexml._2003._07.OTATravelItineraryRS" />
</annox:annotate>
</bindings>
</bindings>
</bindings>
Instead of trying to force in an #XmlSeeAlso annotation you should create the JAXBContext on the generated package name. This way you can be sure that all the classes are processed. Since you are in an OSGi environment be use to use one of the methods that take a ClassLoader parameter.
JAXBContext jc = JAXBContext.newInstance("com.example.foo", ObjectFactory.class.getClassLoader());
If there are more than one generated package name, then the context path is : delimited.
JAXBContext jc = JAXBContext.newInstance("com.example.foo:org.example.bar", ObjectFactory.class.getClassLoader());

Resources