java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String [英] java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String

查看:21
本文介绍了java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Omnifaces 1.3 + Primefaces 3.4.1 + Jboss 7.1.1 Final,但我无法通过在我的 web.xml 上配置的 FullAjaxExceptionHandler 重定向异常代码> 当他们通过 ajax 请求来的时候.什么也没发生,只是另一个异常:

I'm using Omnifaces 1.3 + Primefaces 3.4.1 + Jboss 7.1.1 Final but I just can't redirect the exceptions with the FullAjaxExceptionHandler configured on my web.xml when they come by ajax request. Nothing happens, just an another exception:

19:38:05,467 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/taxMileage].[Faces Servlet]] (http--0.0.0.0-8181-4) Servlet.service() for servlet Faces Servlet threw exception: java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String;
    at org.omnifaces.config.WebXml.parseErrorPageLocations(WebXml.java:216) [omnifaces-1.3.jar:1.3]
    at org.omnifaces.config.WebXml.<init>(WebXml.java:84) [omnifaces-1.3.jar:1.3]
    at org.omnifaces.config.WebXml.<clinit>(WebXml.java:53) [omnifaces-1.3.jar:1.3]
    at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handleAjaxException(FullAjaxExceptionHandler.java:162) [omnifaces-1.3.jar:1.3]
    at org.omnifaces.exceptionhandler.FullAjaxExceptionHandler.handle(FullAjaxExceptionHandler.java:145) [omnifaces-1.3.jar:1.3]
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119) [jsf-impl-2.1.7-jbossorg-2.jar:]
    at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

有人可以给我一个提示吗?我被困住了.如果我在没有 ajax 的情况下调用相同的错误,则异常会正确重定向.

Can someone give-me a tip about this? I'm stuck. If I call the same error without ajax the exception is redirected correctly.

我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0"
>
    <display-name>taxMileage</display-name>
    <welcome-file-list>
        <welcome-file>/pages/protected/user/dashboard.xhtml</welcome-file>
    </welcome-file-list>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet>
        <servlet-name>InitializeApplication</servlet-name>
        <servlet-class>com.taxMileage.server.util.InitializeApplication</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <context-param>
        <param-name>primefaces.THEME</param-name>
        <param-value>south-street</param-value>
    </context-param>
    <filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    <filter>
        <filter-name>facesExceptionFilter</filter-name>
        <filter-class>org.omnifaces.filter.FacesExceptionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>facesExceptionFilter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>*.jsf</url-pattern>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

    <!-- -->

    <!-- Protected area definition -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Restricted Area - ADMIN Only</web-resource-name>
            <url-pattern>/pages/protected/admin/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>ADMIN</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Restricted Area - USER and ADMIN</web-resource-name>
            <url-pattern>/pages/protected/user/*</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <role-name>USER</role-name>
            <role-name>ADMIN</role-name>
        </auth-constraint>
    </security-constraint>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Secured resources</web-resource-name>
            <url-pattern>/rest/*</url-pattern>
        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>
    </security-constraint>

    <!-- Login page -->
    <login-config>
        <auth-method>FORM</auth-method>
        <form-login-config>
            <form-login-page>/pages/public/login.xhtml</form-login-page>
            <form-error-page>/pages/public/loginError.xhtml</form-error-page>
        </form-login-config>
    </login-config>

    <!-- System roles -->
    <security-role>
        <role-name>ADMIN</role-name>
    </security-role>
    <security-role>
        <role-name>USER</role-name>
    </security-role>

    <error-page>
        <exception-type>java.lang.RuntimeException</exception-type>
        <location>/pages/error/error1.xhtml</location>
    </error-page>
</web-app>

我的faces-config.xml:

<?xml version="1.0" encoding="UTF-8"?>

<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_1.xsd"
    version="2.1">

    <lifecycle>
        <phase-listener>com.taxMileage.server.util.MultiPageMessagesSupport</phase-listener>
    </lifecycle>

    <factory>
        <exception-handler-factory>org.omnifaces.exceptionhandler.FullAjaxExceptionHandlerFactory</exception-handler-factory>
    </factory>

    <application>
        <resource-bundle>
            <base-name>messages</base-name>
            <var>msgs</var>
        </resource-bundle>
    </application>
</faces-config>

谢谢!

推荐答案

java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String;

java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String;

当您的 WAR 的 /WEB-INF/lib(或什至 JRE 的 /lib)中有 Xerces JAR 文件时,会发生这种情况,该文件的版本比servletcontainer 内部使用的一个.旧版本,显然实现了 的 JAXPJava 1.4.2 或更早版本,缺少在 Java 1.5.

This will happen when there are Xerces JAR files in your WAR's /WEB-INF/lib (or even JRE's /lib) which is of an older version than the one internally used by the servletcontainer. The older version, which apparently implements JAXP of Java 1.4.2 or older, is missing the mentioned method which was introduced in JAXP of Java 1.5.

有两个选项:

  1. 将 Xerces JAR 文件升级到至少与使用 servletcontainer 的版本匹配的更新版本.

  1. Upgrade Xerces JAR files to a newer version matching at least the one used the servletcontainer.

/WEB-INF/lib 中删除那些 Xerces JAR 文件.他们实际上不属于那里.servletcontainer 带有它自己的 JAXP 实现.你不需要通过 webapp 提供你自己的.

Remove those Xerces JAR files from /WEB-INF/lib. They do actually not belong there. The servletcontainer comes with its own JAXP implementation. You don't need to supply your own via the webapp.

推荐选项 2.使用依赖管理框架(如 Maven)时要小心.即使 API 已经是 Java SE 的一部分,一些糟糕的库也会特别包含 JAXP 实现作为传递依赖.

Option 2 is recommended. Watch out when using a dependency management framework such as Maven. Some poor libraries will specifically include a JAXP implementation as a transitive dependency even though the API is already part of Java SE.

请注意,具体问题与 OmniFaces 无关.它只是由类路径污染引起的.OmniFaces 使用 JAXP 解析 web.xml(和 web-fragment.xml)并提取错误页面位置.更新:这个特定异常不应该再发生,因为 OmniFaces 2.0 就像 issue 90getFirstChild().getNodeValue() 替换了 getTextContent() 调用.

Note that the concrete problem is unrelated to OmniFaces. It's just caused by classpath pollution. OmniFaces uses JAXP to parse the web.xml (and web-fragment.xml) and extract the error page locations. Update: this specific exception shouldn't occur anymore since OmniFaces 2.0 as it has as per issue 90 replaced getTextContent() calls by getFirstChild().getNodeValue().

这篇关于java.lang.AbstractMethodError: org.apache.xerces.dom.ElementImpl.getTextContent()Ljava/lang/String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆