Skip to content

Commit

Permalink
#889, remove tomcat deps. tested/working with wildfly
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenolen committed Mar 15, 2016
1 parent 7124c9f commit 77f2eb4
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 24 deletions.
37 changes: 37 additions & 0 deletions Dockerfile.wildfly
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM jboss/wildfly
MAINTAINER Steve Nolen <technolengy@gmail.com>
# Report issues here: https://github.com/ohmage/server

USER root

RUN yum install -y ant ant-junit curl nc git mysql

#### download flyway (ohmage doesn't do migrations) ####
WORKDIR /flyway
ENV FLYWAY_TGZ_URL http://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/3.2.1/flyway-commandline-3.2.1.tar.gz
RUN set -x \
&& curl -fSL "$FLYWAY_TGZ_URL" -o flyway.tar.gz \
&& tar -xvf flyway.tar.gz --strip-components=1 \
&& rm flyway.tar.gz

WORKDIR /app
ADD . /app
RUN cp db/migration/* /flyway/sql/ \
&& ant clean dist \
&& cp dist/webapp-ohmage* /opt/jboss/wildfly/standalone/deployments/app.war \
&& cp docker_entrypoint.sh /run.sh \
# modify run.sh to run wildfly instead of tomcat!
&& sed -i 's|^exec.*$|exec /opt/jboss/wildfly/bin/standalone.sh -b 0.0.0.0|g' /run.sh \
&& chmod +x /run.sh \
&& rm -rf /app

RUN mkdir -p /var/lib/ohmage && ln -s /var/lib/ohmage /ohmage
RUN useradd -ms /bin/bash ohmage && \
chown -R ohmage.ohmage /opt/jboss/wildfly/ && \
chown -R ohmage.ohmage /var/lib/ohmage

EXPOSE 8080

VOLUME /ohmage

CMD ["/run.sh"]
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<include name="slf4j-log4j12-1.7.5.jar"/>
<include name="tomcat-dbcp-7.0.42.jar" />
<include name="tomcat-jdbc-7.0.42.jar" />
<include name="tomcat-juli.jar" />
<include name="jose4j-0.4.4.jar"/>
</fileset>

Expand Down
Binary file added lib/tomcat-juli.jar
Binary file not shown.
6 changes: 4 additions & 2 deletions src/org/ohmage/jee/listener/ConfigurationFileImport.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public class ConfigurationFileImport
/**
* The location of the default configuration file.
*/
private static final String CONFIG_FILE_DEFAULT =
"WEB-INF/config/default.properties";
private static final String CONFIG_FILE_DEFAULT =
// SN: safe to prepend slash since this gets appended to
// ServletContext realpath.
"/WEB-INF/config/default.properties";
/**
* The default location for the configuration file on Windows.
*/
Expand Down
7 changes: 7 additions & 0 deletions src/org/ohmage/jee/listener/WebAppRootSetter.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public class WebAppRootSetter implements ServletContextListener {
public void contextInitialized(final ServletContextEvent event) {
// This is required to setup the web app's root for our use.
WebUtils.setWebAppRootSystemProperty(event.getServletContext());
// SN: Some piece of the class loading here assumes webapp.root has a trailing slash
// I don't know who is at fault (probably tomcat. ha!) but let's just hack in the trailing
// slash to get an easy fix. Note that tomcat breaks if this ends in two slashes, so only
// add if it doesn't already have the trailing slash.
if(!System.getProperty("webapp.root").endsWith("/")) {
System.setProperty("webapp.root", System.getProperty("webapp.root") + "/");
}
}

/*
Expand Down
9 changes: 5 additions & 4 deletions src/org/ohmage/request/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,11 @@ protected void respond(

writer.write(responseText);
}
// If the client hangs up, just print a warning.
catch(ClientAbortException e) {
LOGGER.info("The client hung up unexpectedly.", e);
}
// SN: commenting as this exception is a subclass of IOException
// and the exception is tomcat-specific.
//catch(ClientAbortException e) {
// LOGGER.info("The client hung up unexpectedly.", e);
//}
catch(IOException e) {
LOGGER.error("Unable to write response message. Aborting.", e);
}
Expand Down
26 changes: 15 additions & 11 deletions src/org/ohmage/request/image/ImageReadRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,11 @@ public void respond(HttpServletRequest httpRequest, HttpServletResponse httpResp
try {
dos.close();
}
catch(ClientAbortException e) {
LOGGER.info("The client hung up unexpectedly.", e);
}
// SN: commenting as this exception is a subclass of IOException
// and the exception is tomcat-specific.
//catch(ClientAbortException e) {
// LOGGER.info("The client hung up unexpectedly.", e);
//}
catch(IOException e) {
LOGGER.warn("Error closing the data output stream.", e);
}
Expand All @@ -297,10 +299,11 @@ public void respond(HttpServletRequest httpRequest, HttpServletResponse httpResp
httpResponse.setStatus(
HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
// If the client hangs up, just print a warning.
catch(ClientAbortException e) {
LOGGER.info("The client hung up unexpectedly.", e);
}
// SN: commenting as this exception is a subclass of IOException
// and the exception is tomcat-specific.
//catch(ClientAbortException e) {
// LOGGER.info("The client hung up unexpectedly.", e);
//}
// If the error occurred while reading from the input stream or
// writing to the output stream, abort the whole operation and
// return an error.
Expand All @@ -319,10 +322,11 @@ public void respond(HttpServletRequest httpRequest, HttpServletResponse httpResp
imageStream.close();
}
}
// If the client hangs up, just print a warning.
catch(ClientAbortException e) {
LOGGER.info("The client hung up unexpectedly.", e);
}
// SN: commenting as this exception is a subclass of IOException
// and the exception is tomcat-specific.
//catch(ClientAbortException e) {
// LOGGER.info("The client hung up unexpectedly.", e);
//}
catch(IOException e) {
LOGGER.warn("Could not close the image stream.", e);
// We don't care about failing the request, because, either, it
Expand Down
16 changes: 10 additions & 6 deletions src/org/ohmage/request/survey/SurveyResponseReadRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1377,9 +1377,11 @@ else if(OutputFormat.CSV.equals(outputFormat)) {
try {
writer.write(resultString);
}
catch(ClientAbortException e) {
LOGGER.info("The client hung up unexpectedly.", e);
}
// SN: commenting as this exception is a subclass of IOException
// and the exception is tomcat-specific.
//catch(ClientAbortException e) {
// LOGGER.info("The client hung up unexpectedly.", e);
//}
catch(IOException e) {
LOGGER.warn("Unable to write response message. Aborting.", e);
}
Expand All @@ -1388,9 +1390,11 @@ else if(OutputFormat.CSV.equals(outputFormat)) {
try {
writer.close();
}
catch(ClientAbortException e) {
LOGGER.info("The client hung up unexpectedly.", e);
}
// SN: commenting as this exception is a subclass of IOException
// and the exception is tomcat-specific.
//catch(ClientAbortException e) {
// LOGGER.info("The client hung up unexpectedly.", e);
//}
catch(IOException e) {
LOGGER.warn("Unable to close the writer.", e);
}
Expand Down
4 changes: 3 additions & 1 deletion web/WEB-INF/web-no_ssl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
</filter-mapping>

<!-- The default Tomcat Servlet used to locate and serve static content -->
<!-- SN: commenting this as it is uncessary in tomcat7, and makes ohmage tomcat-dependent -->
<!--
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
Expand All @@ -94,7 +96,7 @@
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

-->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
Expand Down

0 comments on commit 77f2eb4

Please sign in to comment.