0
votes

I'm getting an error (see below) on one server (Server1) but not at another (Server2).

Here is code:

GregorianCalendar c = new GregorianCalendar();
c.setTime(rs.getDate("claimDate"));
XMLGregorianCalendar date2 = 
DatatypeFactory.newInstance().newXMLGregorianCalendar(c);

Here is error:

Caused by: java.lang.NoSuchMethodError: javax.xml.datatype.FactoryFinder.find(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
at javax.xml.datatype.DatatypeFactory.newInstance(DatatypeFactory.java:49) ~[?:?]

Java versions are same (build 1.8.0_92-b14).

I've used a custom Karaf distribution (https://karaf.apache.org/manual/latest/#_custom_distributions) which I deploy on two different servers (different physical machines and Ubuntu versions).

Server1: Linux karaf1 2.6.32-358.el6.x86_64 #1 SMP Fri Feb 22 00:31:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Server2: Linux newproger 3.13.0-142-generic #191-Ubuntu SMP Fri Feb 2 12:13:35 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Start scripts and java parameters are all same.

1

1 Answers

1
votes

Probably some jar file in karaf endorsed lib folder (apache-karaf-x.x.x/lib/endorsed) is overriding javax.xml.datatype.FactoryFinder class (from rt.jar).

If you are using <libraries> tag in assembly pom (in karaf-maven-plugin) - try to find jar which contain javax.xml.datatype package (in my case it was - org.apache.servicemix.specs.jaxp-api) and remove it. example where to find it below:

<plugin>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>karaf-maven-plugin</artifactId>
            <version>${karaf.version}</version>
            <configuration>
                <startupFeatures>
                    <feature>eventadmin</feature>
                </startupFeatures>
                <installedFeatures>

                    <feature>wrapper</feature>
                </installedFeatures>
                <bootFeatures>
                    <!-- karaf standard -->
                    <feature>jaas</feature>
                    <feature>wrap</feature>
                     (...)
                    <feature>hibernate</feature>
                    <feature>transaction</feature>
                    <feature>jpa</feature>
                </bootFeatures>

                <libraries>

                </libraries>
                <javase>${java.version}</javase>
            </configuration>
        </plugin>