jbosstools / m2e-wro4j

m2e connector for WRO4J
Eclipse Public License 2.0
34 stars 12 forks source link

Exception while processing #12

Closed chrisie closed 11 years ago

chrisie commented 11 years ago

I have a maven project with the following wro4j configuration in my pom.xml:

<plugin>
    <groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>1.7.0</version>
<executions>
    <execution>
            <id>main-assets</id>
    <phase>compile</phase>
    <goals>
        <goal>run</goal>
    </goals>
    </execution>
</executions>
<configuration>
    <minimize>false</minimize>
    <contextFolder>${basedir}/src/main/assets/</contextFolder>
        <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
        <cssDestinationFolder>${project.build.directory}/wro/css</cssDestinationFolder>
        <jsDestinationFolder>${project.build.directory}/wro/js</jsDestinationFolder>
        <wroFile>${basedir}/src/main/assets/wro.xml</wroFile>
        <extraConfigFile>${basedir}/src/main/assets/wro.properties</extraConfigFile>
        <ignoreMissingResources>false</ignoreMissingResources>
    </configuration>
</plugin>

The project builds fine with Maven, however I get the following error in Eclipse:

Exception occured while processing: ro.isdc.wro.WroRuntimeException: Processing error, class: ro.isdc.wro.WroRuntimeException,caused by: org.mozilla.javascript.EcmaError Processing error

which results in wro4j not being executed when Eclipse builds the project on save. I assume that the problem is somehow related with my environment or configuration since the same project works fine on a colleague's computer but I can't seem to find what's wrong. I am using Windows 7 64-bit with Eclipse Juno SR2 and 1.7.0_10

alexo commented 11 years ago

Check if you have two different rhino dependencies in the classpath. The latest 1.7.0 release of wro4j comes with a custom rhino dependencies (built from latest snapshot), but has a different groupId. This can cause two different versions of rhino being present in the classpath.

chrisie commented 11 years ago

Thanks for your answer Alexo. I'm guessing you mean the Eclipse classpath, not the project classpath, right? How can I see that?

alexo commented 11 years ago

CTRL+SHIFT+T (search for "EcmaError" class in classpath)

chrisie commented 11 years ago

The search for EcmaError returns one matching class in package sun.org.mozilla.javascript.internal - [jdk1.7.0_10].

alexo commented 11 years ago

Then you don't have the required rhino dependency which is added transitively by wro4j-extensions module (this class is part of that dependency: org.mozilla.javascript.EcmaError).

Are you sure you haven't excluded dependencies explicitly?

chrisie commented 11 years ago

No, I haven't excluded anything. I also checked for EcmaError on the MacBook of a colleague where wro4j executes without any problems and I also see there only the sun.org.mozilla.javascript.internal.EcmaError class.

alexo commented 11 years ago

When running the plugin from command line using mvn wro4j:run everything works fine?

chrisie commented 11 years ago

Yes, the problem is only when Eclipse attempts to run wro4j when building the project itself (not through Maven).

alexo commented 11 years ago

You could try adding the rhino dependency explicitly... not sure if this would make a difference...

chrisie commented 11 years ago

How would I do that? The truth is I'm not too optimistic either since it works on another machine with the same dependencies...

fbricon commented 11 years ago

Christie, can you setup a sample project (in a github repo for instance) that fails in eclipse and runs in CLI?

chrisie commented 11 years ago

I created a sample project here (https://github.com/chrisie/m2e-wro4j-sample). It is in fact an empty project with just a less file which is processed by wro4j to be compiles to css. It runs with Maven (mvn install or just mvn wro4j:run) either in the command line or through Eclipse (Run as Maven build) but when I modify and save the less file in which case Eclipse kicks in and attempts to build it itself it fails with the above error.

chrisie commented 11 years ago

I ended up re-installing Eclipse and all my plugins from scratch which seems to have resolved the problem (for the time being at least). If however at any point you come across this problem again and you figure out what might have caused it and how it can be solved without re-installing Eclipse I'd be really interested in knowing.

alexo commented 11 years ago

I would expect eclipse to use the same dependencies as the maven plugin does. Probably this problem is very hard to reproduce, since it does matter what distribution of eclipse you are using and what plugins are installed.

chrisie commented 11 years ago

Actually, to make matters even worse I think that even the order the plugins are installed might make a difference since I installed the same Eclipse distribution and the same plugins I had installed before, only this time I installed wro4j first to make sure it was working.