Hibernate in Weblogic has a conflicting antlr version. What to do?


#1

We have a problem with migrating our j2ee ear application from weblogic 12.1.1 to weblogic 12.2.1. We use hibernate 5.2.10.Final as a jpa provider and package it into the ear.

Hibernate has an implicit dependency of antlr 2.7.7, so the ear contains this jar too. But weblogic has internally on its classpath an antlr 3.2

We made its classloader prefer the contents of our ear, which is antlr 2.7.7, but this way weblogic throws an exception at some JMS method calls, where we use a JMS expression filtering for correlation id. So this way we lose an application server feature we use.

If we use antlr 3.2 instead, would it be a problem for hibernate? Or what other options we have to use both functionality (hibernate and weblogic)? In eclipselink I checked, that it is solved by the way of repackaging antlr to some org.eclipselink… Is there a hibernate version available like this?


#2

If we use antlr 3.2 instead, would it be a problem for hibernate?

It’s hard to tell without testing it. I think you should check the Antlr release notes for any backward compatibility changes or give it a try and see how it works.

So, the EAR now uses both Hibernate and that JMS functionality which requires ANTLR 3?

Is it possible to split it into 2 EARs, each one with it’s own ANTLR dependency?

You should ask this question on the Weblogic forum as well. They know their application server better and maybe the have some solution for this problem.


#3

Thanks for the response!
The weblogic part is under investigation also in parallel.
Separating the EAR is a good idea, but I think it’s not too trivial in our case, because there are several processes, that use JMS and DB (hibernate) too, many times in one JTA transaction. So it’s one of our last resorts.
In this forum I’d like to get to know our options from the hibernate side: ANTLR compatibility (I will check, thanks), have a hibernate jar with repackaged antlr (maybe with jarjar), anything else.
Is it not a problem for anyone else, that hibernate depends on an old ANTLR and dosent repackage it to another package? Other librarys use antlr also, I think.
I dont even know, for what functionality does hibernate use antlr. So for what does it use? Maybe we dont even use those functionalities, so it would be no problem to use the antlr version which comes with weblogic.

Thanks!


#4

Is it not a problem for anyone else, that hibernate depends on an old ANTLR and doesn’t repackage it to another package? Other libraries use antlr also, I think.

Hibernate is the default JPA provider for Wildfly and JBoss EAP. Wildfly also uses ANTLR 2.7.7, just like Hibernate.

This Jira issue gives you more details on this topic too.

Also, Spring Boot uses ANTLR 2.7.7 as well.


#5

Hi,
we briefly discussed shading on our mailing list; this is what we said so far:

I don’t know exactly how WebLogic deals with such things, but moving just your ANTLR library do a different module - such as a different EAR - should be enough and have no consequences on your transactions.

For what it’s worth, Hibernate ORM uses ANTLR to parse queries. So if you write any query using HQL or JPQL it’s going to be used. Also, other classes might be importing it incidentally as it’s not designed to be an optional dependency so I would not suggest running without it.

As far as I remember ANTLR 3 happens to use different package names than ANTLR 2. Check that, if I remember correctly then you can just use both of them in the same classpath.


#6

I checked, and I remembered correctly: ANTLR 2 and ANTLR 3 use different package names. So you can have both without issues in the same classpath.


#7

Thanks, you’re right! I haven’t recognized it, because it turned out, that in the weblogic antl jar, there"s an antlr 2.7.7 and an antlr 3.2 put into the same jar. And the maven pom is only for the 3.2, so I thought it’s the 3.2 which contains the antlr.* packages also, not just the org.antlr..
So weblogic contains antlr 3.2 and 2.7.7 too (exactly the same classes as those versions I binary compared). The only thing I don’t understand now is that why the weblogic JMS didn’t work when we made weblogic to prefer the antlr.
packages (package of the 2.7.7), but that should be about weblogic and it’s classloaders and JMS impementation.
Thanks again!