Camel JAXB - jaxb.index not found

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Camel JAXB - jaxb.index not found

contactreji
Hello guys

Am trying a POC to convert a Pojo into equivalent XML using jaxb. I have all my annotation in place on the classes and added index.jaxb to the package.

My route looks like below. not sure why it happens, but its still crying out for ObjectFactory or index.jaxb



@Component
public class BusBookingSearchService extends RouteBuilder{
    @Autowired
    BusSearchUItoXMLMapping busSearchUItoXMLMapping;


    @Override
    public void configure() throws Exception {

        from("direct:processBusBookingSearchRequest")
                .log("received request from postman ${body}")
                .process(busSearchUItoXMLMapping)
                .log("Transformation completed.")
                .marshal().jaxb("com.trvl.integration.domain.busbooking.tbo.search.xmlobjects.request")
                .convertBodyTo(String.class)
                .log("Marshalled XML ${body}")
                .end();
    }
}


Log


017-03-21 08:57:04 INFO  o.e.j.server.handler.ContextHandler - Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext@7a485a36{/,file:///C:/Users/skdev3/AppData/Local/Temp/2/jetty-docbase.4379440425892962628.1211/,UNAVAILABLE}
2017-03-21 08:57:04 INFO  o.s.b.a.l.AutoConfigurationReportLoggingInitializer -

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-03-21 08:57:04 ERROR o.s.boot.SpringApplication - Application startup failed
org.apache.camel.spring.boot.CamelSpringBootInitializationException: javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "com.trvl.integration.domain.busbooking.tbo.search.xmlobjects.request" doesnt contain ObjectFactory.class or jaxb.index
 - with linked exception:
[javax.xml.bind.JAXBException: "com.trvl.integration.domain.busbooking.tbo.search.xmlobjects.request" doesnt contain ObjectFactory.class or jaxb.index]
        at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:88)
        at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:41)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:166)
        at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:138)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:383)
        at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:337)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:882)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:545)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
        at com.trvl.integration.SpringbootApplication.main(SpringbootApplication.java:11)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "com.trvl.integration.domain.busbooking.tbo.search.xmlobjects.request" doesnt contain ObjectFactory.class or jaxb.index
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)
        at javax.xml.bind.ContextFinder.find(ContextFinder.java:335)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:431)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:394)
        at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:298)
        at com.trvl.integration.routes.BusBookingSearchService.configure(BusBookingSearchService.java:32)
        at org.apache.camel.builder.RouteBuilder.checkInitialized(RouteBuilder.java:403)
        at org.apache.camel.builder.RouteBuilder.configureRoutes(RouteBuilder.java:343)
        at org.apache.camel.builder.RouteBuilder.addRoutesToCamelContext(RouteBuilder.java:326)
        at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:869)
        at org.apache.camel.impl.DefaultCamelContext$1.call(DefaultCamelContext.java:866)
        at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)
        at org.apache.camel.impl.DefaultCamelContext.addRoutes(DefaultCamelContext.java:866)
        at org.apache.camel.spring.boot.RoutesCollector.onApplicationEvent(RoutesCollector.java:86)
        ... 20 common frames omitted
Caused by: javax.xml.bind.JAXBException: "com.trvl.integration.domain.busbooking.tbo.search.xmlobjects.request" doesnt contain ObjectFactory.class or jaxb.index
        at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:281)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:171)
        at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:131)
        ... 33 common frames omitted
2017-03-21 08:57:04 INFO  o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7ce026d3: startup date [Tue Mar 21 08:56:50 IST 2017]; root of context hierarchy
2017-03-21 08:57:04 INFO  o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown
2017-03-21 08:57:04 INFO  o.a.camel.spring.SpringCamelContext - Apache Camel 2.18.1 (CamelContext: camel-1) is shutting down
2017-03-21 08:57:04 INFO  o.a.camel.spring.SpringCamelContext - Apache Camel 2.18.1 (CamelContext: camel-1) uptime
2017-03-21 08:57:04 INFO  o.a.camel.spring.SpringCamelContext - Apache Camel 2.18.1 (CamelContext: camel-1) is shutdown in 0.094 seconds

Process finished with exit code 1
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel JAXB - jaxb.index not found

contactreji
oops. sorry i meant jaxb.index. Ignore the typo "index.jaxb"
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel JAXB - jaxb.index not found

Onder SEZGIN
this is not a camel question.

though i can guess it is a jaxb issue.

it seems you have not generated pojos using your xsd schema. you should do
it properly, them jaxb will recognize your pojos.


On Tue, 21 Mar 2017 at 06:35, contactreji <[hidden email]> wrote:

> oops. sorry i meant jaxb.index. Ignore the typo "index.jaxb"
>
>
>
>
> -----
> Reji Mathews
> Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel
> & Jboss Fuse ESB | Mule ESB )
> LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
> Twitter - reji_mathews
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Camel-JAXB-jaxb-index-not-found-tp5795819p5795820.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Sent from my iPhone
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Camel JAXB - jaxb.index not found

contactreji
Made slight mods on the route and it worked. Thanks

 @Override
    public void configure() throws Exception {

        JaxbDataFormat searchXmlRequestJaxb= new JaxbDataFormat();
        searchXmlRequestJaxb.setContext(JAXBContext.newInstance(com.trvl.integration.domain.busbooking.tbo.search.xmlobjects.request.Search.class));

        from("direct:processBusBookingSearchRequest")
                .log("received search request ${body}")
                .process(busSearchUItoXMLMapping)
                .log("Transformation completed.")
                .marshal(searchXmlRequestJaxb)
                //.convertBodyTo(String.class)
                .log("Marshalled XML ${body}")
                .end();
    }
}
Reji Mathews
Sr. Developer - Middleware Integration / SOA ( Open Source - Apache Camel & Jboss Fuse ESB | Mule ESB )
LinkedIn - http://in.linkedin.com/pub/reji-mathews/31/9a2/40a
Twitter - reji_mathews
Loading...