0

I'm facing problems with a jdbc dynamic properties configurer. I try to explain what exactly the problem is.

When I do mvn clean install and right after I deploy the applications in my server (Weblogic 10.3.3), everything is correct, and all the applications work fine. But, every morning, when I try to redeploy the same applications, it was shown an error message like this:

Error creating bean with name 'path.to.my.bean.JDBCPropertiesFactoryBean#6015a10' defined in class path resource [spring/configuration/placeholder-jdbcproperties.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: StatementCallback; bad SQL grammar [
SELECT
  A.COLUMN1 || '.' || P.COLUMN2,
  COLUMN3
FROM
  T_TABLE_WITH_PROPERTIES${application.version} P,
  T_TABLE_WITH_PROPERTIES_2 G
WHERE G.ID = P.ID
]; nested exception is java.sql.SQLSyntaxErrorException: ORA-00911: invalid character

This application.version comes from maven pom.xml:

<properties>
  ...
  <application.version>MyVersion</application.version>
  ...
</properties>

The bean is:

<bean id="jdbcPlaceholderConfig"
class="path.to.my.bean.DefaultPropertyPlaceholderConfigurer"> <!-- Class to extend PropertyPlaceholderConfigurer -->
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="properties">
    <bean class="path.to.my.bean.JDBCPropertiesFactoryBean"> <!-- Class to extend PropertiesFactoryBean -->
        <property name="query">
            <value>
                SELECT
                    A.COLUMN1 || '.' || P.COLUMN2,
                    COLUMN3
                FROM
                    T_TABLE_WITH_PROPERTIES${application.version} P,
                    T_TABLE_WITH_PROPERTIES_2 G
                WHERE G.ID = P.ID
            </value>
        </property>
        <property name="dataSource" ref="ref.to.datasource.bean"/>
    </bean>
</property>

So, every morning I have to rebuild with maven, and the loop starts again.

Additional information: I try to use JRebel too, but I'm not sure where can be the problem, maybe this is relevant.

Thanks in advance.

UPDATE:

This how I generate the rebel.xml:

<build>
  ...
  <plugins>
    <plugin>
      <groupId>org.zeroturnaround</groupId>
      <artifactId>jrebel-maven-plugin</artifactId>
      <version>1.1.5</version>
      <configuration>
        <relativePath>../../</relativePath>
        <rootPath>PATH\TO\MY\SIS_VOB</rootPath>
        <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
        <alwaysGenerate>true</alwaysGenerate>
      </configuration>
      <executions>
        <execution>
          <id>generate-rebel-xml</id>
          <phase>process-resources</phase>
          <goals>
            <goal>generate</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

I've just realized that with <executions>...<goal>generate</goal>...</executions>, when I do mvn clean install, without jrebel:generate, the rebel.xml files are always generated, so maybe I have to delete the executions tag, and generate the rebel.xml files once with jrebel:generate, and then, edit the rebel.xml and do again mvn clean install.

Would be that correct?

Thanks.

UPDATE WITH THE SOLUTION:

This is the final version of maven jrebel plugin in the pom.xml:

<build>
  ...
  <plugins>
    <plugin>
      <groupId>org.zeroturnaround</groupId>
      <artifactId>jrebel-maven-plugin</artifactId>
      <version>1.1.5</version>
      <configuration>
        <relativePath>../../</relativePath>
        <rootPath>PATH\TO\MY\SIS_VOB</rootPath>
        <addResourcesDirToRebelXml>true</addResourcesDirToRebelXml>
        <alwaysGenerate>true</alwaysGenerate>
      </configuration>
      <!-- executions tag out! to not regenerate files always -->
    </plugin>
  </plugins>
</build>

To create the rebel.xml:

mvn jrebel:generate

Then, if we want, we can modify the rebel.xml files if we want to exclude some files, like *.properties, as Henri's answer.

And that's it!

Alavaros
  • 1,665
  • 7
  • 32
  • 52

1 Answers1

1

This can happen if you're using resource filtering with JRebel, as the application looks up the bean's xml in its unfiltered form from the project working directory (as per rebel.xml).

To resolve this, you'll need to update rebel.xml for that module, adding exclude for that particular XML file - see here.

Example

Henri Viik
  • 664
  • 1
  • 5
  • 16
  • Thanks for your answer, I'm going to try it. But I have another question, this `rebel.xml` is generate automatically, Do I have to update the file manually? or Is there any way to do it automatically?. – Alavaros Jun 19 '15 at 07:17
  • How are you generating `rebel.xml`? Via Maven plugin or from IDE? If customizing the `rebel.xml` manually, remove the JRebel Maven plugin and drop the customized file to the `src/main/resources`. If via IDE, just make sure you're using newest IDE plugins and when prompted, don't allow the `rebel.xml` to be regenerated. For further questions contact *support@zeroturnaround.com*. – Henri Viik Jun 19 '15 at 10:16
  • @henri-vik I've just update the post with more information. – Alavaros Jun 19 '15 at 11:57
  • Thank you Henri Vilk, finally this was the solution. I've just update the question with the correct way to do that. – Alavaros Jun 22 '15 at 06:45