Невозможно войти в karaf после исключения: Причина: java.lang.NoClassDefFoundError: Не удалось инициализировать класс javax.xml.bind.DatatypeConverterImpl - PullRequest
0 голосов
/ 06 октября 2018

Мы создали экземпляр karaf, на котором я пишу пример пакета, и успешно развернут.Я получаю ошибку во время выполнения, которая не воспроизводима.Странно, что после этой ошибки я не могу войти в karaf, который запрашивает учетные данные для входа в karaf.пароль по умолчанию karaf после этого не работает.

Caused by: java.lang.NoClassDefFoundError: Could not initialize class javax.xml.bind.DatatypeConverterImpl
        at javax.xml.bind.DatatypeConverter.initConverter(DatatypeConverter.java:155)
        at javax.xml.bind.DatatypeConverter.parseHexBinary(DatatypeConverter.java:371)

Подробности Env: Karaf 4.1.4 ОС RHEL 7.x

Код:

import java.util.Calendar;
import java.util.Map;

import javax.xml.bind.DatatypeConverter;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Component (name = "TestBinder", ds = true, immediate = true, metatype = false)
public class SampleBinder
{
    private static final Logger LOG = LoggerFactory.getLogger(SampleBinder.class);

    @Activate
    public void activate(final Map<String, Object> properties)
    {
        // Testing DatatypeConverter.printHexBinary
        String s2 = "Testing  DatatypeConverter.printHexBinary";
        String encodeds2 = DatatypeConverter.printHexBinary(s2.getBytes());
        LOG.error(" >>>>>>>  printHexBinary  = " + encodeds2);
        byte[] decodeds2 = DatatypeConverter.parseHexBinary(encodeds2);
        LOG.error(" >>>>>>>>  parseHexBinary - decodes2   = " + new String(decodeds2));

        // Lexical representation of date time
        LOG.error(DatatypeConverter.printDateTime(Calendar.getInstance()));
    }
}

Pom.xml

<?xml version="1.0"?>
<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>
    <parent>
        <groupId>com.test.common</groupId>
        <artifactId>compile</artifactId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../compile</relativePath>
    </parent>
    <artifactId>binder</artifactId>
    <name>com.test.binder</name>
    <packaging>bundle</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <build>
        <defaultGoal>install</defaultGoal>
        <plugins>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-Name>${project.Name}</Bundle-Name>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Export-Package>com.test.java*</Export-Package>
                        <Import-Package>javax.xml.bind;version=!,
                     *</Import-Package>
                    </instructions>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
...