0

javax.sql.DataSourceを使用してSpringベースのアプリケーションからストアドプロシージャを実行しようとすると、「不正な引数の例外」が発生します。

スタックトレースは次のとおりです。

Caused by: org.springframework.aop.AopInvocationException: AOP configuration seems to be invalid: tried calling method [public abstract java.sql.Connection javax.sql.DataSource.getConnection() throws java.sql.SQLException] on target [com.ibm.ws.rsadapter.jdbc.WSJdbcDataSource@4582a8fc]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
    at $Proxy115.getConnection(Unknown Source)
    at org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
    at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
    at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:814)
    at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:732)
    at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1367)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1333)
    ... 45 more
Caused by: java.lang.IllegalArgumentException: object is not an instance of declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:618)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)
    ... 56 more

ソースコードは以下の通りです。

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Types;
import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import oracle.sql.ARRAY;
import oracle.sql.ArrayDescriptor;

import org.apache.log4j.Logger;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlTypeValue;
import org.springframework.jdbc.object.StoredProcedure;


public class CERBulkUploadSP extends StoredProcedure{

    private final Logger log = Logger.getLogger(this.getClass().getName());

    public CERBulkUploadSP(DataSource dataSource, String storedProcName) {

        // Run the Parent
        super(dataSource, storedProcName);

        if (log.isInfoEnabled()) {
            log.info("CERA Processes Stored Procedure Name : "+ storedProcName);
        }

        // Declare the Parameter Details
        declareParameter(new SqlParameter("THE_ARRAY", Types.ARRAY, "CER.GL_ENTRY_TYPE_ARRAY"));
        declareParameter(new SqlParameter("INCIDENT_DIM_ID", Types.NUMERIC));
        declareParameter(new SqlParameter("INS_USER", Types.VARCHAR));
        declareParameter(new SqlOutParameter("P_STATUS", Types.VARCHAR));

        // Compile the SP
        compile();
    }

    public boolean execute(final BaseViewBean baseViewBean$Session, final long incidentDimId, final String loginUser, final String identifier) throws Exception {

        boolean returnVal = false;
        Map<String, Object> inParams = new HashMap<String, Object>();
        log.info("Setting up the Stored Procedure Params");

        inParams.put("THE_ARRAY", new SqlTypeValue() {
            public void setTypeValue(PreparedStatement cs, int index, int sqlType, String typeName) throws SQLException {
                Connection con = cs.getConnection();
                ArrayDescriptor des = ArrayDescriptor.createDescriptor("CER.GL_ENTRY_TYPE_ARRAY", con);
                ARRAY a = new ARRAY(des, con, baseViewBean$Session.getExcelRecLst().toArray());
                cs.setObject(1, (Object)a);
            }
        });
        inParams.put("INCIDENT_DIM_ID", incidentDimId);
        inParams.put("INS_USER", loginUser);
        inParams.put("P_STATUS", identifier);

        if (log.isDebugEnabled()) {
            log.debug("Executing the CERA Stored Procedure ");
        }

        Map out = execute(inParams);

        log.info("output size is --------------------->>>>>>>>>> "+out.size());
        for(Object o : out.keySet()){
            log.info((String)out.get(o));
            returnVal = Boolean.parseBoolean((String)out.get(o));
        }

        if (log.isDebugEnabled()) {
            log.info("Output from CERA Stored Procedure :" + out);
        }
        return returnVal;
    }
}

Beanの定義は次のとおりです。

<bean id="cerBulkUploadSp" class="com.****.CERBulkUploadSP">
    <constructor-arg index="0">
        <ref bean="ceraDataSource" />
    </constructor-arg>
    <constructor-arg index="1">
        <value>CER.GL_PROCESS_BULK_ENTRIES</value>
    </constructor-arg>      
</bean>

<bean id="processDao" class="com.****.ProcessDaoImpl">
        <property name="storedProcedure">
            <ref bean="cerBulkUploadSp"/>
        </property>
        <property name="hibernateTemplate" > <ref bean="ceraHibernateTemplate"/></property>
    </bean>

classpath:com / ***** / hibernate

    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.use_sql_comments">true</prop>
            <prop key="hibernate.cache.use_query_cache">true</prop>
            <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
            <prop key="hibernate.jdbc.batch_size">20</prop>
            <prop key="hibernate.cache.use_second_level_cache">true</prop>
            <prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop> 
        </props>
    </property>

    <property name="dataSource"> <ref bean="ceraDataSource" />
    </property>
</bean> 

私のJNDI構成は次のとおりです。

<bean id="ceraDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>jdbc/CERDS</value>
    </property>
    <property name="lookupOnStartup">
        <value>false</value>
    </property>
    <property name="cache">
        <value>true</value>
    </property>
    <property name="proxyInterface">
        <value>javax.sql.DataSource</value>
    </property>
</bean>

私のクラスパスのjarファイルは次のとおりです。

JaxrpcComponent300V5.jar                        
ajaxtags-1.2-beta3.jar                          
ajaxtags-1.3-beta-rc7.jar                       
antlr.jar                                       
aopalliance.jar                                 
asm-commons.jar                                 
asm-util.jar                                    
asm.jar                                         
aspectjrt.jar                                   
aspectjweaver.jar                               
bsf.jar                                         
castor-anttasks.jar                             
castor-codegen.jar                              
castor-xml.jar                                  
cglib-nodep-2.1_3.jar                           
classes12.jar                                   
commons-beanutils.jar                           
commons-chain.jar                               
commons-codec.jar                               
commons-collections.jar                         
commons-dbcp.jar                                
commons-digester.jar                            
commons-fileupload.jar                          
commons-httpclient.jar                          
commons-io.jar                                  
commons-jxpath.jar                              
commons-lang.jar                                
commons-logging.jar                             
commons-pool.jar                                
commons-validator.jar                           
displaytag-1.2.jar                              
displaytag-export-poi-1.2.jar                   
displaytag-portlet-1.2.jar                      
dom4j-1.5.2.jar                                 
dom4j-1.6.1.jar                                 
ehcache.jar                                     
ejb3-persistence.jar                            
hibernate-annotations.jar                       
hibernate-entitymanager.jar                     
hibernate-validator.jar                         
hibernate3.jar                                  
ibatis.jar                                      
jakarta-oro.jar                                 
jamon.jar                                       
javassist.jar                                   
jaxb-api.jar                                    
jboss-archive-browsing.jar                      
jericho-html-2.4.jar                            
jsr173_1.0_api.jar                              
jta.jar                                         
juh-3.2.1.jar                                   
juh.jar                                         
jurt-3.2.1.jar                                  
jurt.jar                                        
list.txt                                        
log4j.jar                                       
mvel.jar                                        
poi-3.8-20120326.jar                            
poi-excelant-3.8-20120326.jar                   
poi-ooxml-3.8-20120326.jar                      
poi-ooxml-schemas-3.8-20120326.jar              
poi-scratchpad-3.8-20120326.jar                 
psecWsClient500.jar                             
quartz-all.jar                                  
ridl.jar                                        
spring-agent.jar                                
spring-aop.jar                                  
spring-aspects.jar                              
spring-beans.jar                                
spring-context-support.jar                      
spring-context.jar                              
spring-core.jar                                 
spring-jdbc.jar                                 
spring-jms.jar                                  
spring-mock.jar                                 
spring-modules-validation.jar                   
spring-orm.jar                                  
spring-security-acl.jar                         
spring-security-catalina.jar                    
spring-security-core-tiger.jar                  
spring-security-core.jar                        
spring-security-ntlm.jar                        
spring-security-openid.jar                      
spring-security-portlet.jar                     
spring-security-taglibs.jar                     
spring-tomcat-weaver.jar                        
spring-tx.jar                                   
spring-web.jar                                  
spring-webmvc-portlet.jar                       
spring-webmvc-struts.jar                        
spring-webmvc.jar                               
struts-core.jar                                 
struts-el.jar                                   
struts-extras.jar                               
struts-faces.jar                                
struts-scripting.jar                            
struts-taglib.jar                               
struts-tiles.jar                                
unoil.jar                                       
unoloader.jar                                   
urlprocessingfilter300V5.jar                    
velocity.jar                                    
xbean.jar                                       
xerces-2.2.1.jar

がtomcatでローカルにホストし、データソースをOracle接続として表すアプリを実行すると、正常に機能しますが、すべてのアプリがホストされているWebsphereサーバーにコードをデプロイすると、この問題が発生します。誰かが同じことを解決する方法を教えてもらえますか?

4

1 に答える 1

1

クラスパスに古いOracleJDBCドライバがありますclasses12.jar。これはOracle10.2およびJDK1.2/1.3用です-これがあなたの環境ではないかと思います。おそらく、他のJARにもjavax.sql.*クラスが含まれている可能性があります(すべてを知っているわけではありません)。

万が一、WebSphereクラスローダーモードをPARENT_FIRST(デフォルト)からPARENT_LASTに切り替えましたか?

于 2013-01-08T19:52:29.840 に答える