Issue
------------APPLICATION_CONTEXT.xml-------------- I have read alot of articles but didnt find any solution...
<jee:jndi-lookup jndi-name="jdbc/test" id="dataSource" expected-type="javax.sql.DataSource"/>
<bean
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"
name="factory">
<property name="dataSource" ref="dataSource"></property>
<property name="annotatedClasses">
<list>
<value>com.spring.rest.curd.model.Payment</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
</bean>
<bean
class="org.springframework.orm.hibernate4.HibernateTransactionManager"
name="transactionManager">
<property name="sessionFactory" ref="factory"></property>
</bean>
------------CONTEXT.xml-----------
<ResourceLink name="jdbc/test"
global="jdbc/test"
auth="Container"
type="javax.sql.DataSource" />
------------SERVER.xml---------
<Resource name="jdbc/test"
global="jdbc/test"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"
username="root"
password="root"
maxActive="100"
maxIdle="20"
minIdle="5"
maxWait="10000"/>
Solution
The jndi-name of the resource has the implicit prefix: java:comp/env/
So, if the resource name in your context.xml
is jdbc/test
, then the jndi-name
of your jndi-lookup
(in APPLICATION_CONTEXT.xml
) must be java:comp/env/jdbc/test
.
<jee:jndi-lookup
jndi-name="java:comp/env/jdbc/test"
id="dataSource"
expected-type="javax.sql.DataSource"/>
Answered By - Ralph