3

I've written a small Java Program that is using JAXB. In Eclipse it is working fine! Everthing works...

Then I involved Maven and when I execute the Jar (generated from Maven) I get the following error:

Dez 16, 2014 2:51:15 PM com.sun.xml.internal.bind.v2.util.XmlFactory createParserFactory
SCHWERWIEGEND: null
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 com.sun.xml.internal.bind.v2.util.XmlFactory.createParserFactory(Unknown Source)
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getXMLReader(Unknown Source)
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unknown Source)
        at javax.xml.bind.JAXB.unmarshal(Unknown Source)
        at de.lsd.jimp.controller.JImpController.doJAXB(JImpController.java:70)
        at de.lsd.jimp.controller.JImpController.<init>(JImpController.java:46)
        at de.lsd.jimp.init.JImp.initController(JImp.java:195)
        at de.lsd.jimp.init.JImp.main(JImp.java:219)

ERROR [2014-12-16 14:51:15,626] - Fehler bei JAXB.unmarshal aufgetreten! Thread:main Class:de.lsd.jimp.controller.JImpController Method:doJAXB
java.lang.IllegalStateException: org.xml.sax.SAXNotRecognizedException: http://javax.xml.XMLConstants/feature/secure-processing
        at com.sun.xml.internal.bind.v2.util.XmlFactory.createParserFactory(Unknown Source)
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.getXMLReader(Unknown Source)
        at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(Unknown Source)
        at javax.xml.bind.JAXB.unmarshal(Unknown Source)
        at de.lsd.jimp.controller.JImpController.doJAXB(JImpController.java:70)
        at de.lsd.jimp.controller.JImpController.<init>(JImpController.java:46)
        at de.lsd.jimp.init.JImp.initController(JImp.java:195)
        at de.lsd.jimp.init.JImp.main(JImp.java:219)
Caused by: 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)

My POM-file looks like that:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>JImp</groupId>
    <artifactId>JImp</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>de.own.jimp.init.JImp</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.5</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2</version>
        </dependency>
        <dependency>
            <groupId>commons-configuration</groupId>
            <artifactId>commons-configuration</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.9</version>
        </dependency>
        <dependency>
            <groupId>ownSWT64</groupId>
            <artifactId>ownSWT64</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>ownJFace</groupId>
            <artifactId>ownJFace</artifactId>
            <version>3.8.102</version>
        </dependency>
        <dependency>
            <groupId>ownOjdbc</groupId>
            <artifactId>ownOjdbc</artifactId>
            <version>14</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.core</groupId>
            <artifactId>runtime</artifactId>
            <version>3.10.0-v20140318-2214</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.core</groupId>
            <artifactId>commands</artifactId>
            <version>3.3.0-I20070605-0010</version>
        </dependency>
        <dependency>
            <groupId>revofubi</groupId>
            <artifactId>revofubi</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</project>

I figured out that this is an problem caused by Maven (in Eclipse it works..). Further I read that this problem is caused by the integrated depedencies?!

I can't solve it..

Maybe you have experience with that issue..!

Thanks for your help!!

mrbela
  • 4,477
  • 9
  • 44
  • 79
  • Different JDK used perhaps? Try running both java -version and javac -version on the command line and see what it outputs. Is it what you expect? – Gimby Dec 16 '14 at 13:59
  • Here is what I get: C:\>java -version java version "1.8.0_20" Java(TM) SE Runtime Environment (build 1.8.0_20-b26) Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode) C:\>javac -version javac 1.8.0_20 My program is running very well. Even in cmd (executing it with java -jar xyz.jar param0 param1).. But the line JAXB.unmarshal(new File(pathToXML), EdtsType.class) causes the error! So I don't think it is a Java problem because Java is working.. – mrbela Dec 16 '14 at 14:07
  • Must be a JAXB version ... are you running from a JAR of using eclipse? – Hichamov Dec 16 '14 at 14:16
  • JAXB is integrated in Java since version 6.. This is why I don't have it in my depedencies. I tried to add it manually in the depedencies, but this didn't fix my problem.. :( No, I am running out of cmd (Windows 7), invoking the jar-file via "java -jar ...." When I run the project in Eclipse, all works fine! – mrbela Dec 16 '14 at 14:21
  • And you have the same JDK configured in Eclipse? Check the installed runtimes in the workspace preferences. This is why I hate localized exceptions messages by the way - if you had the proper English stacktrace and message you could far easier Google the error and find existing stackoverflow questions relating to the same problem. – Gimby Dec 16 '14 at 14:44
  • Yes, under Properties -> Java Compiler I have chosen Compiler compliance level 1.8 – mrbela Dec 16 '14 at 14:52
  • I've tried it with Project -> Properties -> Java Build Path -> Libraries: JRE7 and Project -> Properties -> Java Build Path -> Java Compiler: 1.7 But it doesn't work either.. :( – mrbela Dec 16 '14 at 15:04
  • Setting the compiler compliance would not be enough and is not what I was asking for, but if you can set it to level 1.8 then you indeed have a Java 8 JDK/Runtime setup. Well on to the next area of investigation: you're using Maven, so do a mvn dependency:tree to see all the dependencies that your application is pulling in. It might very well be that older versions of JAXB are pulled in as transitive dependencies and you're just lucky they are not used when running through Eclipse. – Gimby Dec 17 '14 at 08:45
  • @mrbela Did you ever figure out what the problem was? Or do you still have an idea how you solved it? – Sumurai8 Dec 11 '15 at 16:17
  • [slodeveloper](https://stackoverflow.com/users/4655907) posted an [Answer](https://stackoverflow.com/a/69440837) saying "The **solution** for this problem is already solved here: [Error unmarshalling xml in java-8 "secure-processing org.xml.sax.SAXNotRecognizedException causing java.lang.IllegalStateException"](https://stackoverflow.com/questions/25644023/error-unmarshalling-xml-in-java-8-secure-processing-org-xml-sax-saxnotrecognize)" – Scratte Oct 05 '21 at 17:20

0 Answers0