Skip to content

Commit

Permalink
upgrade wilma-message-search for java >8 + fix jsp handling
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohegyi committed May 21, 2021
1 parent e7f1158 commit f5be759
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 24 deletions.
4 changes: 2 additions & 2 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Fri May 21 21:52:52 CEST 2021
VERSION_CODE=451
#Fri May 21 23:49:57 CEST 2021
VERSION_CODE=455
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ dependencies {
compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version:'1.9.10'
compile group: 'javax.inject', name: 'javax.inject', version:'1'
compile group: 'com.google.code.gson', name: 'gson', version:'2.2.4'
compile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.2.10.v20150310'
compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.2.10.v20150310'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version:'9.2.10.v20150310'
compile group: 'org.eclipse.jetty', name: 'jetty-servlets', version:'9.2.10.v20150310'
compile group: 'org.eclipse.jetty', name: 'jetty-jsp', version:'9.2.10.v20150310'
compile group: 'org.eclipse.jetty', name: 'jetty-server', version:'9.4.30.v20200611'
compile group: 'org.eclipse.jetty', name: 'jetty-servlet', version:'9.4.30.v20200611'
compile group: 'org.eclipse.jetty', name: 'jetty-webapp', version:'9.4.30.v20200611'
compile group: 'org.eclipse.jetty', name: 'jetty-servlets', version:'9.4.30.v20200611'
compile group: 'org.eclipse.jetty', name: 'apache-jsp', version:'9.4.30.v20200611'
compile group: 'ch.qos.logback', name: 'logback-classic', version:'1.0.13'
compile(group: 'org.slf4j', name: 'jcl-over-slf4j', version:'1.7.0') {
exclude(module: 'slf4j-api')
}
compile project(':wilma-message-search:wilma-message-search-lucene')
compile project(':wilma-message-search:wilma-message-search-properties')
compile group: 'org.apache.commons', name: 'commons-compress', version:'1.6'
compile group: 'org.apache.commons', name: 'commons-compress', version:'1.18'
compile group: 'org.apache.commons', name: 'commons-io', version:'1.3.2'
compile(group: 'javax.servlet', name: 'jstl', version:'1.2') {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,24 @@
along with Wilma. If not, see <http://www.gnu.org/licenses/>.
===========================================================================*/

import java.net.URL;
import java.util.concurrent.Executors;

import javax.servlet.Servlet;

import com.epam.wilma.message.search.web.domain.exception.ServerException;
import org.apache.tomcat.InstanceManager;
import org.apache.tomcat.SimpleInstanceManager;
import org.eclipse.jetty.annotations.ServletContainerInitializersStarter;
import org.eclipse.jetty.apache.jsp.JettyJasperInitializer;
import org.eclipse.jetty.plus.annotation.ContainerInitializer;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.webapp.WebAppContext;

import com.epam.wilma.message.search.web.domain.exception.ServerException;
import com.epam.wilma.message.search.web.service.WebAppStopper;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

/**
* Responsible for configuring, starting and
* stopping the jetty server.
* @author Tamas_Bihari
*
* @author Tamas_Bihari, Tamas Kohegyi
*/

public class WebAppServer {
Expand All @@ -46,8 +47,17 @@ public class WebAppServer {
private static final String WEBAPP_ROOT = "webapp";
private Server server;

private static List<ContainerInitializer> jspInitializers() {
JettyJasperInitializer sci = new JettyJasperInitializer();
ContainerInitializer initializer = new ContainerInitializer(sci, null);
List<ContainerInitializer> initializers = new ArrayList<>();
initializers.add(initializer);
return initializers;
}

/**
* Creates and configures the webapp server.
*
* @param port the port the server listens on
*/
public void createServer(final Integer port) {
Expand Down Expand Up @@ -86,9 +96,18 @@ private WebAppContext configureWebAppContext() {
context.setResourceBase(baseUrl + "");
context.setContextPath("/");
context.setParentLoaderPriority(true);
WebAppStopper webAppStopper = new WebAppStopper(this, Executors.newSingleThreadExecutor());
Servlet shutdownServlet = new ShutdownServlet(webAppStopper);
context.addServlet(new ServletHolder(shutdownServlet), SHUTDOWN_URL);

context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$");

context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);

// ErrorPageErrorHandler errorHandler = new ErrorPageErrorHandler();
// errorHandler.addErrorPage(HttpStatus.NOT_FOUND.value(), "/wilma-messages/e404");
// errorHandler.addErrorPage(HttpStatus.INTERNAL_SERVER_ERROR.value(), "/wilma-messages/e500");
// context.setErrorHandler(errorHandler);
return context;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="false"%>
<%@ page session="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="false"%>
<%@ page session="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
Expand Down

0 comments on commit f5be759

Please sign in to comment.