Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException (HqlToken) when running in WebLogic

I have a .war file for an application that normally runs fine in Jetty.

I'm trying to port the application to run in WebLogic, but at startup I'm getting these exceptions:

ERROR:Foo - Error in named query: findBar
org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from Bar]
    at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:80)
    at antlr.CharScanner.setTokenObjectClass(CharScanner.java:340)
    at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:54)
    at antlr.CharScanner.<init>(CharScanner.java:51)
    at antlr.CharScanner.<init>(CharScanner.java:60)
    at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:56)
    at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:53)
    at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:50)
    ...

What's the best way to fix this?

I'm using Hibernate 3.3.1.GA and WebLogic 10.3.2.0.

like image 865
leedm777 Avatar asked Apr 23 '10 22:04

leedm777


3 Answers

WebLogic has its own version of ANTLR and this causes the problem you're facing. One way to solve it with a web application is to set the prefer-web-inf-classes element in weblogic.xml to true.

<weblogic-web-app>
  ....
  <container-descriptor>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
  </container-descriptor>
  ....
</weblogic-web-app>

The weblogic.xml goes in WEB-INF.

like image 145
Pascal Thivent Avatar answered Oct 14 '22 17:10

Pascal Thivent


In my opinion the best solution for war: Create file webapp\WEB-INF\weblogic.xml and put the text

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app>
    <container-descriptor>
        <prefer-web-inf-classes>false</prefer-web-inf-classes>
        <prefer-application-packages>
            <package-name>antlr.*</package-name>
        </prefer-application-packages>
    </container-descriptor>
</weblogic-web-app>
like image 41
Alexander Trofimov Avatar answered Oct 14 '22 17:10

Alexander Trofimov


If you have an EAR project like myself then you need to add this element to weblogic ear deployment descriptor [weblogic-application.xml]

<wls:prefer-application-packages>
        <wls:package-name>antlr.*</wls:package-name>
    </wls:prefer-application-packages>
like image 23
shane lee Avatar answered Oct 14 '22 17:10

shane lee