抛出代理对象的问题

时间:2016-07-24 19:11:26

标签: java sap hana cmis

我尝试使用HANA Cloud Document服务与Maven和Spring集成CMIS。 当我尝试使用没有Maven / Spring上下文的代码时,它工作正常。 (为了更好地理解,请看一下:http://scn.sap.com/community/developer-center/cloud-platform/blog/2013/04/13/document-management-using-hana-cloud-document-service-on-android

        Session openCmisSession = null;
        EcmService ecmSvc = null;
        InitialContext ctx = new InitialContext();
        String lookupName = "java:comp/env/" + "EcmService";
        try
        {   
          Object obj = ctx.lookup(lookupName);
          ecmSvc = (EcmService) obj; 
        }       
        catch (Exception e)
        {
          e.printStackTrace();
        }

使用Spring时,尝试转换代理对象时会发生异常。

ecmSvc = (EcmService) obj; //Here, the EcmService is a interface

例外是:

java.lang.ClassCastException:com.sun.proxy。$ Proxy146无法强制转换为com.sap.ecm.api.EcmService

at com.msg.reinsurance.application.account.service.FindAccountFacadeImp.findContract(FindAccountFacadeImp.java:93)

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 org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:180)

at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)

at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:189)

at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:99)

at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)

at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)

at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)

at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)

at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:254)

at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)

at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)

at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)

at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:180)

at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:298)

at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:222)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:735)

at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:273)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)

at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

at com.sap.core.jpaas.security.auth.service.lib.AbstractAuthenticator.invoke(AbstractAuthenticator.java:168)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at com.sap.core.tenant.valve.TenantValidationValve.invokeNextValve(TenantValidationValve.java:167)

at com.sap.core.tenant.valve.TenantValidationValve.invoke(TenantValidationValve.java:91)

at com.sap.js.statistics.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:34)

at com.sap.core.js.monitoring.tomcat.valve.RequestTracingValve.invoke(RequestTracingValve.java:27)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Thread.java:745)

任何帮助将不胜感激。感谢。

1 个答案:

答案 0 :(得分:0)

最好的选择我认为你正在打包。客户端库进入您的应用程序,因此它们与平台已经提供的文件冲突(由于不同的类加载器)。 仔细检查一下。 此外,如果问题不是由我的假设造成的,您可以在此处检查另一种解决方法:http://scn.sap.com/thread/3803685