Skip to content

mybatis-3.4.0.jar on IBM's Websphere Application Server 8.5.5.9 #706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
moonfruit opened this issue Jun 12, 2016 · 17 comments
Closed

mybatis-3.4.0.jar on IBM's Websphere Application Server 8.5.5.9 #706

moonfruit opened this issue Jun 12, 2016 · 17 comments
Assignees
Labels
Milestone

Comments

@moonfruit
Copy link

MyBatis version

3.4.0

Mybatis 3.4.0 use shade to integrate javassist and ognl with relocation.

But when deploy war which has mybatis-3.4.0.jar to IBM's Websphere Application Server 8.5.5.9 (Java 7), the war cannot start because of the relocation of javassist.

Then I create a mybatis-3.4.0.jar without javassist and a independent javassist jar put it to my war. And deploy it to IBM's Websphere Application Server, everything is right.

@emacarron
Copy link
Member

emacarron commented Jun 12, 2016

Can you please add some more information about the error? For example the error shown in the log during startup?

Looks the same error that the one reported here:
https://groups.google.com/forum/#!topic/mybatis-user/ZhI4cPe7cq8

You will find a workaround there:

"Well you are right the issue was around javassist pkg in the mybatis jar file. I just got around the issue by adding the the following entries in META-INFMANIFEST.MF now the app starts up fine with no issues.

Manifest-Version: 1.0
Ignore-Scanning-Archives: WEB-INF/lib/mybatis-3.4.0.jar
Ignore-Scanning-Packages: org.apache.ibatis.javassist"

Anyway we should need to find the root cause for this. I will open an issue in the shade tracker.

@emacarron
Copy link
Member

@moonfruit can you open a ticket to IBM so they can bring more information about why is this happening?

@moonfruit
Copy link
Author

https://groups.google.com/forum/#!topic/mybatis-user/ZhI4cPe7cq8
The above is exactly the same one that I met.

@moonfruit
Copy link
Author

Sorry, I cannot open a ticket to IBM.
Because I develop application on WAS for my client, so my client has the license for WAS and I have not.

@harawata
Copy link
Member

The exception in this SO question looks very similar.
By any chance, isn't it possible that the deployed mybatis jar is recompiled during the process?

Please try the following command on the mybatis-3.4.0.jar causing the problem.

$ javap -classpath PATH_TO/mybatis-3.4.0.jar -v org.apache.ibatis.javassist.ByteArrayClassPath | grep major

major version 50 means it's compiled with 1.6 and 52 means 1.8.

@harawata
Copy link
Member

And one more thing. What is your Gradle version?

@moonfruit
Copy link
Author

moonfruit commented Jun 20, 2016

@harawata
No, the question that you mentioned is not the one I met.

As I say, this one below is the one that I met.
https://groups.google.com/forum/#!topic/mybatis-user/ZhI4cPe7cq8

And I do not use Gradle...

@harawata
Copy link
Member

So, did you try the javap command and it returned major version 50?
And what is your Gradle version?

@moonfruit
Copy link
Author

I use Maven to download the jar from central repository, and DO NOT use Gradle.
And I run the command that you give me, yes, it returned major version 50.

@harawata
Copy link
Member

OK...thanks for the answer. :-)

By the way, the report on the forum was using Java 8, so it's not exactly the same.

@harawata
Copy link
Member

harawata commented Jun 22, 2016

In another ticket, a user informed me that Javassist 3.20.0-GA is incorrectly built with '-parameters' compiler option.
javap shows that there is parameter information attached and it could confuse ASM depending on WebSphere implementation, I think.

For testing, I have attached a custom version of mybatis 3.4.0 (you must change the extension to .jar after download).
The only difference from the release version is that it includes Javassist built without parameters info.
It's a long shot as the original Javassist JAR does not cause any problem, but I would appreciate if you could test it and see if it resolves the problem.

FYI, here is how I built it:

  • Clone Javassist and checkout 3.20.0-GA tag.

    $ git clone https://github.com/jboss-javassist/javassist
    $ cd javassist
    $ git checkout refs/tags/rel_3_20_0_ga 
  • Edit pom.xml to apply <source> and <target> is 1.6, but <compilerArgument> "-parameters" in1.8 jboss-javassist/javassist#54

  • Install it to local repo.

    $ mvn clean install -Dmaven.test.skip=true
  • Re-build mybatis 3.4.0 using the new Javassist.

    $ git clone https://github.com/mybatis/mybatis-3
    $ cd mybatis-3
    $ git checkout refs/tags/mybatis-3.4.0
    $ mvn clean package -Dmaven.test.skip=true

@emacarron
Copy link
Member

emacarron commented Jun 22, 2016

Good research Iwao!!

Looks like using 3.18 instead of 3.20 may fix the problem:
http://stackoverflow.com/questions/25279729/tomcat-7-annotation-scanner-and-jdk-8-with-parameters-compiler-flag-exceptions

@moonfruit please we need a confirmation.

update: Looks like current Javassist trunk has already fixed the problem:
jboss-javassist/javassist@0e40ca2#diff-600376dffeb79835ede4a0b285078036

emacarron referenced this issue in jboss-javassist/javassist Jun 22, 2016
@harawata
Copy link
Member

Hi Eduardo,

If the fix is verified and we release 3.4.1 soon, I think it's OK to use the custom build of Javassist 3.20.0-GA considering that the difference is just a compiler option and the fix is already committed.

Anyway, first thing first, I'll ask the reporter on the forum if he could test the fix.

@moonfruit
Copy link
Author

moonfruit commented Jun 23, 2016

Hi, @emacarron and @harawata,

I test mybatis 3.4.0 built with javassist 3.18 and mybatis 3.4.0 built with no '-parameters' javassist 3.20, and they both have no problems when I deploy my war with them separately on WAS 8.5.5.9.
I think you found the real reason for this issue.

Thanks for all your work!

But I also have to remind you that this issue only happened with relocation javassist. At the very beginning, I test a mybatis 3.4.0 with no javassist built in and a independent javassist 3.20 jar on WAS 8.5.5.9, and it can also work.

@emacarron
Copy link
Member

Thanks for checking @moonfruit

@harawata agreed. Now we know this is the root cause I am OK with realeasing 3.4.1. There are 7 closed issues (with this one) so it is a good pack.

Thank you both for your help!

@emacarron emacarron added this to the 3.4.1 milestone Jun 23, 2016
@emacarron emacarron added the bug label Jun 23, 2016
@harawata
Copy link
Member

harawata commented Jun 23, 2016

@moonfruit

Thank you very much for testing!

But I also have to remind you that this issue only happened with relocation javassist.

The stacktrace shows that the RuntimeException is thrown at the following code in ASM.

public void visitParameter(String name, int access) {
  if (api < Opcodes.ASM5) {
    throw new RuntimeException();
  }
  // ...
}

WebSphere evidently uses Opcodes.ASM4 when scanning mybatis JAR and throws the exception.
I can only imagine, but the logical explanation would be that WebSphere either 1) does not scan independent Javassist JAR or 2) uses Opcodes.ASM5 when scanning it for somehow.

@emacarron

👍 for 3.4.1 =D

@harawata
Copy link
Member

Just FYI, this issue is planned to be fixed in WAS 8.5.5.11.
http://www-01.ibm.com/support/docview.wss?uid=swg1PI60902

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants