wood burning stoves*
The moose likes EJB and other Java EE Technologies and the fly likes Throws exception in Spring 3.0 DataAccess with lookup jndi in J2SE app Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Throws exception in Spring 3.0 DataAccess with lookup jndi in J2SE app" Watch "Throws exception in Spring 3.0 DataAccess with lookup jndi in J2SE app" New topic
Author

Throws exception in Spring 3.0 DataAccess with lookup jndi in J2SE app

Jose Carlos Miranda
Greenhorn

Joined: Aug 19, 2011
Posts: 1
Hi everyone..
Can someone help me with the exception in Spring 3.0, I use jee:jndi-lookup with jboss 6 to return a javax.sql.DataSource follow the code



import org.springframework.jdbc.core.JdbcTemplate;


public abstract class CvmImplDao {



/**
*
*/
private JdbcTemplate jdbcTemplate;

/**
*
* @return
*/
public JdbcTemplate getJdbcTemplate() {
return jdbcTemplate;
}


/**
*
* @param jdbcTemplate
*/
public void setJdbcTemplate(final JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}


}



<jee:jndi-lookup id="dataSource" jndi-name="java:jdbc/MySqlDS" resource-ref="true" proxy-interface="javax.sql.DataSource" />



<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" p:dataSource-ref="dataSource" />

mysql-ds.xml
<local-tx-datasource><jndi-name>jdbc/MySqlDS<jndi-name><use-java-context>false</use-java-context>.....


Exception

In this snippet of code throws a exception

// TODO Auto-generated method stub
super.getJdbcTemplate().batchUpdate(super.getSqlStatement(), new BatchPreparedStatementSetter() {…





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 [Reference Class Name: javax.sql.DataSource
Address Type: ProxyData
AddressContents: ffffffac ffffffed 0 5 73 7d 0 0 0 1 0 14 6a 61 76 61 78 2e 73 71 6c 2e 44 61 74 61 53 6f 75 72 63 65 ...
Address Type: VMID
AddressContents: ffffffac ffffffed 0 5 73 72 0 13 6a 61 76 61 2e 72 6d 69 2e 73 65 72 76 65 72 2e 55 49 44 f 12 70 d ffffffbf ...
Type: JndiName
Content: jdbc/MySqlDS
]; nested exception is java.lang.IllegalArgumentException: object is not an instance of declaring class
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy9.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:572)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:614)
at org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:883)
at br.com.bvmf.icadx.persistencia.impl.comum.RepresentanteInventidorNResidenteDaoImpl.insertBatch(RepresentanteInventidorNResidenteDaoImpl.java:29)
at br.com.bvmf.icadx.negocio.impl.comum.RepresentanteInvestidorNResidenteImpl.processaArquivo(RepresentanteInvestidorNResidenteImpl.java:102)
at com.core.CriaProcessoCvm.submitJobs(CriaProcessoCvm.java:108)
at com.core.CriaProcessoCvm.main(CriaProcessoCvm.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
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:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
... 33 more
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Throws exception in Spring 3.0 DataAccess with lookup jndi in J2SE app
 
Similar Threads
Problem in Jndi LooK up in Was6.1 for MySql Data Source
java.lang.Exception: Attempted to use a 5.0 DataSource outside of a 2.3 servlet
ClassCast when launching - No exception when using LaunchClient
Incompatible resource adapter
javax.naming.Reference incompatible with javax.sql.DataSource