代码之家  ›  专栏  ›  技术社区  ›  leedm777 om-nom-nom

在WebLogic中运行时出现ClassNotFoundException(hqltoken)

  •  8
  • leedm777 om-nom-nom  · 技术社区  · 16 年前

    我有一个.war文件,用于在jetty中正常运行的应用程序。

    我正试图将应用程序移植到WebLogic中运行,但在启动时出现了以下异常:

    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)
        ...
    

    最好的解决办法是什么?

    我正在使用hibernate 3.3.1.ga和weblogic 10.3.2.0。

    6 回复  |  直到 12 年前
        1
  •  12
  •   Pascal Thivent    16 年前

    weblogic有自己的antlr版本,这导致了您所面临的问题。使用Web应用程序解决此问题的一种方法是设置 prefer-web-inf-classes 元素在 weblogic.xml 到 true .

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

    这个 WebLogig.xml 进去 WEB-INF .

        2
  •  11
  •   Alexander Trofimov    13 年前

    在我看来 war : 创建文件 webapp\WEB-INF\weblogic.xml 把文字

    <?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>
    
        3
  •  6
  •   shane lee    16 年前

    如果您有一个像我这样的ear项目,那么您需要将这个元素添加到weblogic ear部署描述符中[ weblogic-application.xml ]

    <wls:prefer-application-packages>
            <wls:package-name>antlr.*</wls:package-name>
        </wls:prefer-application-packages>
    
        4
  •  2
  •   Karthik N G    13 年前

    我想在weblogic 11g(weblogic server 10.3.5)上部署war文件。通常,在web应用程序中会有web.xml。为了使weblogic能够获取web.xml中提到的类,我们需要在WEB-INF/weblogic.xml中包含一个文件。下面是代码。

        <?xml version="1.0" encoding="UTF-8"?>
        <weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
        <context-root>ProjectName</context-root>
        <container-descriptor>
        <prefer-web-inf-classes>true</prefer-web-inf-classes>
        </container-descriptor>
        </weblogic-web-app>
    

    这为我解决了这个问题,我能够在weblogic上部署这场战争。请从WebLogic控制台启用Web存档选项。

        5
  •  1
  •   Ed Griebel    15 年前

    我有一个ear,所以我必须添加一个文件meta-inf/weblogic-application.xml

    文件本身非常简单,这是针对Oracle Weblogic 11g的,也就是Weblogic Server 10.3.x:

    <? xml version="1.0" ?>
    <weblogic-application>
      <prefer-application-packages>
        <package-name>antlr.*</package-name>
      </prefer-application-packages>
    </weblogic-application>
    
        6
  •  0
  •   mwhs    13 年前

    对于那些尝试上述方法来声明 antlr 命名空间中的“首选应用程序包” weblogic-application.xml 描述符,如果仍然有相同的问题,则可以尝试直接用项目的库重写启动脚本中WebLogic域的类路径:

    为此,请执行以下步骤:

    1.)找到文件 bin/startWeblogic.[sh|cmd] 在您的WebLogic域主页中

    2)找出上面写着 set SAVE_CLASSPATH=

    3.)替换为这个(在windows上,相应地适应mac/*nix)

    set CLASSPATH=C:\SomeProject\WebContent\WEB-INF\lib\*;%SAVE_CLASSPATH%
    rem set CLASSPATH=%SAVE_CLASSPATH%
    
    set SAVE_CLASSPATH=
    

    4.)保存(重新)启动WebLogic域并交叉手指。

    not a bene:如果您的域中有多个已部署的人工制品,那么这可能不是一个好主意。在某些情况下,它可能只能从WEB-INF/lib文件夹中选择相关的JAR文件。当然,如果您使用maven,您将需要在其他地方托管这些库。

    此解决方案还适用于从EclipseServers视图中启动的WebLogic服务器,因为Oracle WebLogic适配器使用命令行脚本启动服务器。