掲示板
Bug fix for WAR ServletContainerInitializer support in Liferay 7
6年前 に John Edward Platts によって更新されました。
Bug fix for WAR ServletContainerInitializer support in Liferay 7
New Member 投稿: 9 参加年月日: 09/08/08 最新の投稿
There is a bug in com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initServletContainerInitializers(Bundle, ServletContext) in Liferay Portal 7. The bug occurs whenever there is a META-INF/services/javax.servlet.ServletContainerInitializer file with more than one class name in one of the JARs in the WEB-INF/lib directory of a WAR that is deployed to Liferay Portal 7. In addition, the bug also occurs if there is a META-INF/services/javax.servlet.ServletContainerInitializer file with a comment in one of the JARs in the WEB-INF/lib directory of a WAR that is deployed to Liferay Portal 7.
WARs containing the Atmosphere JAR fail to deploy on Liferay 7 because the META-INF/services/javax.servlet.ServletContainerInitializer file in the Atmosphere Runtime JAR declares two ServletContainerInitializers (org.atmosphere.cpr.AnnotationScanningServletContainerInitializer and org.atmosphere.cpr.ContainerInitializer).
The code for com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor can be found at https://github.com/liferay/com-liferay-portal-osgi-web/blob/master/portal-osgi-web-wab-extender/src/main/java/com/liferay/portal/osgi/web/wab/extender/internal/WabBundleProcessor.java.
Here is how initServletContainerInitializers is currently implemented in com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor:
Here is the fixed version of initServletContainerInitializers in com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor that would solve the problem of Atmosphere failing to load in Liferay 7:
WARs containing the Atmosphere JAR fail to deploy on Liferay 7 because the META-INF/services/javax.servlet.ServletContainerInitializer file in the Atmosphere Runtime JAR declares two ServletContainerInitializers (org.atmosphere.cpr.AnnotationScanningServletContainerInitializer and org.atmosphere.cpr.ContainerInitializer).
The code for com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor can be found at https://github.com/liferay/com-liferay-portal-osgi-web/blob/master/portal-osgi-web-wab-extender/src/main/java/com/liferay/portal/osgi/web/wab/extender/internal/WabBundleProcessor.java.
Here is how initServletContainerInitializers is currently implemented in com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor:
protected void initServletContainerInitializers(
Bundle bundle, ServletContext servletContext)
throws IOException {
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
Enumeration<url> initializerResources = bundle.getResources(
"META-INF/services/javax.servlet.ServletContainerInitializer");
if (initializerResources == null) {
return;
}
while (initializerResources.hasMoreElements()) {
URL url = initializerResources.nextElement();
try (InputStream inputStream = url.openStream()) {
String fqcn = StringUtil.read(inputStream);
processServletContainerInitializerClass(
fqcn, bundle, bundleWiring, servletContext);
}
catch (IOException ioe) {
_logger.log(Logger.LOG_ERROR, ioe.getMessage(), ioe);
}
}
}</url>
Here is the fixed version of initServletContainerInitializers in com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor that would solve the problem of Atmosphere failing to load in Liferay 7:
protected void initServletContainerInitializers(
Bundle bundle, ServletContext servletContext)
throws IOException {
BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
Enumeration<url> initializerResources = bundle.getResources(
"META-INF/services/javax.servlet.ServletContainerInitializer");
if (initializerResources == null) {
return;
}
while (initializerResources.hasMoreElements()) {
URL url = initializerResources.nextElement();
try (InputStream inputStream = url.openStream()) {
try(UnsyncBufferedReader unsyncBufferedReader =
new UnsyncBufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
String line;
while((line = unsyncBufferedReader.readLine()) != null) {
// Remove comments from the line
int hashIndex = line.indexOf('#');
if(hashIndex == 0) {
continue;
} else if(hashIndex > 0) {
line = line.substring(0, hashIndex);
}
// Trim line
line = line.trim();
// Skip over any empty lines
if(line.isEmpty()) {
continue;
}
// line should now be a fully qualified name of a class that implements the
// javax.servlet.ServletContainerInitializer interface
String fqcn = line;
processServletContainerInitializerClass(
fqcn, bundle, bundleWiring, servletContext);
}
}
}
catch (IOException ioe) {
_logger.log(Logger.LOG_ERROR, ioe.getMessage(), ioe);
}
}
}</url>
6年前 に David H Nebinger によって更新されました。
RE: Bug fix for WAR ServletContainerInitializer support in Liferay 7
Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
John, posting the solution to the forums will not get the change into the product as quickly as opening a ticket on issues.liferay.com...
Come meet me at the 2017 LSNA!
Come meet me at the 2017 LSNA!
6年前 に John Edward Platts によって更新されました。
RE: Bug fix for WAR ServletContainerInitializer support in Liferay 7
New Member 投稿: 9 参加年月日: 09/08/08 最新の投稿
I am unable to log into issues.liferay.com to report the issue. I need a login to issues.liferay.com to report this bug.
6年前 に David H Nebinger によって更新されました。
RE: Bug fix for WAR ServletContainerInitializer support in Liferay 7
Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Hmm, you may need to request an account, but the links there should help you do that...
Come meet me at the 2017 LSNA!
Come meet me at the 2017 LSNA!