我正在使用Glassfish和OSGI开发一个简单的应用程序。我找到了这个教程: http://blogs.oracle.com/arungupta/entry/totd_154_dynamic_osgi_services 我修改了这个例子。您可以找到我自定义的示例文件: http://uploading.com/files/cf1ffd63/test.zip/ 我用Web模块和EJB模块创建了EAR包。我创建了一个调用OSGI包的会话bean。我成功编译了这个项目。问题是,当我将软件包上传到Glassfish应用程序服务器并尝试将简单小程序打开到Web模块时,会出现此错误消息:
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.ClassCastException: Cannot cast org.glassfish.web.loader.WebappClassLoader to org.osgi.framework.BundleReference
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 3.1.1 logs.
GlassFish Server Open Source Edition 3.1.1
也许问题是缺少依赖性。我找不到问题?你知道可能是什么问题吗?
答案 0 :(得分:1)
OSGi Core 4.2规范的第3.8.9节(org.osgi.framework; version = 1.5)要求所有bundle类加载器必须实现BundleReference接口。也许GlassFish中的类加载器不这样做?您的GlassFish版本支持哪个版本的OSGi Core规范?
答案 1 :(得分:1)
您不应该将应用程序部署为耳朵,两个模块必须单独部署为OSGi捆绑包
答案 2 :(得分:0)
如果我理解正确,那么OSGI的版本就是问题所在。在Web模块中,我已声明:
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>osgi-cdi-api</artifactId>
<version>3.1-SNAPSHOT</version>
<type>jar</type>
</dependency>
我是否需要添加其他内容?
P.S 我使用Glassfish 3.1.1 - 最新版本。这是包含已安装组件的列表:
Source Button to include column Source in sort.
felix OSGi Service Platform Release 4 3.0.8-0 999KB stable.glassfish.org
glassfish-appclient Application Servers 3.1.1-12 1MB stable.glassfish.org
glassfish-cluster Application Servers 3.1.1-12 1MB stable.glassfish.org
glassfish-cmp Application Servers 3.1.1-12 2MB stable.glassfish.org
glassfish-common Application Servers 3.1.1-12 10MB stable.glassfish.org
glassfish-common-full Application Servers 3.1.1-12 210KB stable.glassfish.org
glassfish-corba Application Servers 3.1.0-30 2MB stable.glassfish.org
glassfish-corba-base Application Servers 3.1.0-30 794KB stable.glassfish.org
glassfish-ejb Application Servers 3.1.1-12 298KB stable.glassfish.org
glassfish-ejb-lite Application Servers 3.1.1-12 942KB stable.glassfish.org
glassfish-full-incorporation Application Servers 3.1.1-12 37KB stable.glassfish.org
glassfish-full-profile Application Servers 3.1.1-12 37KB stable.glassfish.org
glassfish-grizzly Application Servers 1.9.36-1 1007KB stable.glassfish.org
glassfish-grizzly-full Application Servers 1.9.36-1 163KB stable.glassfish.org
glassfish-gui Application Servers 3.1.1-12 8MB stable.glassfish.org
glassfish-ha Application Servers 3.1.1-12 53KB stable.glassfish.org
glassfish-hk2 Application Servers 3.1.1-12 1MB stable.glassfish.org
glassfish-javahelp Application Servers 2.0.2-1 586KB stable.glassfish.org
glassfish-jca Application Servers 3.1.1-12 1MB stable.glassfish.org
glassfish-jcdi Application Servers 3.1.1-12 2MB stable.glassfish.org
glassfish-jdbc Application Servers 3.1.1-12 922KB stable.glassfish.org
glassfish-jms Application Servers 3.1.1-12 4MB stable.glassfish.org
glassfish-jpa Application Servers 3.1.1-12 5MB stable.glassfish.org
glassfish-jsf Application Servers 2.1.3-4 2MB stable.glassfish.org
glassfish-jta Application Servers 3.1.1-12 110KB stable.glassfish.org
glassfish-jts Application Servers 3.1.1-12 424KB stable.glassfish.org
glassfish-management Application Servers 3.1.1-12 334KB stable.glassfish.org
glassfish-nucleus Application Servers 3.1.1-12 3MB stable.glassfish.org
glassfish-osgi-feature-pack Application Servers 3.1.1-12 37KB contrib.glassfish.org
glassfish-osgi-gui Application Servers 3.1.1-12 656KB contrib.glassfish.org
glassfish-osgi-http Application Servers 3.1.1-12 66KB stable.glassfish.org
glassfish-osgi-incorporation Application Servers 3.1.1-12 37KB contrib.glassfish.org
glassfish-registration Application Servers 3.1.1-12 135KB stable.glassfish.org
glassfish-upgrade Application Servers 3.1.1-12 139KB stable.glassfish.org
glassfish-web Application Servers 3.1.1-12 3MB stable.glassfish.org
glassfish-web-incorporation Application Servers 3.1.1-12 37KB stable.glassfish.org
glassfish-web-profile Application Servers 3.1.1-12 37KB stable.glassfish.org
javadb-client Databases and Tools 10.6.2.1-1 527KB stable.glassfish.org
javadb-common Databases and Tools 10.6.2.1-1 60KB stable.glassfish.org
javadb-core Databases and Tools 10.6.2.1-1 4MB stable.glassfish.org
jersey Web Services 1.9-1.18 2MB stable.glassfish.org
metro Web Services 2.1.1-9 16MB stable.glassfish.org
mq-bin-exe Message-Oriented Middleware 4.5.1-3.2 297KB stable.glassfish.org
mq-bin-sh Message-Oriented Middleware 4.5.1-3.2 85KB stable.glassfish.org
mq-config-gf Message-Oriented Middleware 4.5.1-3.2 60KB stable.glassfish.org
mq-core Message-Oriented Middleware 4.5.1-3.2 4MB stable.glassfish.org
mq-server Message-Oriented Middleware 4.5.1-3.2 6MB stable.glassfish.org
pkg System Tools 1.122.2-54.2834 6MB stable.glassfish.org
pkg-java System Tools 1.122-54.2834 652KB stable.glassfish.org
pkg-toolkit-incorporation System Tools 2.3.4-54.2834 0KB stable.glassfish.org
python2.4-minimal System Tools 2.4.4.0-54.2834 6MB stable.glassfish.org
shoal Application Servers 1.5.34-0 536KB stable.glassfish.org
updatetool System Tools 2.3.4-54.2834 4MB stable.glassfish.org
wxpython2.8-minimal System Tools 2.8.10.1-54.2834 24MB stable.glassfish.org