Search code examples
springstderratomikos

How to remove/hide Atomikos startup error message?


When Atomikos is configured via Spring, a jta.properties or transactions.properties file is not needed. Nonetheless, Atomikos starts up with the follow messages printed to stderr:

No properties path set - looking for transactions.properties in classpath...
transactions.properties not found - looking for jta.properties in classpath...
Failed to open transactions properties file - using default values

It makes it look like the Spring configuration didn't take -- although apparently everything is fine. Does anyone know how to get rid of this so I don't end up getting asked about it 1.000 times?

Is there a way to redirect stderr from a particular component or jar?


Solution

  • You need to set the system property com.atomikos.icatch.hide_init_file_path to any value. Do this on the java command line. In maven you do this by passing a command line arg to surefire as follows:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
            <argLine>-Dcom.atomikos.icatch.hide_init_file_path=true</argLine>
        </configuration>
    </plugin>
    

    Update: From within a Spring configuration file, you can set the property like this:

    <bean id="atomikosSystemProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetObject">
            <!-- System.getProperties() -->
            <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
                <property name="targetClass" value="java.lang.System" />
                <property name="targetMethod" value="getProperties" />
            </bean>
        </property>
        <property name="targetMethod" value="putAll" />
        <property name="arguments">
            <!-- The new Properties -->
            <util:properties>
                <prop key="com.atomikos.icatch.hide_init_file_path">true</prop>
            </util:properties>
        </property>
    </bean>
    

    Just remember to make your Atomikos beans "depend-on" this bean so the order of instantiation is correct.