Alex
Alex

Reputation: 883

JNDI DataSource: migrating from Tomcat to jBoss/Wildfly

I have a web application that uses Tomcat 7, Spring MVC 4.0, and JPA (Hibernate implementation). I am migrating this application to jBoss/Wildfly application server.

Currently, the DataSource is injected in the application with JNDI in a Spring configuration file:

<jee:jndi-lookup id="dataSource" jndi-name="jdbc/MY_DB" expected-type="javax.sql.DataSource" />

The data source itself is defined in $CATALINA_HOME/conf/context.xml in the following way:

<Context> 
    <Resource name="jdbc/MY_DB" 
        auth="Container" 
        type="javax.sql.DataSource" 
        driverClassName="com.mysql.jdbc.Driver" 
        url="jdbc:mysql://localhost:3306/MY_DB?useUnicode=yes&amp;characterEncoding=UTF-8" 
        username="user1" 
        password="" 
        validationQuery="select 1" 
        removeAbandoned="true" 
        removeAbandonedTimeout="120" 
        maxWait="60" 
        maxActive="20" 
        maxIdle="10" /> 
</Context>

How can I define this JNDI DataSource in JBoss/Wildfly?

Upvotes: 0

Views: 2160

Answers (1)

Federico Sierra
Federico Sierra

Reputation: 5208

First, you must make the JDBC driver available to the application server; then you can configure the data source itself.

See more details in Data Source Configuration in AS 7 and DataSource configuration

Upvotes: 1

Related Questions