小编Pet*_*ter的帖子

带有JAX-RS的OSGi Bundle RESTful服务无法启动

我正在为Glassfish AS编写捆绑的OSGi应用程序.我有与JAX-RS RESTful服务的捆绑,与泽西(我使用Vogella的turtorial)一起发布.我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <servlet>
        <servlet-name>Jersey REST Service</servlet-name>
        <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Jersey REST Service</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)

当我尝试自动包装时出现问题,例外:

SEVERE: WebModule[/spm]StandardWrapper.Throwable
com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.HeaderDelegateProvider: The class com.sun.jersey.core.impl.provider.header.LocaleProvider implementing provider interface com.sun.jersey.spi.HeaderDelegateProvider could not be instantiated: Cannot cast com.sun.jersey.core.impl.provider.header.LocaleProvider to com.sun.jersey.spi.HeaderDelegateProvider
    at com.sun.jersey.core.osgi.OsgiRegistry$OsgiServiceFinder$1.next(OsgiRegistry.java:149)
    at com.sun.jersey.core.spi.factory.AbstractRuntimeDelegate.<init>(AbstractRuntimeDelegate.java:76)
    at com.sun.jersey.server.impl.provider.RuntimeDelegateImpl.<init>(RuntimeDelegateImpl.java:54)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at java.lang.Class.newInstance0(Class.java:372)
    at java.lang.Class.newInstance(Class.java:325)
    at com.sun.jersey.core.osgi.OsgiRegistry.hookUp(OsgiRegistry.java:391)
    at com.sun.jersey.core.osgi.OsgiRegistry.getInstance(OsgiRegistry.java:119)
    at com.sun.jersey.core.reflection.ReflectionHelper.getOsgiRegistryInstance(ReflectionHelper.java:737)
    at com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.getClassForName(AnnotationScannerListener.java:217)
    at com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.visitEnd(AnnotationScannerListener.java:186) …
Run Code Online (Sandbox Code Playgroud)

osgi glassfish jersey java-ee

6
推荐指数
0
解决办法
2292
查看次数

多个WAR试图加载彼此的类

我在GlassFish上部署了一个Java EE应用程序.这个应用程序里面有2个web模块:

  • 第一次使用一些RESTful服务(业务逻辑)
  • 第二个使用JSF应用程序(管理控制台)

当我部署我的应用程序时,所有部署都可以,但我ClassNotFound在日志中看到了许多警告和异常(来自他们,第一次战争和第二次战争).

第一次战争:

SEVERE: Unable to load annotated class: com...web.admin.AdministrationBean
SEVERE: java.lang.ClassNotFoundException: com...web.admin.AdministrationBean
Run Code Online (Sandbox Code Playgroud)

第二次战争:

WARNING: WEB9052: Unable to load class com...web.rest.SomeResourse, reason: java.lang.ClassNotFoundException: com...rest.SomeResourse
Run Code Online (Sandbox Code Playgroud)

一切正常,但这些日志警告和错误真的很烦人.

看起来在应用程序属性中出现了问题,但我检查了它们并且看起来都很好(当我尝试将它们彼此分开时,一切都很好).

也许我需要一些application.xml设置来在GlassFish中单独加载?我用Google搜索,但没有找到有用的信息.

ear glassfish war java-ee

6
推荐指数
1
解决办法
1584
查看次数

标签 统计

glassfish ×2

java-ee ×2

ear ×1

jersey ×1

osgi ×1

war ×1