mysticfall / pivot4j

Pivot4J provides a common API for OLAP servers which can be used to build an analytical service frontend with pivot style GUI.
Other
128 stars 99 forks source link

Cannot find CupParser: build failure on HEAD and 0.9 #177

Closed nczempin closed 9 years ago

nczempin commented 9 years ago

I am trying to get the example project running, but run into several build issues. First of all I have to insert into all poms or I get errors.

Once I have done that, maven install fails looking for one of the generated files: [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project pivot4j-core: Compilation failure: Compilation failure: [ERROR] /Users/nczempin/pivot4j/pivot4j-core/src/main/java/org/pivot4j/mdx/impl/MdxParserImpl.java:[21,28] cannot find symbol [ERROR] symbol: class CupParser [ERROR] location: package org.pivot4j.mdx.impl [ERROR] /Users/nczempin/pivot4j/pivot4j-core/src/main/java/org/pivot4j/mdx/impl/MdxParserImpl.java:[37,25] cannot find symbol [ERROR] symbol: class CupParser [ERROR] location: class org.pivot4j.mdx.impl.MdxParserImpl [ERROR] /Users/nczempin/pivot4j/pivot4j-core/src/main/java/org/pivot4j/mdx/impl/MdxParserImpl.java:[37,48] cannot find symbol [ERROR] symbol: class CupParser [ERROR] location: class org.pivot4j.mdx.impl.MdxParserImpl

The file is never generated in the first place. I tried this from HEAD and with 0.9. I tried this first on MacOS, then on Windows, and finally on a colleague's Ubuntu, in which building from HEAD had been working properly in September (where, AFAIK, the was not necessary).

Using Eclipse Luna 64 bit on Mac and Windows, with JDK 1.8. Same error occurs when starting Maven from the command line.

I had managed to get a 0.8 version working, but I don't remember the details of what I did to get it working. I think they may also have been related to the cup plugin.

nczempin commented 9 years ago

As a workaround, I manually copied the three generated files CupParser.java, Symbols.java, Yylex.java. into the src/ tree and it seems to work now.

nczempin commented 9 years ago

I'm assuming that people who currently use pivot4j from source will already have these files generated. To reproduce the original issue, please try it from a fresh checkout.

nczempin commented 9 years ago

When I call mvn cup:generate on its own in pivot4j-core, I get this error message:

[ERROR] Failed to execute goal edu.tum.cs:cup-maven-plugin:1.0.0:generate (default-cli) on project pivot4j-core: Execution default-cli of goal edu.tum.cs:cup-maven-plugin:1.0.0:generate failed: Unable to load the mojo 'generate' in the plugin 'edu.tum.cs:cup-maven-plugin:1.0.0' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: edu/tum/cs/CupGenerator : Unsupported major.minor version 51.0 [ERROR] ----------------------------------------------------- [ERROR] realm = plugin>edu.tum.cs:cup-maven-plugin:1.0.0 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [ERROR] urls[0] = file:/Users/nczempin/.m2/repository/edu/tum/cs/cup-maven-plugin/1.0.0/cup-maven-plugin-1.0.0.jar [ERROR] urls[1] = file:/Users/nczempin/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar [ERROR] urls[2] = file:/Users/nczempin/.m2/repository/net/sf/squirrel-sql/thirdparty-non-maven/java-cup/0.11a/java-cup-0.11a.jar [ERROR] urls[3] = file:/Users/nczempin/.m2/repository/commons-io/commons-io/1.2/commons-io-1.2.jar [ERROR] urls[4] = file:/Users/nczempin/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar [ERROR] Number of foreign imports: 1 [ERROR] import: Entry[import from realm ClassRealm[project>org.pivot4j:pivot4j-core:1.0-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]

Version 51 is Java 1.7, this possibly clashes with the pivot4j setting of 1.6.

nczempin commented 9 years ago

Note also that the source and target of the cup Maven plugin changed on August 3rd: https://github.com/vbmacher/cup-maven-plugin/blob/ffd3db7cd2d0305098eec5f8ab0ef8efdcc012cf/pom.xml

mysticfall commented 9 years ago

Hi,

Sorry for the late response. I tested building the master branch from clean state but was unable to reproduce such an error on my Linux desktop.

Both mvn install in the top level project, and mvn cup:generate in pivot4j-core runs without any error.

However, I found a encoding problem when I tried it on my Windows partition, which prevented the generated parser files from being compiled properly:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.9.1:jar (javadoc-jar) on project pivot4j-core: MavenReportException: Error while creating archive:
[ERROR] Exit code: 1 - C:\Users\fender\git\pivot4j\pivot4j-core\target\generated-sources\parser\org\pivot4j\mdx\impl\Yylex.java:1: error: unmappable character for encoding UTF-8
[ERROR] /* The following code was generated by JFlex 1.4.3 on 15. 1. 22 ???? 6:10 */
[ERROR] ^

It's caused by incorrectly encoded characters in the generated Javadoc comments, and I could workaround the problem by removing them by hand and restart the build process. This problem seems to happen on non-English Windows environment only, and should be fixed as a separate issue.

I tested with both Java 1.7 and 1.8 and got the same result. By the way, the compiler/source setting of version '1.6' should not prevent it from running on later version of JVMs. The error message with 'Unsupported major.minor version 51.0' strongly suggest that we use different versions of the CUPS plugin, and yours was built with 1.7+ compatibility settings.

I deleted my local cache of the edu.tum.cs:cup-maven-plugin:1.0.0 plugin from the Maven repository, and got the same result. So, I suppose it might be worth a shot if you could do the same and see if it resolves the problem.

And thanks for the head up on the library update :)

nczempin commented 9 years ago

Hmm, "my" version of CUPS should in principle be the same as yours. I will try deleting my local version. What I don't understand is that my colleague built pivot4j in September, with everything working fine, and when he ran Maven again in January, with no changes in between, he got the same error I got.

Is there no likely relation between the Maven plugin for CUP changing to 1.7 compatibility (without changing the version number? Is that supposed to work? Not a Maven expert, sorry) and what I'm seeing? I guess it doesn't explain why it would work for you; are you sure you don't have any other repository caches configured that may still have the 1.6 version?

mysticfall commented 9 years ago

After some thought, I suppose it's unlikely that any of us have a custom built CUPS plugin which could cause such a problem.

Maybe more probable explanation could be that you're somehow using Java 1.6 to build Pivot4J, but CUPS plugin itself is only compatible with Java 1.7+

As you know, specifying version compatibility in maven POM only affects binary compatibility of the built library. So, the specified version 1.6 in Pivot4J's POM does not change anything about Maven's runtime environment, which is determined by JAVA_HOME environment variable.

So, please double check that you're building Pivot4J with Java 7 or 8 and see if it changes anything.

nczempin commented 9 years ago

When building mvn from the command line I'm definitely using 1.8. Your hypothesis doesn't account for my colleague's result that it used to work and now it doesn't. He hasn't changed anything (although I haven't checked this with him, I am fairly confident that he hasn't switched to 1.6).

mysticfall commented 9 years ago

Of course, my explanation is just a theory I thought was the most probable. But if I'm not mistaken, there's no other possible explanation than that the runtime environment was somehow 1.6 or lower when you get such an error like "Unsupported major.minor version 51.0".

It's not even Maven specific and it's telling us that the JVM it's running on cannot understand the class format of version 51.0 because the format is not backward compatible.

So, please try mvn clean then mvn -version to verify you're indeed using Java 1.7+. And if it says it's Java 1.7 then try rebuilding the project.

nczempin commented 9 years ago

Oh, wow.

WTF?

Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T18:29:23+01:00)
Maven home: /Library/Maven/apache-maven-3.2.5
Java version: 1.6.0_65, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.9.5", arch: "x86_64", family: "mac"

I guess I have some homework to do; I'll get back to you. Still wondering about my colleague though, plus I'll have to check on my Windows machine what's going on there.

mysticfall commented 9 years ago

Mystery solved! (at least half of it) :)

Anyway, I'm going to close this issue, so please reopen it with more information if you find anything interesting.

Thanks!

nczempin commented 9 years ago

This is what confused me:

$java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

Time to look at my Maven settings, and do a bit of housecleaning.

Good job on solving the mystery (for now; I'll have to figure out the other open questions to be sure that this was the only issue. Since I currently have a workaround, I'm not in desparate need for the proper solution, so it might be a while before I get around to checking the details.