CXF BusException否命名空间的DestinationFactory http://cxf.apache.org/transports/http [英] CXF BusException No DestinationFactory for namespace http://cxf.apache.org/transports/http

查看:114
本文介绍了CXF BusException否命名空间的DestinationFactory http://cxf.apache.org/transports/http的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图站起[basic cxf rs示例] [1],但是使用我自己的服务impl,它甚至更简单,并且我的所有方法都返回字符串.当我尝试运行此服务器时,出现此异常

I'm trying to stand up the [basic cxf rs example][1], but with my own service impl which is even simpler and all my methods return strings. When I try to run this server I get this exception

我建立了一个干净的项目,所以我从头开始.

I built a clean project so I'm starting fresh..

波姆大师 http://maven.apache.org/xsd/maven-4.0.0.xsd>

Master pom http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<name>Tests</name>
<groupId>com.crush</groupId>
<artifactId>tests</artifactId>
<version>1.0</version>
<packaging>pom</packaging>

<properties>
    <cxf.version>2.7.11</cxf.version>
    <httpclient.version>3.1</httpclient.version>
    <rs-api.version>2.0</rs-api.version>

    <disclaimer/>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <slf4j.version>1.6.2</slf4j.version>
    <guava.version>13.0-rc2</guava.version>
    <jgroups.version>3.1.0.Final</jgroups.version>
    <infinispan.version>5.1.4.CR1</infinispan.version>
    <commons.cli.version>1.2</commons.cli.version>
    <jettison.version>1.3.2</jettison.version>
    <spring.version>3.1.0.RELEASE</spring.version>
    <bouncycastle.version>1.46</bouncycastle.version>
    <junit.version>4.8</junit.version>
    <jasypt.version>1.9.0</jasypt.version>

    <!-- Additional Dependencies -->
    <cxf.buildtools.version>2.2.12</cxf.buildtools.version>

    <!-- Maven Plugin Versions -->
    <shade.plugin.version>1.7.1</shade.plugin.version>
    <buildnumber.plugin.version>1.1</buildnumber.plugin.version>
    <jar.plugin.version>2.4</jar.plugin.version>
    <resources.plugin.version>2.5</resources.plugin.version>
    <versions.plugin.version>1.3.1</versions.plugin.version>

    <!-- Plugin Versions -->
    <compiler.plugin.version>2.4</compiler.plugin.version>
    <surefire.plugin.version>2.12.4</surefire.plugin.version>
    <skipTests>true</skipTests>
    <jboss.cache.version>3.2.5.GA</jboss.cache.version>
    <maven.build.timestamp.format>yyyyMMdd-HHmmss</maven.build.timestamp.format>
</properties>

<modules>
    <module>sample-service</module>
</modules>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <!-- This dependency is needed if you're using the Jetty container -->
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http-jetty</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxrs</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-httpclient</groupId>
            <artifactId>commons-httpclient</artifactId>
            <version>${httpclient.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>${rs-api.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <!-- This plugin is used update the version numbers of the project
                    during the release process. -->
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>${versions.plugin.version}</version>
                <configuration>
                    <generateBackupPoms>false</generateBackupPoms>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    <plugins>
        <plugin>
            <!-- Plugin configuration for the plugin that specifies the base file encoding. -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>${resources.plugin.version}</version>
            <configuration>
                <encoding>UTF-8</encoding>
                <outputDirectory>${project.build.outputDirectory}</outputDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>${compiler.plugin.version}</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
    </plugins>
</build>

样本服务pom

<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/maven-    v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
<parent>
    <groupId>com.crush</groupId>
    <artifactId>tests</artifactId>
    <version>1.0</version>
</parent>
<artifactId>sample-service</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<name>Simple CXF project using spring configuration</name>
<dependencies>
  <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
  </dependency>
  <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http</artifactId>
  </dependency>
  <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
  </dependency>
  <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxrs</artifactId>
  </dependency>
  <dependency>
      <groupId>commons-httpclient</groupId>
      <artifactId>commons-httpclient</artifactId>
  </dependency>
  <dependency>
      <groupId>javax.ws.rs</groupId>
      <artifactId>javax.ws.rs-api</artifactId>
  </dependency>
</dependencies>
<profiles>
        <profile>
              <id>server</id>
            <build>
                <defaultGoal>test</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.2.1</version>
                        <executions>
                            <execution>
                                <phase>test</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <mainClass>com.crush.tests.service.Test</mainClass>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
</profiles>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>com.crush.tests.service.Test</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

MANIFEST.MF 清单版本:1.0 存档器版本:Plexus存档器 创建者:Apache Maven 内置:暗恋 Build-Jdk:1.7.0_55

MANIFEST.MF Manifest-Version: 1.0 Archiver-Version: Plexus Archiver Created-By: Apache Maven Built-By: crush Build-Jdk: 1.7.0_55

SampleServiceImpl

SampleServiceImpl

package com.crush.tests.service.ws.impl;

import javax.jws.WebService;

import com.crush.tests.service.ws.SampleService;

import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
impo rt javax.ws.rs.Produces;
import javax.ws.rs.core.Response;

@WebService(endpointInterface = "com.crush.tests.service.ws.SampleService")
@Path("/sample/")
@Produces("text/xml")
public class SampleServiceImpl implements SampleService
{
public SampleServiceImpl()
{

}

@GET
@Path("/hi/{text}")
public String sayHi(@PathParam("text") String text)
{
    return "Hello " + text;
}


}

当我使用以下命令运行此命令时:mvn -Pserver
2014年6月27日3:10:26 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO:将服务器的发布地址设置为http://://localhost:9000/
SLF4J:无法加载类"org.slf4j.impl.StaticLoggerBinder". SLF4J:默认为无操作(NOP)记录器实现 SLF4J:有关信息,请参见 http://www.slf4j.org/codes.html#StaticLoggerBinder 进一步的细节.
服务器已准备就绪...

When I run this with: mvn -Pserver
Jun 27, 2014 3:10:26 PM org.apache.cxf.endpoint.ServerImpl initDestination
INFO: Setting the server's publish address to be http ://localhost:9000/
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Server ready...

就像我以前一样,从捆绑的jar中运行
java -cp sample-service-1.0-jar-with-dependencies.jar com.crush.tests.service.Test 线程主"中的异常org.apache.cxf.service.factory.ServiceConstructionException 在org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:205) 在com.crush.tests.service.Test.(Test.java:25) 在com.crush.tests.service.Test.main(Test.java:30) 原因:org.apache.cxf.BusException:找不到名称空间 http://cxf.apache的DestinationFactory. .org/transports/http . 在org.apache.cxf.bus.managers.DestinationFactoryManagerImpl.getDestinationFactory(DestinationFactoryManagerImpl.java:130)处 在org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:78) 在org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:62) 在org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:159) ...另外2个

Like I was before, and running from the bundled jar
java -cp sample-service-1.0-jar-with-dependencies.jar com.crush.tests.service.Test Exception in thread "main" org.apache.cxf.service.factory.ServiceConstructionException at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:205) at com.crush.tests.service.Test.(Test.java:25) at com.crush.tests.service.Test.main(Test.java:30) Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://cxf.apache.org/transports/http. at org.apache.cxf.bus.managers.DestinationFactoryManagerImpl.getDestinationFactory(DestinationFactoryManagerImpl.java:130) at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:78) at org.apache.cxf.endpoint.ServerImpl.(ServerImpl.java:62) at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:159) ... 2 more

如果浏览sample-service-1.0-jar-with-dependencies.jar,则可以导航到/org/apache/cxf/transport(s)并在依赖的jar中找到任何类.

If I browse the sample-service-1.0-jar-with-dependencies.jar I can navigate to /org/apache/cxf/transport(s) as well as find any of the classes in the dependent jars.

推荐答案

问题是即使将cxf类捆绑到了我的jar中,也需要在类路径上设置它们.解决方法.

Problem was that the cxf classes needed to be set on the classpath even though they were bundled into my jar... Didn't make sense why but that was the fix.

这篇关于CXF BusException否命名空间的DestinationFactory http://cxf.apache.org/transports/http的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆