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.
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
.
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>
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With