1

我有一个试图部署到 ServiceMix 4.5.2 的 JAX RS 服务,但它失败并出现两个错误。我一直在关注并与各种示例进行比较,并从 Maven 原型开始,但我找不到错误或答案。

第一个错误;

2013-09-20 22:45:09,357 | ERROR | lixDispatchQueue | FeatureDeploymentListener        | 35 - org.apache.karaf.deployer.features - 2.2.11 | Unable to install deployed features for bundle: FleetInfoService - 1.0.0.SNAPSHOT
java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
    at java.util.Properties.loadConvert(Properties.java:569)[:1.6.0_27]
    at java.util.Properties.load0(Properties.java:391)[:1.6.0_27]
    at java.util.Properties.load(Properties.java:342)[:1.6.0_27]
    at org.apache.karaf.deployer.features.FeatureDeploymentListener.bundleChanged(FeatureDeploymentListener.java:171)[35:org.apache.karaf.deployer.features:2.2.11]

我的 POM 有以下几行 wrt/ encoding - 由原型提供;

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>

尽管有这个错误,它尝试加载 bean 定义,并得到这个错误;

2013-09-20 22:45:10,551 | ERROR | ExtenderThread-3 | ContextLoaderListener            | 82 - org.springframework.osgi.extender - 1.2.1 | Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=FleetInfoService, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.osgi.org/xmlns/blueprint/v1.0.0]
Offending resource: URL [bundle://200.0:0/META-INF/spring/camel-context.xml]

camel-context.xml 以以下内容开头,我仔细检查了拼写错误;

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs"
xmlns:cxf="http://cxf.apache.org/blueprint/core"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://cxf.apache.org/blueprint/jaxrs http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd">

maven POM 包含以下依赖项。骆驼/蓝图版本与我在 ServiceMix 的 osgi:list 中看到的相匹配;

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-core</artifactId>
        <version>2.10.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-blueprint</artifactId>
        <version>2.10.6</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxrs</artifactId>
        <version>2.7.6</version>
    </dependency>
    <dependency>
        <groupId>javax.ws.rs</groupId>
        <artifactId>jsr311-api</artifactId>
        <version>1.1.1</version>
    </dependency>

POM 插件是;

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.karaf.tooling</groupId>
            <artifactId>features-maven-plugin</artifactId>
            <version>2.3.2</version>
            <executions>
                <execution>
                    <id>generate</id>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>generate-features-xml</goal>
                    </goals>
                    <configuration>
                        <!-- bundles>src/main/resources/bundles.properties</bundles -->
                        <outputFile>target/${project.artifactId}Features-${project.version}.xml</outputFile>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.4.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Private-Package>${project.groupId}.*</Private-Package>
                    <Import-Package>*</Import-Package>
                </instructions>
            </configuration>
        </plugin>
    </plugins>
4

1 回答 1

1

您应该查看 $SMX/data/cache/bundle/data 中的 FeatureDeploymentListener.cfg 文件。看起来其中一个条目的内容不正确。寻找\u序列或其他奇怪的字符序列。

不正确的文件可能是您的 pom.xml 的结果(例如您的 artifactId 包含\u),或者它可能已损坏。在后一种情况下,您可以轻松删除 $SMX/data/cache/bundle 目录并重新启动 ServiceMix。

第二个问题似乎是由于您将 OSGI 蓝图配置放入 spring 文件 ( META-INF/spring/camel-context.xml) 造成的。如果要使用蓝图,请将文件放在OSGI-INF/blueprint目录中。或者,您可以使用 Spring DM 配置,例如 camel中的示例。

于 2013-10-10T17:39:11.377 回答