Mybatis-3: The mybatis-3.4.2.jar (inside mybatis-3.4.2.zip provided at release page) is require Java 8 runtime

Created on 18 Jan 2017  ·  7Comments  ·  Source: mybatis/mybatis-3

MyBatis version

3.4.2

Database vendor and version

Test case or example project

Steps to reproduce

The mybatis-3.4.2 released at Jan 2017 was compiled by Java 8. I think it should be complied by Java 6 unless the java that mybatis supports is upgraded to java 8.

  1. Make a sample code for my batis
  2. Run it with mybatis-3.4.2.jar by java 6

Expected result

These must be no error used in java 6

Actual result

java.lang.UnsupportedClassVersionError happens.

java.lang.UnsupportedClassVersionError: org/apache/ibatis/io/Resources : Unsupported major.minor version 52.0 (unable to load class org.apache.ibatis.io.Resources)
at org.apache.catalina.loader.WebappClassLoaderBase.findClassInternal(WebappClassLoaderBase.java:2271)
at org.apache.catalina.loader.WebappClassLoaderBase.findClass(WebappClassLoaderBase.java:811)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1254)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)

Status

We has been replaced already the .zip archive with the valid one.
(https://github.com/mybatis/mybatis-3/releases/tag/mybatis-3.4.2)

bug

Most helpful comment

mybatis-3.4.2 needs to be complied by Java 6

MyBatis 3.4.2+ requires Java 8 to build, but runs fine on Java 6.
It is to support some features that requires Java 7+ API.

java.lang.UnsupportedClassVersionError happens.

It should not happen if you are using the JAR in the official release.
When building MyBatis, you need to specify the right maven profile.

$ mvn clean package -Pjava16

Closing as it's not a bug.

All 7 comments

mybatis-3.4.2 needs to be complied by Java 6

MyBatis 3.4.2+ requires Java 8 to build, but runs fine on Java 6.
It is to support some features that requires Java 7+ API.

java.lang.UnsupportedClassVersionError happens.

It should not happen if you are using the JAR in the official release.
When building MyBatis, you need to specify the right maven profile.

$ mvn clean package -Pjava16

Closing as it's not a bug.

I've confirmed the class version using javap command as follow:

$ javap -v Resources
警告: バイナリ・ファイルResourcesにorg.apache.ibatis.io.Resourcesが含まれています
Classfile /Users/xxx/tmp/mybatis-3.4.2/org/apache/ibatis/io/Resources.class
  Last modified 2017/01/02; size 4668 bytes
  MD5 checksum 71075a53c6c293a83b5052cee4b7fb80
  Compiled from "Resources.java"
public class org.apache.ibatis.io.Resources
  minor version: 0
  major version: 50
  flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
...

It's building for running on Java 6+.

The manifest says it all...it's designed from the parent to log in the manifest what jdk version it is targetting. Plus as others noted, we are only using various jdks for testing purposes.

From manifest off maven central....

X-Compile-Target-JDK: 1.6
X-Compile-Source-JDK: 1.6

So it is definitely compiled with java 6. So I'm curious as to how that error was even encountered. For one that would mean adding at least property values to switch the compiler to use java 8. The profiles don't matter at all in this case as that is for test only. Can you provide any more info on what you did specifically to result in this?

Hi,

Here are the steps I did.

  1. I downloadedmybatis-3.4.2.zip https://github.com/mybatis/mybatis-3/releases/download/mybatis-3.4.2/mybatis-3.4.2.zip from https://github.com/mybatis/mybatis-3/releases https://github.com/mybatis/mybatis-3/releases.
  2. I unzipped the zip.
  3. I extracted mybatis-3.4.2.jar to jar folder.
  4. I ran the following command and it said it was a Java 8 class.

Z:\Downloads\mybatis-3.4.2\jar\org\apache\ibatis\io>javap -v Resources.class | findstr version
minor version: 0
major version: 52

But when I did same thing with mybatis-3.4.3-20170117.233125-7.jar https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis/3.4.3-SNAPSHOT/mybatis-3.4.3-20170117.233125-7.jar from https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis/3.4.3-SNAPSHOT/ https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis/3.4.3-SNAPSHOT/
It said it was a Java 6 class.

Z:\Downloads\mybatis-3.4.3\jar\org\apache\ibatis\io>javap -v Resources.class | findstr version
minor version: 0
major version: 50

The both have same target and source JDK 1.6

X-Compile-Target-JDK: 1.6
X-Compile-Source-JDK: 1.6

But the build Jdk is different.

mybatis-3.4.2.jar was built by JDK 1.8.0_111

X-Compile-Target-JDK: 1.6
X-Compile-Source-JDK: 1.6
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.8.0_111

and mybatis-3.4.3-20170117.233125-7.jar was built by JDK 1.8.0_31

X-Compile-Target-JDK: 1.6
X-Compile-Source-JDK: 1.6
Created-By: Apache Maven Bundle Plugin
Build-Jdk: 1.8.0_31

I guess there are some changes on JDK 1.8.0_111 and it caused the issue.

Thank you,
JB.

On Jan 18, 2017, at 10:20 PM, Jeremy Landis notifications@github.com wrote:

The manifest says it all...it's designed from the parent to log in the manifest what jdk version it is targetting. Plus as others noted, we are only using various jdks for testing purposes.

From manifest off maven central....

X-Compile-Target-JDK: 1.6
X-Compile-Source-JDK: 1.6

So it is definitely compiled with java 6. So I'm curious as to how that error was even encountered. For one that would mean adding at least property values to switch the compiler to use java 8. The profiles don't matter at all in this case as that is for test only. Can you provide any more info on what you did specifically to result in this?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/mybatis/mybatis-3/issues/900#issuecomment-273671684, or mute the thread https://github.com/notifications/unsubscribe-auth/ARGsUrbd1dF3y_gLc-vbgiMyP3Se8ax0ks5rTtZ5gaJpZM4LnZ7o.

Actually, the .zip archive on the release page contained classes with wrong version (my bad!).
I have already replaced the .zip archive with the valid one, so please download it again.

@hazendaz ,
Is it possible to specify the compiler version explicitly in bundle profile?
Or I might make the same mistake again in the future ;D

Thank you so much,
JB

On Jan 19, 2017, at 8:54 AM, Iwao AVE! notifications@github.com wrote:

Actually, the .zip archive on the release page https://github.com/mybatis/mybatis-3/releases/tag/mybatis-3.4.2 contained classes with wrong version (my bad!).
I have already replaced the .zip archive with the valid one, so please download it again.

@hazendaz https://github.com/hazendaz ,
Is it possible to specify the compiler version explicitly in bundle profile?
Or I might make the same mistake again in the future ;D


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/mybatis/mybatis-3/issues/900#issuecomment-273781497, or mute the thread https://github.com/notifications/unsubscribe-auth/ARGsUlBrN9aGQTCv3DZIygUdMWMQLvKMks5rT2sBgaJpZM4LnZ7o.

Thank you for taking the time to report! =)

Was this page helpful?
0 / 5 - 0 ratings