1

I get the Eclipse error below when starting my application in Tomcat (via Run As > Run on Server.) I'm using the DataNucleus Eclipse Plugin and have it set up to Enable Auto-Enhancement.

Publishing failed with multiple errors
Resource is out of sync with the file system: '/myproject/target/classes/com/mysite/models/Inventory.class'.
Resource is out of sync with the file system: '/myproject/target/classes/com/mysite/models/Product.class'.

I understand I can manually trigger refresh on that project every time I want to run the project on server. Are there ways to overcome that inconvenience?

Note: I also understand Eclipse can be configured to refresh on access, using native hooks, or using polling. However, that triggers multiple unnecessary runs of datanucleus:enhance. Additionally, the problem is compounded when Tomcat is configured to automatically publish when resources change or after a build event.

For reference, relevant excerpts of my pom.xml are below

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <packaging>war</packaging>

    <properties>
        <datanucleus.core.version>3.2.12</datanucleus.core.version>
        <datanucleus.api.version>3.0.1</datanucleus.api.version>
    </properties>

    <dependencies>
        <!-- Database See http://www.datanucleus.org/products/datanucleus/jdo/maven.html -->
        <dependency>
            <groupId>javax.jdo</groupId>
            <artifactId>jdo-api</artifactId>
            <version>${datanucleus.api.version}</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-core</artifactId>
            <version>${datanucleus.core.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-api-jdo</artifactId>
            <version>[3.2.0, 3.2.99)</version>
        </dependency>
        <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-rdbms</artifactId>
            <version>[3.2.0, 3.2.99)</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>2.3.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- JDO Enhancer See http://www.datanucleus.org/products/datanucleus/jdo/guides/eclipse.html -->
            <plugin>
                <groupId>org.datanucleus</groupId>
                <artifactId>datanucleus-maven-plugin</artifactId>
                <version>3.3.0-release</version>
                <configuration>
                    <log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
                    <verbose>true</verbose>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.datanucleus</groupId>
                        <artifactId>datanucleus-core</artifactId>
                        <version>${datanucleus.core.version}</version>
                    </dependency>
                    <dependency>
                        <groupId>javax.jdo</groupId>
                        <artifactId>jdo-api</artifactId>
                        <version>${datanucleus.api.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>enhance</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-enforcer-plugin</artifactId>
                                        <versionRange>[1.0.0,)</versionRange>
                                        <goals>
                                            <goal>enforce</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.datanucleus
                                        </groupId>
                                        <artifactId>
                                            datanucleus-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [3.3.0-release,)
                                        </versionRange>
                                        <goals>
                                            <goal>enhance</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
icma
  • 81
  • 3
  • 1
    have you tried this http://stackoverflow.com/questions/5618652/publishing-failed-with-multiple-errors-eclipse – Marquis Blount Feb 28 '14 at 23:57
  • @MarquisBlount Appreciate the response. Yes, I've tried that. "I also understand Eclipse can be configured to refresh on access, using native hooks, or using polling." I'm also not technically editing any files outside of Eclipse. The DataNucleus plugin is "editing" the files automatically. – icma Mar 01 '14 at 20:05
  • hmm interesting. Is your project set to build automatically. Project -> Select Build automatically ? I fear even with build automatically selected but not having auto refresh enabled your files may still get stale. But give Build automatically a try you may get lucky IDEs are so finicky – Marquis Blount Mar 03 '14 at 18:25
  • @MarquisBlount Yes, build automatically is enabled. My guess is that DataNucleus Plugin's Enable Auto-Enhancement works independently of Eclipse's build. Because of that, the workspace doesn't get synced. – icma Mar 03 '14 at 21:54

0 Answers0