Commit 68bb92b
committed
This module exists for strict environments where you are force to deploy into a Servlet Container.
If you are free to deploy a new server technology, we strongly recommend to avoid this and go
directly with netty, jetty or undertow.
Generate a *.war file at build time. The *.war file can be deployed into a Servlet Container.
Add the ```jooby-servlet``` dependency to your ```pom.xml```:
```xml
<dependency>
<groupId>org.jooby</groupId>
<artifactId>jooby-ftl</artifactId>
<version>{{version}}</version>
<scope>provided</scope>
</dependency>
```
IMPORTANT: Scope must be ```provided```.
Find out the ```maven-assembly-plugin``` section in your ```pom.xml```, it looks like this:
```xml
<!-- Build jooby.zip | jooby.war -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jooby.zip</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
```
Add a new descriptorRef: ```jooby.war```
```xml
<!-- Build jooby.zip | jooby.war -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jooby.zip</descriptorRef>
<descriptorRef>jooby.war</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
```
Run: ```mvn clean package``` and find the ```*.war``` file in the ```target``` directory.
* web-sockets are not supported
* some properties has no effect when deploying into a Servlet Container:
- application.path
- appplication.port
- any other server specific property: server.*, jetty.*, netty.*, undertow.*
The ```maven-assembly-plugin``` generates the *.war file. The assembly descriptor can be found
[here](https://github.com/jooby-project/jooby/blob/master/jooby-dist/src/main/resources/assemblies/jooby.war.xml)
All it does, is to adapt the project structure to the one required by a Servlet Container.
A default web.xml file is generated by the assembly plugin. File looks like:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>application.class</param-name>
<param-value>${application.class}</param-value>
</context-param>
<listener>
<listener-class>org.jooby.servlet.ServerInitializer</listener-class>
</listener>
<servlet>
<servlet-name>jooby</servlet-name>
<servlet-class>org.jooby.servlet.ServletHandler</servlet-class>
<load-on-startup>0</load-on-startup>
<!-- MultiPart setup -->
<multipart-config>
<file-size-threshold>0</file-size-threshold>
<!-- Default 200k -->
<max-request-size>${war.maxRequestSize}</max-request-size>
</multipart-config>
</servlet>
<servlet-mapping>
<servlet-name>jooby</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
```
Default upload size is set to ```204800b``` (200kb). If you need to increase the upload size, add
the ```war.maxRequestSize``` property to ```pom.xml```:
```
<properties>
<war.maxRequestSize>1048576</war.maxRequestSize> <!-- 1mb -->
</properties>
```
It is possible to provide your own ```web.xml``` file too. Follow these steps
1. create a dir: ```src/etc/war/WEB-INF```
2. save a ```web.xml``` file inside that dir
3. run: ```mvn clean package```
That's all folks! Enjoy it!!!1 parent 54fd803 commit 68bb92b
4 files changed
Lines changed: 140 additions & 2 deletions
File tree
- jooby-servlet/src/main/resources/WEB-INF
- md
- doc/jooby-servlet
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1022 | 1022 | | |
1023 | 1023 | | |
1024 | 1024 | | |
| 1025 | + | |
1025 | 1026 | | |
1026 | 1027 | | |
1027 | 1028 | | |
| |||
0 commit comments