Search code examples
javagwtguicegwt-gin

GWT Gin 2.1 Unsupported major.minor version 51.0


I am getting an error when trying to compile gwt project that is typically caused by a jre 1.7 (51.0) compiled class. I have verified that my classes are getting compiled with 1.6 version. I am almost positive that this is some other class that is getting included on the classpath but I am unable to get the gwt compiler to break when debugging a maven build. I am using eclipse to attempt to break debug maven build and adding breakpoints for the UnsupportClassVersionError and the UnableToCompleteException but the jvm is not stopping when this occurrs. I am GUESSING that maybe the GWT compiler is running under a separate process and I won't be able to easily catch those exceptions. Any pointers would be greatly appreciated. I would rather find a way to break on gwt exceptions but if someone knows why GIN is complaining about invalid class revisions that would be great too.

Here is the error when I am attempting to compile from command line using maven.

[INFO] --- gwt-maven-plugin:2.5.1:compile (default) @ smartbar ---
[INFO] Loading inherited module 'com.smartbar.SmartBar'
[INFO]    Loading inherited module 'com.smartbar.SmartBarCommon'
[INFO]       Loading inherited module 'com.google.gwt.inject.Inject'
[INFO]          [ERROR] Unexpected error while processing XML
[INFO] java.lang.UnsupportedClassVersionError: com/google/gwt/inject/rebind/GinjectorGenerator : Unsupported major.minor version 51.0
[INFO]  at java.lang.ClassLoader.defineClass1(Native Method)
[INFO]  at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
[INFO]  at java.lang.ClassLoader.defineClass(ClassLoader.java:615)


chinshaw$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)


chinshaw$ find . -name '*.class' | xargs file | head -10
    ./WEB-INF/classes/com/testing/client/activity/AbstractActivity.class:                                compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/activity/EstablishmentInventoryActivity.class:                  compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/activity/EstablishmentNavigationActivity.class:                 compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/ClientUserSession.class:                                        compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/EntityEditEvent$Handler.class:                           compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/EntityEditEvent.class:                                   compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/InventoryItemSelectionEvent$Handler.class:               compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client/events/InventoryItemSelectionEvent.class:                       compiled Java class data, version 50.0 (Java 1.6)
    ./WEB-INF/classes/com/testing/client

Temporary Solution

This may be just a problem with the maven repository but it appears that the 2.1.0 gin package is built with 1.7.0. I downgraded my dependencies to 2.0.0 and it works fine now.

desktop-mini:2.1.0 chinshaw$ pwd
/Users/chinshaw/.m2/repository/com/google/gwt/inject/gin/2.1.0
desktop-mini:inject chinshaw$ find . -name '*.class'  -exec file {} \; | head -10
./client/AbstractGinModule.class: compiled Java class data, version 51.0
./client/assistedinject/BindingCollector.class: compiled Java class data, version 51.0
./client/assistedinject/FactoryModule.class: compiled Java class data, version 51.0
./client/assistedinject/GinFactoryModuleBuilder.class: compiled Java class data, version 51.0
./client/AsyncProvider.class: compiled Java class data, version 51.0
./client/binder/GinAnnotatedBindingBuilder.class: compiled Java class data, version 51.0
./client/binder/GinAnnotatedConstantBindingBuilder.class: compiled Java class data, version 51.0
./client/binder/GinAnnotatedElementBuilder.class: compiled Java class data, version 51.0
./client/binder/GinBinder.class: compiled Java class data, version 51.0
./client/binder/GinConstantBindingBuilder.class: compiled Java class data, version 51.0

Here's the bug id, wish I had looked there first. Assumed it was a problem with another jar first though. http://code.google.com/p/google-gin/issues/detail?id=190


Solution

  • The enforceBytecodeVersion Enforcer Rule should be able to help you with these kind of issues. It'll go through all the dependencies to check if they match the required class version.