与Karaf的Moxy错误 [英] Moxy error with Karaf

查看:76
本文介绍了与Karaf的Moxy错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在保险丝ESB下使用MOXy(基于karaf),我将 org.eclipse.persistence.jar 转换为捆绑包,我将此捆绑包部署在保险丝ESB下我收到此错误

 错误:org.apache.cxf.interceptor.Fault:propertyeclipselink-oxm-xml不支持

尝试创建 JAXBContext 我的代码正在尝试将Java模型转换为XML,并且模型部署在保险丝ESB下的单独包中,并且我在同一个文件中添加了 jaxb.properties 文件模型的包



注意:从主类中的main方法运行时,相同的代码运行成功没有问题。



以下是我的代码,错误发生在第6行

  Map< String,Source> metadataSourceMap = new HashMap< String,Source>(); 
InputStream is = getClass()。getClassLoader()。getResourceAsStream
(com / syngenta / mint / security / service / transformation / User.xml);

metadataSourceMap.put(com.syngenta.mint.security.model,new StreamSource(is));

1.地图< String,Object> properties = new HashMap< String,Object>();
2. properties.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY,
metadataSourceMap);
3. properties.put(javax.xml.bind.context.factory,
org.eclipse.persistence.jaxb.JAXBContextFactory);

4.类[]类=新类[1];
5. classes [0] = User.class;

6. JAXBContext jc = JAXBContext.newInstance(classes,properties);

任何想法?



更新



堆栈跟踪:

  org.apache.cxf.interceptor.Fault:属性eclipselink.oxm.metadata-source不支持
org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java: 155)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)[131 :org.apache.cxf.bundle:2.5.0.fuse-70-084]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167)[131:org.apache.cxf .bundle:2.5.0.fuse-70-084]
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94)[131:org.apache.cxf.bundle:2.5.0 .fuse-70-084]
at org.apache.cxf.interceptor.ServiceInvokerInterceptor $ 1.run(ServiceInvokerInterceptor.java:58)[131:org.apache.cxf.bundle:2.5.0.fuse-70- 084]
org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMes sage(ServiceInvokerInterceptor.java:94)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java: 263)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123)[131:org .apache.cxf.bundle:2.5.0.fuse-70-084]
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:344)[131:org.apache.cxf .bundle:2.5.0.fuse-70-084]
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:310)[131:org.apache.cxf.bundle:2.5 .0.fuse-70-084]
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)[131:org.apache.cxf.bundle:2.5.0.fuse -70-084]
org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:943)[72:org.eclipse.jetty.server:7.5.4.v20111024]
在org.eclipse。 jetty.server.handler.ContextHandler.doScope(ContextHandler.java:879)[72:org.eclipse.jetty.server:7.5.4.v20111024]
at org.eclipse.jetty.server.handler.ScopedHandler。 handle(ScopedHandler.java:117)[72:org.eclipse.jetty.server:7.5.4.v20111024]
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250) [72:org.eclipse.jetty.server:7.5.4.v20111024]
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[72:org.eclipse.jetty .server:7.5.4.v20111024]
at org.eclipse.jetty.server.Server.handle(Server.java:349)[72:org.eclipse.jetty.server:7.5.4.v20111024]
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)[72:org.eclipse.jetty.server:7.5.4.v20111024]
at org.eclipse.jetty。 server.HttpConnection $ RequestHandler.headerComplete(HttpConnection.java:919)[72:org.eclipse.jetty.server:7.5.4.v20111024]
at org.eclipse.jetty.http.HttpParser.parseNext( HttpParser.java:582)[73:org.eclipse.jetty.http:7.5.4.v20111024]
org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)[73:org .eclipse.jetty.http:7.5.4.v20111024]
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[72:org.eclipse.jetty.server:7.5.4 .v20111024]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[68:org.eclipse.jetty.io:7.5.4.v20111024]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint $ 1.run(SelectChannelEndPoint.java:44)[68:org.eclipse.jetty.io:7.5.4.v20111024]
at org.eclipse.jetty.util .thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[76:org.eclipse.jetty.util:7.5.4.v20111024]
at org.eclipse.jetty.util.thread.QueuedThreadPool $ 3.run( QueuedThreadPool.java:533)[76:org.eclipse.jetty.util:7.5.4.v20111024]
at java.lang.Thread.run(Thread.java:619)[:1.6.0_12]
引起:javax.xml.bind.JAXBException:propertyeclipseli com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:118)
com.sun.xml.bind.v2不支持nk.oxm.metadata-source
.ContextFactory.createContext(ContextFactory.java:202)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_12]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 39)[:1.6.0_12]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_12]
at java.lang.reflect.Method.invoke(Method。 java:597)[:1.6.0_12]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:143)[:2.0.0.fuse-70-084]
at javax。 xml.bind.ContextFinder.find(ContextFinder.java:269)[:2.0.0.fuse-70-084]
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412)[:2.0 .0.fuse-70-084]
at com.syngenta.transport1.security.transformation.Transformer.fromJavaToXML(Transformer.java:72)[311:com.syngenta.transport1.securit y.transformation:1.0.0.SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_12]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39 )[:1.6.0_12]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_12]
at java.lang.reflect.Method.invoke(Method.java :597)[:1.6.0_12]
org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.osgi.service.importer.support.internal .aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
at org .springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
在org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework .osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.Cglib2AopProxy $ FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:572)
at com.syngenta.transport1.security.transformation.Transformer $$ EnhancerByCGLIB $$ 1aed98eb.fromJavaToXML(< generated> )
at com.syngenta.transport1.security.restservice.UserRestService.handleGetUserRequest(UserRestService.java:53)[310:com.syngenta.transport1.security.restservice:1.0.0.SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_12]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_12]
at sun.reflect .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_12]
at ja va.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_12]
org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)[131: org.apache.cxf.bundle:2.5.0.fuse-70-084]
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)[131:org.apache。 cxf.bundle:2.5.0.fuse-70-084]
... 25更多


解决方案

问题已经通过替换这段代码解决了

  Map< String,Source> metadataSourceMap = new HashMap< String,Source>(); 
InputStream is = getClass()。getClassLoader()。getResourceAsStream(com / syngenta / mint / security / service / transformation / User.xml); metadataSourceMap.put(com.syngenta.mint.security.model,new StreamSource(is));
Map< String,Object> properties = new HashMap< String,Object>();
properties.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY,metadataSourceMap);
properties.put(javax.xml.bind.context.factory,org.eclipse.persistence.jaxb.JAXBContextFactory);



< pre class =lang-java prettyprint-override> InputStream is = getClass()。getClassLoader()。getResourceAsStream(com / syngenta / mint / security / service / transformation / User.xml);
Map< String,Object> properties = new HashMap< String,Object>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE,is);


I'm using MOXy under fuse ESB (based on karaf), I converted org.eclipse.persistence.jar to a bundle, I deployed this bundle under fuse ESB and I got this error

Error : "org.apache.cxf.interceptor.Fault: property "eclipselink-oxm-xml" is not supported"

When trying to create new instance of JAXBContextmy code is trying to convert Java model to XML, and the model is deployed in a separate bundle under fuse ESB and I added jaxb.properties file in the same package of the model

Note: The same code runs successfully without problems when running from a main method in a main class.

The following is my code and the error happens at line no.6.

    Map<String, Source> metadataSourceMap = new HashMap<String, Source>();      
    InputStream is = getClass().getClassLoader().getResourceAsStream
            ("com/syngenta/mint/security/service/transformation/User.xml");             

    metadataSourceMap.put("com.syngenta.mint.security.model",new StreamSource(is));

    1. Map<String, Object> properties = new HashMap<String, Object>();
    2. properties.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY,
            metadataSourceMap);
    3. properties.put("javax.xml.bind.context.factory",
                 "org.eclipse.persistence.jaxb.JAXBContextFactory");

    4. Class[] classes = new Class[1];
    5. classes[0] = User.class;

    6. JAXBContext jc = JAXBContext.newInstance(classes, properties);

Any Idea?

Update

Stack Trace:

org.apache.cxf.interceptor.Fault: property "eclipselink.oxm.metadata-source" is not supported
    at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:155)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:121)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:167)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:94)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:58)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:94)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(JettyHTTPDestination.java:344)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:310)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:943)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:879)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.Server.handle(Server.java:349)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:919)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)[73:org.eclipse.jetty.http:7.5.4.v20111024]
    at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)[73:org.eclipse.jetty.http:7.5.4.v20111024]
    at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:51)[72:org.eclipse.jetty.server:7.5.4.v20111024]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:586)[68:org.eclipse.jetty.io:7.5.4.v20111024]
    at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:44)[68:org.eclipse.jetty.io:7.5.4.v20111024]
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)[76:org.eclipse.jetty.util:7.5.4.v20111024]
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)[76:org.eclipse.jetty.util:7.5.4.v20111024]
    at java.lang.Thread.run(Thread.java:619)[:1.6.0_12]
Caused by: javax.xml.bind.JAXBException: property "eclipselink.oxm.metadata-source" is not supported
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:118)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:202)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_12]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_12]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_12]
    at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_12]
    at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:143)[:2.0.0.fuse-70-084]
    at javax.xml.bind.ContextFinder.find(ContextFinder.java:269)[:2.0.0.fuse-70-084]
    at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:412)[:2.0.0.fuse-70-084]
    at com.syngenta.transport1.security.transformation.Transformer.fromJavaToXML(Transformer.java:72)[311:com.syngenta.transport1.security.transformation:1.0.0.SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_12]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_12]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_12]
    at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_12]
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
    at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
    at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
    at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.Cglib2AopProxy$FixedChainStaticTargetInterceptor.intercept(Cglib2AopProxy.java:572)
    at com.syngenta.transport1.security.transformation.Transformer$$EnhancerByCGLIB$$1aed98eb.fromJavaToXML(<generated>)
    at com.syngenta.transport1.security.restservice.UserRestService.handleGetUserRequest(UserRestService.java:53)[310:com.syngenta.transport1.security.restservice:1.0.0.SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_12]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_12]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_12]
    at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_12]
    at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:173)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:89)[131:org.apache.cxf.bundle:2.5.0.fuse-70-084]
    ... 25 more

解决方案

the problem has been solved by replacing this piece of code

Map<String, Source> metadataSourceMap = new HashMap<String, Source>();      
InputStream is = getClass().getClassLoader().getResourceAsStream("com/syngenta/mint/security/service/transformation/User.xml");               metadataSourceMap.put("com.syngenta.mint.security.model",new StreamSource(is));
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(JAXBContextFactory.ECLIPSELINK_OXM_XML_KEY,metadataSourceMap);
        properties.put("javax.xml.bind.context.factory","org.eclipse.persistence.jaxb.JAXBContextFactory");

With

InputStream is = getClass().getClassLoader().getResourceAsStream("com/syngenta/mint/security/service/transformation/User.xml");    
Map<String, Object> properties = new HashMap<String, Object>();
properties.put(JAXBContextProperties.OXM_METADATA_SOURCE, is);

这篇关于与Karaf的Moxy错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆