diff --git a/TASMAN-embedded/pom.xml b/TASMAN-embedded/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ce0eb8b0eac058c64c45b741dd6f6b4a9a99bc56 --- /dev/null +++ b/TASMAN-embedded/pom.xml @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>it.inaf.ia2.tap</groupId> + <artifactId>tasman-embedded</artifactId> + <version>1.2.0</version> + <packaging>jar</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>1.7</maven.compiler.source> + <maven.compiler.target>1.7</maven.compiler.target> + <jetty.version>9.4.6.v20170531</jetty.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-server</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>jetty-webapp</artifactId> + <version>${jetty.version}</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>org.eclipse.jetty</groupId> + <artifactId>apache-jsp</artifactId> + <version>${jetty.version}</version> + <type>jar</type> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <mainClass>it.inaf.ia2.tap.tasman.Main</mainClass> + </manifest> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.0.0</version> + <configuration> + <archive> + <manifest> + <addClasspath>true</addClasspath> + <mainClass>it.inaf.ia2.tap.tasman.Main</mainClass> + </manifest> + </archive> + <descriptorRefs> + <descriptorRef>jar-with-dependencies</descriptorRef> + </descriptorRefs> + <appendAssemblyId>false</appendAssemblyId> + <finalName>${project.artifactId}</finalName> + </configuration> + <executions> + <execution> + <id>create-my-bundle</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/TASMAN-embedded/src/main/java/it/inaf/ia2/tap/tasman/Main.java b/TASMAN-embedded/src/main/java/it/inaf/ia2/tap/tasman/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..759ba1ecf5a157817f6f9869aa94eb2906092673 --- /dev/null +++ b/TASMAN-embedded/src/main/java/it/inaf/ia2/tap/tasman/Main.java @@ -0,0 +1,40 @@ +package it.inaf.ia2.tap.tasman; + +import java.io.File; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.webapp.WebAppContext; + +/** + * + * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} + */ +public class Main { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws Exception { + Server server = new Server(2500); + + WebAppContext webapp = new WebAppContext(); + webapp.setContextPath("/"); + File warFile = new File("/home/sonia/git/TASMAN/TASMAN-webapp/target/tasman-webapp-1.2.0.war"); + webapp.setWar(warFile.getAbsolutePath()); + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=477705 + //https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty + webapp.prependServerClass("-org.eclipse.jetty.server.handler.ContextHandler"); + webapp.prependServerClass("-org.eclipse.jetty.servlet.FilterHolder"); + webapp.prependServerClass("-org.eclipse.jetty.servlet.ServletContextHandler"); + webapp.prependServerClass("-org.eclipse.jetty.servlet.ServletHolder"); + + server.setHandler(webapp); + + server.start(); + server.dumpStdErr(); + + // The use of server.join() the will make the current thread join and + // wait until the server is done executing. + server.join(); + } +} diff --git a/TASMAN-webapp/pom.xml b/TASMAN-webapp/pom.xml index 9038a6816e8e76d65def5140710242cabff9c484..7c6bdff97b149e43cede5ee20a42521053345af8 100644 --- a/TASMAN-webapp/pom.xml +++ b/TASMAN-webapp/pom.xml @@ -15,28 +15,36 @@ <netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license> <jersey.version>2.23.2</jersey.version> <deltaspike.version>1.7.2</deltaspike.version> - </properties> + <enable.weld.config.start></enable.weld.config.start> + <enable.weld.config.end></enable.weld.config.end> + <enable.jetty.config.start></enable.jetty.config.start> + <enable.jetty.config.end></enable.jetty.config.end> + </properties> <profiles> <profile> - <id>GlassFish</id> + <id>FullEE</id> <activation> <property> <name>environment</name> - <value>GlassFish</value> + <value>FullEE</value> </property> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> - <id>Tomcat</id> + <id>ServletContainer</id> <activation> <property> <name>environment</name> - <value>Tomcat</value> + <value>ServletContainer</value> </property> </activation> + <properties> + <enable.weld.config.start><!-- </enable.weld.config.start> + <enable.weld.config.end> --></enable.weld.config.end> + </properties> <dependencies> <dependency> <groupId>org.glassfish</groupId> @@ -82,6 +90,20 @@ </dependency> </dependencies> </profile> + <profile> + <id>Jetty</id> + <!-- for Jetty use both this and the ServletContainer profile --> + <activation> + <property> + <name>environment</name> + <value>Jetty</value> + </property> + </activation> + <properties> + <enable.jetty.config.start><!-- </enable.jetty.config.start> + <enable.jetty.config.end> --></enable.jetty.config.end> + </properties> + </profile> </profiles> <dependencies> @@ -180,6 +202,7 @@ <build> <resources> + <!-- Include version.txt and filter it --> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> @@ -187,6 +210,7 @@ <include>**/version.txt</include> </includes> </resource> + <!-- Include all other files without filtering them --> <resource> <directory>src/main/resources</directory> <filtering>false</filtering> @@ -215,12 +239,21 @@ <configuration> <attachClasses>true</attachClasses> <failOnMissingWebXml>false</failOnMissingWebXml> + <webResources> + <resource> + <directory>src/main/webapp</directory> + <filtering>true</filtering> + <includes> + <include>**/web.xml</include> + </includes> + </resource> + </webResources> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> - <version>2.6</version> + <version>2.8</version> <executions> <execution> <phase>validate</phase> diff --git a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/ConfigurationManager.java b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/ConfigurationManager.java index 7e3a8f9fd5effce2c71114fd931a729152f18092..7754a94ed087a04d2ad79c73c3b6c7ed1990a9c0 100644 --- a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/ConfigurationManager.java +++ b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/ConfigurationManager.java @@ -66,7 +66,7 @@ public class ConfigurationManager { public void init() { try { Properties prop = new Properties(); - try (InputStream in = getClass().getClassLoader().getResourceAsStream("webapp.properties")) { + try (InputStream in = ConfigurationManager.class.getClassLoader().getResourceAsStream("webapp.properties")) { prop.load(in); } configDirectory = new File(prop.getProperty("config_directory")); diff --git a/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml b/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml index 6e31eb67d70921005c524ffee477778f0686f1d6..cb584df0722e5c7b2d6f3a767874fbc0943abbc4 100644 --- a/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml +++ b/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml @@ -69,4 +69,33 @@ <exception-type>javax.faces.application.ViewExpiredException</exception-type> <location>/faces/expired.xhtml</location> </error-page> + + <!-- + ######################################################################## + # WELD configuration: necessary for Tomcat and Jetty. # + # Following section will be automatically decommented by Maven profile # + ######################################################################## + --> + <!-- ${enable.weld.config.end} + <resource-env-ref> + <resource-env-ref-name>BeanManager</resource-env-ref-name> + <resource-env-ref-type>javax.enterprise.inject.spi.BeanManager</resource-env-ref-type> + </resource-env-ref> + <listener> + <listener-class>org.jboss.weld.environment.servlet.Listener</listener-class> + </listener> + ${enable.weld.config.start} --> + + <!-- + ################################################################################## + # JSF com.sun.faces.config.ConfigureListener configuration: necessary for Jetty. # + # See: https://stackoverflow.com/q/7886035/771431 # + # Following section will be automatically decommented by Maven profile # + ################################################################################## + --> + <!-- ${enable.jetty.config.end} + <listener> + <listener-class>com.sun.faces.config.ConfigureListener</listener-class> + </listener> + ${enable.jetty.config.start} --> </web-app>