蜡染依赖在 Payara 中不起作用

Batik dependency not working in Payara

我有一个使用 batik-bridge 1.6-1 依赖项的 jsf 项目。 当我 运行 glassfish 4.1.1 上的项目时,它工作得很好,但是当我使用 Payara 4.1.2.173 时,我得到这个错误堆栈

 Grave:   org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/secure-processing
    at org.apache.xerces.parsers.AbstractSAXParser.setFeature(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.setFeatures(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.<init>(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParserImpl(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserFactoryImpl.setFeature(Unknown Source)
    at org.eclipse.persistence.internal.helper.XMLHelper.createParserFactory(XMLHelper.java:98)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:628)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:617)
    at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.getPersistenceUnits(PersistenceUnitProcessor.java:503)
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchive(JPAInitializer.java:178)
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfoInArchives(JPAInitializer.java:160)
    at org.eclipse.persistence.internal.jpa.deployment.JPAInitializer.findPersistenceUnitInfo(JPAInitializer.java:141)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:188)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)
   ...

这是产生错误的代码部分:

    @Stateless
    public class MyEventListener extends DescriptorEventAdapter {
    @PersistenceContext(unitName = StaticUtil.UNIT_NAME)
    private EntityManager em;

    protected EntityManager getEntityManager() {
        EntityManagerFactory entityFactory = Persistence.createEntityManagerFactory(StaticUtil.UNIT_NAME);
        em = (JpaEntityManager) entityFactory.createEntityManager();
        return em;

    }
...

persistence.xml:

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

    <persistence-unit name="mypersistence-ejbPU" transaction-type="JTA">
        <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
        <jta-data-source>myJNDI</jta-data-source>
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
        <properties>
            <property name="eclipselink.jpa.uppercase-column-names" value="true"/>
            <property name="eclipselink.ddl-generation" value="create-tables"/> 
<!--            <property name="eclipselink.logging.level.sql" value="FINEST"/>
            <property name="eclipselink.logging.parameters" value="true"/>
            <property name="eclipselink.logging.logger" value="ServerLogger"/>-->
            <!--<property name="eclipselink.logging.level" value="FINE"/>-->
            <!--<property name="eclipselink.logging.level.cache" value="FINE"/>-->
            <!--property name="eclipselink.logging.level" value="FINE"/-->
            <!--property name="eclipselink.weaving" value="static"/-->
            <!--<property name="eclipselink.logging.level.sql" value="FINE"/>-->
            <!--property name="eclipselink.logging.level.cache" value="FINEST"/-->
            <property name="javax.persistence.schema-generation.database.action" value="create"/>
            <!--<property name="javax.persistence.schema-generation.database.action" value="create"/>-->
        </properties>
    </persistence-unit>
</persistence>

NB:当我删除 Batik-bridge 1.6-1 依赖项时,该项目在 Payara 和 glassfish 中都有效,但我需要此依赖项

问题已通过升级到 Batik 1.7 解决,必须使用此依赖项:

<dependency>
    <groupId>org.apache.xmlgraphics</groupId>
    <artifactId>batik-bridge</artifactId>
    <version>1.7</version>
</dependency>

改为:

        <dependency>
            <groupId>batik</groupId>
            <artifactId>batik-bridge</artifactId>
            <version>1.6-1</version> 
        </dependency>

正如@OndrejM 所说,batik 1.6-1 依赖于 xercesImpl,这导致 Sax 解析器出现问题,似乎 Batik 1.7 使用了另一个解析器,现在它可以完美运行