Commit 60551cea authored by Sonia Zorba's avatar Sonia Zorba
Browse files

Created Maven project TASMAN embedded (using jetty embedded), web.xml changes

parent 480e5518
<?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
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();
}
}
......@@ -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>&lt;!-- </enable.weld.config.start>
<enable.weld.config.end> --&gt;</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>&lt;!-- </enable.jetty.config.start>
<enable.jetty.config.end> --&gt;</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>
......
......@@ -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"));
......
......@@ -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>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment