Fórum
Bug fix for WAR ServletContainerInitializer support in Liferay 7
John Edward Platts, modificado 6 Anos atrás.
Bug fix for WAR ServletContainerInitializer support in Liferay 7
New Member Postagens: 9 Data de Entrada: 08/08/09 Postagens Recentes
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>
David H Nebinger, modificado 6 Anos atrás.
RE: Bug fix for WAR ServletContainerInitializer support in Liferay 7
Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
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!
John Edward Platts, modificado 6 Anos atrás.
RE: Bug fix for WAR ServletContainerInitializer support in Liferay 7
New Member Postagens: 9 Data de Entrada: 08/08/09 Postagens Recentes
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.
David H Nebinger, modificado 6 Anos atrás.
RE: Bug fix for WAR ServletContainerInitializer support in Liferay 7
Liferay Legend Postagens: 14919 Data de Entrada: 02/09/06 Postagens Recentes
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!