Announcement Announcement Module
No announcement yet.
Using database command in connection with a persistence setup with jndiDataSource Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using database command in connection with a persistence setup with jndiDataSource

    I'm using a persistence setup using a jndiDataSource:

    persistence setup --database MYSQL --provider ECLIPSELINK --databaseName mydb --jndiDataSource jdbc/mydb

    When I now try to inspect that database

    database introspect --schema mydb

    it says:

    Connection properties must not be null or empty

    Shouldn't spring roo take the connection properties from the jndi data source? I probably have to connect a running server somehow to Spring Roo, but how?

    Thank you very much

  • #2
    Yes, DBRE just uses the URL etc to make live connections at present. Raise an improvement request if you like for jndi. Will probably have to use something like:

    Connection connection = null;
    try {
       InitialContext context = new InitialContext();
       DataSource dataSource = (DataSource) context.lookup("jdbc/DataSource");
       connection = dataSource.getConnection();
    } catch (Exception e) {
       return connection;


    • #3
      Ah ok

      Well, it's no problem for development but I don't want any properties file for deployment.
      I don't think time is saved when using JNDI because you would have to manually connect to/start the server first.

      The 'solution' I guess is:

      1. create configuration with local db configuration:
      persistence setup --database MYSQL --provider ECLIPSELINK --databaseName mydb --userName asdf --password jklm
      2. also register jndi data source
      persistence setup --database MYSQL --provider ECLIPSELINK --databaseName mydb --jndiDataSource jdbc/mydb


      For release: delete
      Last edited by Clawg; Nov 29th, 2011, 04:51 AM.


      • #4
        Not that it would help with DBRE, but in my previous job I declared the following config to read properties out of JDNI, but it also defaulted to a properties file if the JNDI object could not be found. So the same configuration worked in either WebSphere or Tomcat with the same WAR file:

        	<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        		<property name="properties">
        			<bean class="org.springframework.jndi.JndiObjectFactoryBean">
        				<property name="jndiName" value="config/FOO" />
        				<property name="resourceRef" value="true" />
        				<property name="defaultObject" ref="coreProperties" />
        		<property name="ignoreUnresolvablePlaceholders" value="true" />
        	<bean id="coreProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        		<property name="locations">
        		<property name="ignoreResourceNotFound" value="true" />