3

I am trying to deploy my spring-boot application to WildFly Version 8.1, but I get an javax.naming.NameNotFoundException, everytime the app tries to boot.

My Configuration:
I added the JDBC as Module to the WildFly-Standalone instance.
module.xml:

<module xmlns="urn:jboss:module:1.1" name="org.postgresql">

    <resources>
       <resource-root path="postgresql-9.4-1201.jdbc41.jar"/>
    </resources>

    <dependencies>
       <module name="javax.api"/>
       <module name="javax.transaction.api"/>
    </dependencies>
</module>

After that I defined the driver:

<driver name="postgresql" module="org.postgresql">
  <driver-class>org.postgresql.Driver</driver-class>
  <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
  <datasource-class>org.postgresql.ds.PGSimpleDataSource</datasource-class>
</driver>

Then added a datasource to the standalone.xml

<datasource jndi-name="java:jboss/jdbc/MyDS" pool-name="MyDS" enabled="true">
  <connection-url>jdbc:postgresql://localhost:5432/databasename</connection-url>
  <driver>postgresql</driver>
  <security>
    <user-name>username</user-name>
  </security>
</datasource>

Testing the connection via JBoss-CLI results in a success.

So Now when I try to load the DataSource via:

@Bean
public DataSource getDataSource() {
   JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
   DataSource dataSource = dataSourceLookup.getDataSource(this.jndiName);
   return dataSource;
}

When I deploy via jboss-cli:

 deploy /path/to/myapplication.war

I get:

Caused by: org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'java:jboss/jdbc/MyDS'; nested exception is javax.naming.NameNotFoundException; remaining name 'java:jboss/jdbc/MyDS'
Caused by: javax.naming.NameNotFoundException; remaining name 'java:jboss/jdbc/MyDS'"}}}}

Versions:

  • spring-boot 1.2.2.RELEASE
  • wildfly-8.2.0Final

Thanks for your help :)

Markus Heider
  • 186
  • 1
  • 11
  • 1
    Did you solve this? – Doo Dah Aug 31 '16 at 00:55
  • @DooDah Sort off, but I can't fully describe the solution. The problem was I used Jetty as embedded Server. Jetty didn't find the JNDI of Wildfly somehow. By changing back to Tomcat everything worked as expected. Sorry for my late answer. Hope it still helps. – Markus Heider Feb 09 '17 at 12:00

0 Answers0