views:

302

answers:

2

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.

+2  A: 

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.

Pascal Thivent
+1.. I just wonder why "true" isn't the default value of the setting?
Bozho
@Bozho Not sure what the Java EE spec says about that but a parent first strategy seems logical to me.
Pascal Thivent
That fixed it. It caused a seperate ClassCastException, which was fixed by following the advice in this post: http://forum.springsource.org/archive/index.php/t-22597.html
dave
A: 

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>
shane lee