2

I have added logback-spring.xml into the class path and it was working fine until I added below dependencies for some ISO message conversion.(crimson dependency is hardcoded in the JPOS library, so it cannot be removed)

<project>
<modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.7</version>
    <relativePath/>
</parent>
<groupId>com.test</groupId>
<artifactId>iso-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>iso-test</name>
<description>test</description>
<properties>
    <java.version>11</java.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.modelmapper</groupId>
        <artifactId>modelmapper</artifactId>
        <version>2.4.4</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.jpos</groupId>
        <artifactId>jpos</artifactId>
        <version>2.1.0</version>
    </dependency>
    <dependency>
        <groupId>crimson</groupId>
        <artifactId>crimson</artifactId>
        <version>1.1.3</version>
        <optional>true</optional>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
</project>

Then there is an issue with logback-spring.xml reading with below exceptions.

java.lang.IllegalStateException: Could not initialize Logback logging from classpath:logback-spring.xml'

and

Caused by: org.xml.sax.SAXNotSupportedException: Feature: http://xml.org/sax/features/external-general-entities

Below is where the JPOS packager(GenericValidatingPackager.class) used crimson library.

public void readFile(String filename) throws ISOException {
    XMLReader reader=XMLReaderFactory.createXMLReader(System.getProperty("sax.parser", "org.apache.crimson.parser.XMLReaderImpl"));
...
}
2
  • Would you be able to provide a minimal pom to reproduce the problem? Commented Dec 28, 2022 at 10:19
  • @samabcde I have added minimum pom to reproduce the issue Commented Dec 29, 2022 at 4:43

2 Answers 2

1

crimson dependency is hardcoded in the JPOS library, so it cannot be removed

This is not correct, referring to JPOS packager(GenericValidatingPackager.class)

XMLReader reader = XMLReaderFactory.createXMLReader(System.getProperty("sax.parser", "org.apache.crimson.parser.XMLReaderImpl"));

This line just tell us that if we do not set the property "sax.parser", we use org.apache.crimson.parser.XMLReaderImpl as fallback.

So what we need:

  1. Remove crimson dependency
  2. set the property "sax.parser", e.g.
System.setProperty("sax.parser", "com.sun.org.apache.xerces.internal.parsers.SAXParser");
Sign up to request clarification or add additional context in comments.

1 Comment

Once the system property is set it worked, thanks a lot.
0

Crimson is not required by jPOS if you use a modern JVM (1.8 and up).

It was used in the past, as a fallback if the JVM didn't provide an XMLReader, and org.xml.sax.driver was not configured.

Also, I suggest to use the latest version (see ChangeLog) as there has been a lot of improvements since 2.1.0 back in 2017.

2 Comments

java version 11 is used , I have changed JPOS version to 2.1.7 but the issue is there still.I have updated the post to show that JPOS is using crimson.
Oh, I get it. You're using the GenericValidatingPackager. This was a very old contribution that never get into mainstream use. Please the GenericPackager instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.