我正在尝试在 OSGI 环境中运行 Jetty 9.0.3 并使用特殊的清单参数部署 WAR(实际上它是一个 jar,下面是 JettyTest-0.0.0.jar)。我正在按照 http://www.eclipse.org/jetty/documentation/current/framework-jetty-osgi.html上的说明进行操作
如果我不包括 JSP 支持,它工作正常,即,如果我从运行配置中删除以下行
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.osgi.boot.jsp)'
org.eclipse.jetty.osgi.boot.jsp;version='[9.0.3,9.0.4)',\
但是如果我包含它们并因此包含 org.eclipse.jetty.osgi.boot.jsp 包,我会收到以下错误消息
! Failed to start bundle org.eclipse.jetty.osgi.boot-9.0.3.v20130506, exception activator error org/xml/sax/ErrorHandler from: org.eclipse.jetty.osgi.boot.jasper.JSTLBundleDiscoverer:fixupDtdResolution#216
我已经搜索了一个多星期来寻找这个错误我已经查看了第 216 行的源 org.eclipse.jetty.osgi.boot.jasper.JSTLBundleDiscoverer 我看不到任何明显的错误。
即使我没有在运行配置中包含 JettyTest-0.0.0.jar,错误也是一样的。
阅读 Jetty 的文档似乎我应该能够做我想做的事。我想知道这个错误的原因并修复它,我不想在我的设置中包含 pax-web 或任何其他重大更改。
有没有人遇到过类似的问题?还是您没有问题地做到这一点?请帮助我找到错误的根本原因。
以下是我使用的文件:
JettyTest-0.0.0.jar
META-INF
MANIFEST.MF
WEB-INF
classes
lib
web.xml
index.html
test.jsp
清单文件
Manifest-Version: 1.0
Class-Path:
Bundle-ManifestVersion: 2
Bundle-SymbolicName: JettyTest
Import-Package: javax.servlet,javax.servlet.http
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<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_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Example</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>
索引.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
Hello World?
</body>
</html>
测试.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%= "Hello World!" %>
</body>
</html>
运行.bndrun
-runfw: org.apache.felix.framework;version='[4.2.1,4.2.1]'
-runee: JavaSE-1.7
-resolve.effective: active
-runrequires: osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.deploy)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.http)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.security)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.server)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.servlet)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.util)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.webapp)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.osgi.boot)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.io)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.xml)',\
osgi.identity;filter:='(osgi.identity=com.sun.el)',\
osgi.identity;filter:='(osgi.identity=javax.el)',\
osgi.identity;filter:='(osgi.identity=javax.servlet.jsp)',\
osgi.identity;filter:='(osgi.identity=javax.servlet.jsp.jstl)',\
osgi.identity;filter:='(osgi.identity=org.apache.taglibs.standard.glassfish)',\
osgi.identity;filter:='(osgi.identity=org.apache.jasper.glassfish)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jdt.core.compiler.batch)',\
osgi.identity;filter:='(osgi.identity=JettyTest)',\
osgi.identity;filter:='(osgi.identity=org.eclipse.jetty.osgi.boot.jsp)'
-runrepos: Releases,\
Local,\
Bndtools Hub
-resolve: auto
-runbundles: JettyTest;version='[0.0.0,0.0.1)',\
com.sun.el;version='[2.2.0,2.2.1)',\
javax.el;version='[2.2.0,2.2.1)',\
javax.servlet;version='[3.0.0,3.0.1)',\
javax.servlet.jsp;version='[2.2.0,2.2.1)',\
javax.servlet.jsp.jstl;version='[1.2.0,1.2.1)',\
org.apache.felix.configadmin;version='[1.4.0,1.4.1)',\
org.apache.felix.log;version='[1.0.1,1.0.2)',\
org.apache.jasper.glassfish;version='[2.2.2,2.2.3)',\
org.apache.taglibs.standard.glassfish;version='[1.2.0,1.2.1)',\
org.eclipse.jdt.core.compiler.batch;version='[3.8.2,3.8.3)',\
org.eclipse.jetty.deploy;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.http;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.io;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.osgi.boot;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.osgi.boot.jsp;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.security;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.server;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.servlet;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.util;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.webapp;version='[9.0.3,9.0.4)',\
org.eclipse.jetty.xml;version='[9.0.3,9.0.4)',\
osgi.cmpn;version='[4.2.0,4.2.1)'
-runvm: -Djetty.home.bundle=org.eclipse.jetty.osgi.boot
更新
经过一些改进的日志记录后,我发现了完整的错误消息。我似乎错过了带有 org.xml.sax.ErrorHandler 的 JAR,任何人都知道我可以使用的 Apache Felix jar,或者包含此类的任何其他库?
ERROR: Bundle org.eclipse.jetty.osgi.boot [20] Error starting osgi-dp:org.eclipse.jetty.osgi.boot (org.osgi.framework.BundleException: Activator start error in
bundle org.eclipse.jetty.osgi.boot [20].)
java.lang.NoClassDefFoundError: org/xml/sax/ErrorHandler
at org.eclipse.jetty.osgi.boot.jasper.JSTLBundleDiscoverer.fixupDtdResolution(JSTLBundleDiscoverer.java:216)
at org.eclipse.jetty.osgi.boot.jasper.JSTLBundleDiscoverer.<init>(JSTLBundleDiscoverer.java:91)
at org.eclipse.jetty.osgi.boot.jsp.FragmentActivator.start(FragmentActivator.java:57)
at org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker.invokeFragmentActivators(PackageAdminServiceTracker.java:280)
at org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker.setup(PackageAdminServiceTracker.java:87)
at org.eclipse.jetty.osgi.boot.utils.internal.PackageAdminServiceTracker.<init>(PackageAdminServiceTracker.java:67)
at org.eclipse.jetty.osgi.boot.JettyBootstrapActivator.start(JettyBootstrapActivator.java:87)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1191)
at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:295)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.xml.sax.ErrorHandler not found
by org.apache.jasper.glassfish [32]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1843)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 13 more