代码之家  ›  专栏  ›  技术社区  ›  srth12

websphere上StructDescriptor的ClassCastException,但tomcat上没有

  •  0
  • srth12  · 技术社区  · 8 年前

    我的应用程序在本地tomcat服务器上运行良好。但后来我通过创建一个war文件将其部署到WebSphere中。部署之后,每当我尝试使用 结构描述符 如下所示,我得到ClassCastException。下面是我的代码段:

    StructDescriptor projectTypeDesc = StructDescriptor.createDescriptor(
            "FRA_DATA.REGION_TYPE", st.getConnection());
    STRUCT[] structs = new STRUCT[filterDTO.getRegion().size()];
    for (int i = 0; i < filterDTO.getRegion().size(); ++i) {
        int str = (int) filterDTO.getRegion().get(i).intValue();
        Object[] objects = new Object[] { str };
        STRUCT struct = new STRUCT(projectTypeDesc, st.getConnection(),
                objects);
        structs[i] = struct;
    }
    ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
            "FRA_DATA.REGIONS", st.getConnection());
    arrayList.add(new ARRAY(arrayDescriptor, st.getConnection(), structs));
    

    抛出的错误是:

    java.lang.ClassCastException: com.ibm.ws.rsadapter.jdbc.WSJdbcConnection incompatible with oracle.jdbc.OracleConnection 
        at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:169) 
        at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:140) 
        at com.citi.oprisk.cpa.repository.impl.ReportRepositoryImpl.setFilterArraysForOracle(ReportRepositoryImpl.java:310) 
        at com.citi.oprisk.cpa.repository.impl.ReportRepositoryImpl.getCommonProcessSystemReportUsingSP(ReportRepositoryImpl.java:385) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:600) 
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
        at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99) 
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281) 
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) 
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208) 
        at com.sun.proxy.$Proxy2088.getCommonProcessSystemReportUsingSP(Unknown Source) 
        at com.citi.oprisk.cpa.service.impl.CpaReportServiceImpl.getCommonProcessReport(CpaReportServiceImpl.java:271) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:600) 
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202) 
        at com.sun.proxy.$Proxy2089.getCommonProcessReport(Unknown Source) 
        at com.citi.oprisk.cpa.controller.CpaDashboardController.getCommonProcessSystemReport(CpaDashboardController.java:98) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
        at java.lang.reflect.Method.invoke(Method.java:600) 
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) 
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) 
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) 
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814) 
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737) 
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) 
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) 
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969) 
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:871) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:738) 
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845) 
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) 
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1661) 
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:944) 
        at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:507) 
        at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:181) 
        at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3954) 
        at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276) 
        at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:945) 
        at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1592) 
        at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:191) 
        at com.ibm.ws.ard.channel.ARDChannelConnLink.handleDiscrimination(ARDChannelConnLink.java:188) 
        at com.ibm.ws.ard.channel.ARDChannelConnLink.ready(ARDChannelConnLink.java:93) 
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:453) 
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:515) 
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:306) 
        at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:277) 
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214) 
        at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113) 
        at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175) 
        at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217) 
        at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161) 
        at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138) 
        at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204) 
        at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775) 
        at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905) 
        at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1656)
    

    在数据库中创建的对象如下:

    CREATE OR REPLACE TYPE region_type AS OBJECT (region NUMBER); 
    CREATE OR REPLACE TYPE regions AS TABLE OF region_type;
    

    我试图在不同的表格上搜索,但没有找到任何解决方案。请帮忙。

    1 回复  |  直到 8 年前
        1
  •  0
  •   Brett Kail    8 年前

    使用 WSCallHelper.getNativeConnection 要“展开”WSJdbcConnection中包含的OracleConnection:

    StructDescriptor projectTypeDesc = StructDescriptor.createDescriptor(
            "FRA_DATA.REGION_TYPE",
            WSCallHelper.getNativeConnection(st.getConnection()));