Hello Experts,
I've been working on a web application that uses Spring, Hibernate, and Struts. I'm not using any EJBs, but am deploying to Glassfish v2. I've been successfully connecting to my database using the "org.apache.commons.dbcp.B
asicDataSo
urce" as my datasource. Now I'm trying to set up the webapp on the server and want to use JNDI. I've set it up both in glassfish and in the spring context, but I keep getting a "java.lang.IllegalArgument
Exception:
null source" as soon as I try to hit the database.
My original setup that works properly - I've commented this out temporarily, but works when I uncomment:
<bean id="btdDataSource" class="org.apache.commons.
dbcp.Basic
DataSource
">
<property name="driverClassName" value="${database.driver}"
/>
<property name="url" value="${database.url}" />
<property name="username" value="${database.user}" />
<property name="password" value="${database.password
}" />
</bean>
New setup that is establishing a connection via JNDI, but fails as soon as I try to execute a query:
<bean id="btdDataSource" class="org.springframework
.jndi.Jndi
ObjectFact
oryBean" >
<property name="jndiName" value="java:comp/env/jdbc/
btdConnDS"
/>
</bean>
NOTE: I did set this up under sun-web.xml, web.xml, and under Glassfish.
I was originially using the "mysql-connector-java-5.1.
6-bin.jar"
file, but read somewhere that "mysql-connector-java-5.0.
8-bin.jar"
may solve this problem. Both files result in the same "null source" error.
This is the line of code that is the first database access and where the exception is generated:
if(getHibernateTemplate().
getSession
Factory().
getCurrent
Session().
isConnecte
d()){
System.out.println("It's connected");
}
return getHibernateTemplate().fin
d("from TechnologyGroup");
I added the top line of code to make sure that hibernateTemplate is not null. So it does actually produce the line It's connected. As soon as it hits the find statement is generates the exception: "java.lang.IllegalArgument
Exception:
null source"
Thanks in advance for you help.
Jared