JBoss Fuse CXF-RS REST Issue - 'No services have been found'

旧城冷巷雨未停 提交于 2020-08-05 14:08:33

问题


I'm creating a REST Service with Apache Camel and CXF-RS, using the following tutorial: https://www.javainuse.com/camel/apache_camel_rest_cxfrs

I've set up the code as shown in the tutorial and followed the steps correctly. After building the Maven project, I have successfully been able to install the bundle on Apache Karaf, using the SNAPSHOT file created. (A new Bundle ID was created).

When I run the command to 'start' the newly created bundle, it seemingly works with no errors being shown. However, when I access http://localhost:8181/cxf as mentioned towards the end of the tutorial, it says 'No services have been found':

Can you please advise me on what could be causing this problem?

Thank you.

My Project Structure:

My Code:

pom.xml:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.fuseproject</groupId>
  <artifactId>camel-cxfrs-core</artifactId>
  <version>0.0.1-SNAPSHOT</version>

          <packaging>bundle</packaging>

          <repositories>
              <repository>
                <id>Central2</id>
                <name>Central2</name>
                <url>https://repo.maven.org/maven2</url>
              </repository>
          </repositories>

          <dependencies>
                   <dependency>
                             <groupId>org.apache.camel</groupId>
                             <artifactId>camel-core</artifactId>
                             <version>2.12.0</version>
                   </dependency>
                   <dependency>
                             <groupId>org.apache.camel</groupId>
                             <artifactId>camel-cxf</artifactId>
                             <version>2.12.0</version>
                   </dependency>
          </dependencies>
          <build>
                   <plugins>
                             <plugin>
                                      <groupId>org.apache.maven.plugins</groupId>
                                      <artifactId>maven-compiler-plugin</artifactId>
                                      <version>3.1</version>
                             </plugin>

                             <plugin>
                                      <groupId>org.apache.felix</groupId>
                                      <artifactId>maven-bundle-plugin</artifactId>
                                      <extensions>true</extensions>
                                      <version>2.4.0</version>
                             </plugin>
                   </plugins>
          </build>
</project>

CamelProcessor.java:

package com.fuseproject.beans;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;

public class CamelProcessor implements Processor {

          public void process(Exchange exchange) throws Exception {

                   // Get input from exchange
                   String msg = exchange.getIn().getBody(String.class);
                   // set output in exchange
                   exchange.getOut().setBody("Hello World " + msg);
          }

}

EmployeeServiceResource.java:

package com.fuseproject.beans;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

@Path("/")
public class EmployeeServiceResource {

          public EmployeeServiceResource() {
          }

          @GET
          @Path("/employees/{name}/")
          public String getCustomer(@PathParam("name") String name) {
                   return null;
          }

}

applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/cxf"
       xmlns:jaxrs="http://cxf.apache.org/jaxrs"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

       <cxf:rsServer id="restService" address="http://localhost:9000/employeeservice"
              serviceClass="com.fuseproject.beans.EmployeeServiceResource">
       </cxf:rsServer>

       <bean id="processor" class="com.fuseproject.beans.CamelProcessor" />

       <camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring">
              <route>
                     <from uri="cxfrs://bean://restService" />
                     <process ref="processor" />
              </route>
       </camelContext>

</beans>

来源:https://stackoverflow.com/questions/62200138/jboss-fuse-cxf-rs-rest-issue-no-services-have-been-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!