掲示板
Atmosphere Runtime 2.4.6 refuses to load in Liferay Portal 7
6年前 に John Edward Platts によって更新されました。
Atmosphere Runtime 2.4.6 refuses to load in Liferay Portal 7
New Member 投稿: 9 参加年月日: 09/08/08 最新の投稿
Atmosphere Runtime 2.4.6 refuses to load in Liferay Portal 7 because it declares two different ServletContainerInitializer classes in the META-INF/services/javax.servlet.ServletContainerInitializer file of its JAR.
There is a bug in com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initServletContainerInitializers(Bundle, ServletContext) that prevents Atmosphere Runtime 2.4.6 from loading in Liferay Portal 7.
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:
There is a bug in com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initServletContainerInitializers(Bundle, ServletContext) that prevents Atmosphere Runtime 2.4.6 from loading in Liferay Portal 7.
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: Atmosphere Runtime 2.4.6 refuses to load in Liferay Portal 7
Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
Great! If you open a ticket on issues.liferay.com, the issue can get addressed by Liferay folks and perhaps your fix will get included!
Come meet me at the 2017 LSNA!
Come meet me at the 2017 LSNA!