首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Amdatu rest示例不工作吗?

Amdatu rest示例不工作吗?
EN

Stack Overflow用户
提问于 2017-04-05 18:05:05
回答 1查看 191关注 0票数 0

我创建了一个带有amdatu引导jar文件的bnd-工作区。然后创建一个测试rest项目和一个bnd运行描述符文件来测试它。当我运行运行描述符文件并导航到http://localhost:8080/test时,我面对了404页:(。

代码语言:javascript
复制
HTTP ERROR: 404

Problem accessing /test. Reason:

    Not Found

以下是我为此采取的详细步骤:

  1. 下载并使用引导-bin-r9.zip
  2. 在Amdatu引导UI中,要初始化我发出的带有"amdatu“模板的工作区-init。
  3. 然后,我用" project -create“命令创建了一个项目"osgi.test”。
  4. 然后我使用“tmp.Test-createcomponent”命令创建了一个以"/test“作为url的测试组件”/test“。
  5. 然后,我使用" rest -install“命令添加了所需的rest依赖项。
  6. 然后,我用org.apache.felix.framework;version='5.2.0,5.2.0‘和Java1.8作为OSGI框架创建了launcher.bndrun。
  7. 然后,我使用" rest -run“命令将rest必需的库添加到launcher.bndrun中。
  8. 然后,我用" shell -run“命令添加了gogo和dm shell。

测试组件:

代码语言:javascript
复制
package tmp;

import java.util.List;

import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import java.util.Arrays;
import org.apache.felix.dm.annotation.api.Component;

@Component(provides = Object.class)
@Path("/test")
public class Test {

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public List<String> list() {
        return Arrays.asList("test");
    }
}

以下是捆绑包的列表:

代码语言:javascript
复制
lb
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.2.0)
    1|Active     |    1|Apache Felix Http Jetty (3.2.0)
    2|Active     |    1|Apache Felix Http API (3.0.0)
    3|Active     |    1|Apache Felix Servlet API (1.1.2)
    4|Active     |    1|Apache Felix Http Whiteboard (3.0.0)
    5|Active     |    1|org.amdatu.web.rest.jaxrs (1.1.1)
    6|Active     |    1|org.amdatu.web.rest.wink (3.0.1)
    7|Active     |    1|org.amdatu.web.rest.doc (1.2.3)
    8|Active     |    1|Jackson-annotations (2.6.3)
    9|Active     |    1|Jackson-core (2.6.3)
   10|Active     |    1|jackson-databind (2.6.3)
   11|Active     |    1|Jackson-JAXRS-base (2.6.3)
   12|Active     |    1|Jackson-JAXRS-JSON (2.6.3)
   13|Active     |    1|Apache Felix Dependency Manager (4.3.0)
   14|Active     |    1|Apache Felix Dependency Manager Runtime (4.0.3)
   15|Active     |    1|Apache Felix Metatype Service (1.0.12)
   16|Active     |    1|Apache Felix EventAdmin (1.3.2)
   17|Active     |    1|Apache Felix Configuration Admin Service (1.8.6)
   18|Active     |    1|OPS4J Pax Logging - API (1.7.0)
   19|Active     |    1|OPS4J Pax Logging - Service (1.7.0)
   20|Active     |    1|osgi.test (0.0.0)
   21|Active     |    1|Apache Felix Gogo Command (0.12.0)
   22|Active     |    1|Apache Felix Gogo Runtime (0.10.0)
   23|Active     |    1|Apache Felix Gogo Shell (0.10.0)
   24|Active     |    1|Apache Felix Dependency Manager Shell (4.0.4)

下面是"dm“命令的结果

代码语言:javascript
复制
dm
[6] org.amdatu.web.rest.wink
 [0] org.amdatu.web.rest.jaxrs.JaxRsSpi registered
 [1] org.slf4j.impl.StaticLoggerBinder(OSGi) registered
    org.osgi.service.log.LogService service optional available
 [2] org.amdatu.web.rest.whiteboard.JaxRsWhiteboard registered
    active{bundle.id=6} bundle required available
    org.osgi.service.log.LogService service optional available
    javax.ws.rs.core.Application (osgi.jaxrs.application.base=*) service optional unavailable
    java.lang.Object (osgi.jaxrs.resource.base=*) service optional unavailable
 [3] Adapter for interface org.amdatu.web.rest.jaxrs.ApplicationService registered
    org.amdatu.web.rest.jaxrs.ApplicationService service optional unavailable
[14] org.apache.felix.dependencymanager.runtime
 [4] org.apache.felix.dm.runtime.DependencyManagerRuntime registered
    active (DependencyManager-Component=*) bundle optional unavailable
    org.osgi.service.packageadmin.PackageAdmin service required available
    org.osgi.service.log.LogService service optional available

当我导航到http://localhost:8080/test时,会显示以下错误

代码语言:javascript
复制
HTTP ERROR: 404

Problem accessing /test. Reason:

    Not Found

任何帮助都会得到赏识。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-27 19:04:43

将org.amdatu.web.rest.wink的版本更改为2.0.3将解决问题。

我不知道3+版本有什么问题,为什么它只适用于2.0.3?!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43238546

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档