Issue
- While integrating RESTeasy JAX RS dependency in Liferay DXP projects, customers may notice the below messages in the server logs:
SEVERE [fileinstall-/home/liferay.com/7.0/osgi/war] org.apache.catalina.core.ApplicationContext.log Patterns, regex or servletNames must contain a value.
Or:
java.lang.IllegalArgumentException: Patterns, regex or servletNames must contain a value.
at org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddFilterRegistration(ContextController.java:245)
[...]
SEVERE [fileinstall-/liferay-portal-7.2.10-ga1/osgi/war] org.apache.catalina.core.ApplicationContext.log Invalid pattern '' java.lang.IllegalArgumentException: Invalid pattern '' at org.eclipse.equinox.http.servlet.internal.context.ContextController.checkPattern(ContextController.java:987) at org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddFilterRegistration(ContextController.java:244) at org.eclipse.equinox.http.servlet.internal.context.ContextController.addFilterRegistration(ContextController.java:179) at org.eclipse.equinox.http.servlet.internal.customizer.ContextFilterTrackerCustomizer.addingService(ContextFilterTrackerCustomizer.java:55) at org.eclipse.equinox.http.servlet.internal.customizer.ContextFilterTrackerCustomizer.addingService(ContextFilterTrackerCustomizer.java:1) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943) at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903) at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:891) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:228) at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469) at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:487) at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1004) at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initFilters(WabBundleProcessor.java:525) at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:220) at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:179) at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:101) at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:114) at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:67) at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory.addingBundle(WabFactory.java:49) at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:475) at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1) at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256) at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229) at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450) at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230) at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148) at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:230) at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:137) at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:129) at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:191) at org.eclipse.osgi.container.Module.publishEvent(Module.java:476) at org.eclipse.osgi.container.Module.doStart(Module.java:578) at org.eclipse.osgi.container.Module.start(Module.java:449) at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428) at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1264) at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1237) at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:520) at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:365) at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:316)
Despite the messages, the portlet will operate seamlessly.
Environment
- Liferay DXP 7.0+
Resolution
- To handle the logging messages, one possible approach could be to develop a custom filter to work with
RESTEasy, likely by overriding theFilter30Dispatcherclass.
Additional Information
- For these cases, the filter declaration does not meet the specification, therefore Liferay is unable to work it around on the portal side, as changing the code to accept the filter/ maintain the code is OSGI and/or Tomcat specific topic.
1. Looking at the Java Servlet Specification, specifically chapter 8, we see lots of info regarding annotations
2. InsideIn a web application, classes using annotations will have their annotations processed only if they are located in the WEB-INF/classes directory, or if they are packaged in a jar file located in WEB-INF/lib within the application.
WEB-INF/lib, there is theresteasy-jaxrs.jar. This is the jar which is getting processed and throwing the error
3. Inside the jar is a file calledFilter30Dispatcher.class. This class has the following annotation:
@WebFilter(
4. From the spec, section 8.1.2:
asyncSupported = true
)
This annotation is used to define a Filter in a web application. This annotation is specified on a class and contains metadata about the filter being declared. The default name of the Filter if not specified is the fully qualified class name. The urlPatterns attribute, servletNames attribute or the value attribute of the annotation MUST be specified.
urlPatterns,servletNames, and the value must be specified withinFilter30Dispatcher'sWebFilterannotation.
Further, looking through Tomcat's ContextConfig.java class, Tomcat will not process the filter if it is missing all of these values. Instead, it simply ignores it and moves on. This supports the conclusion regarding this not being a Liferay bug, but rather a problem with the way the filter is specified.