Skip to content

Commit a1b414e

Browse files
springbootdemo-tomcat11: add README documenting deployment, services, and context path gotcha
Documents the critical Tomcat directory naming requirement (axis2-json-api not axis2-json-api.war), the full test flow, Axis2 JSON-RPC request format, and architectural differences from the WildFly springbootdemo module. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 3cab684 commit a1b414e

1 file changed

Lines changed: 151 additions & 0 deletions

File tree

  • modules/samples/userguide/src/userguide/springbootdemo-tomcat11
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
-->
19+
20+
# springbootdemo-tomcat11
21+
22+
Axis2 JSON-RPC services deployed as a WAR in **Apache Tomcat 11**, using Spring Boot 3.x as a
23+
configuration framework only — there is no embedded container.
24+
25+
Tested with: **Tomcat 11.0.20** · **OpenJDK 21** · **Spring Boot 3.4.3**
26+
27+
---
28+
29+
## Services
30+
31+
| Service | Path | Auth |
32+
|---------|------|------|
33+
| `LoginService.login` | `POST /axis2-json-api/services/LoginService` | None (public) |
34+
| `TestwsService.testws` | `POST /axis2-json-api/services/TestwsService` | Bearer token |
35+
| `BigDataH2Service.processBigDataSet` | `POST /axis2-json-api/services/BigDataH2Service` | None (public) |
36+
| OpenAPI spec (JSON) | `GET /axis2-json-api/openapi.json` | None |
37+
| OpenAPI spec (YAML) | `GET /axis2-json-api/openapi.yaml` | None |
38+
| Swagger UI | `GET /axis2-json-api/swagger-ui` | None |
39+
40+
---
41+
42+
## Build
43+
44+
```bash
45+
cd modules/samples/userguide/src/userguide/springbootdemo-tomcat11
46+
mvn package
47+
```
48+
49+
This produces an exploded WAR directory at `target/deploy/axis2-json-api/`.
50+
51+
---
52+
53+
## Deploy to Tomcat 11
54+
55+
```bash
56+
# Copy exploded WAR to Tomcat webapps
57+
cp -r target/deploy/axis2-json-api /path/to/tomcat/webapps/
58+
59+
# Restart Tomcat
60+
/path/to/tomcat/bin/shutdown.sh && /path/to/tomcat/bin/startup.sh
61+
```
62+
63+
### CRITICAL: Directory naming and context path
64+
65+
Tomcat strips the `.war` suffix when deploying a **packaged** `foo.war` file, giving context
66+
path `/foo`. However, when deploying an **exploded directory**, Tomcat uses the directory name
67+
as-is. A directory named `axis2-json-api.war/` deploys at context path `/axis2-json-api.war`,
68+
**not** `/axis2-json-api`.
69+
70+
The Maven build produces `target/deploy/axis2-json-api` (no `.war` suffix) for exactly this
71+
reason. Do not rename the directory before copying to `webapps/`.
72+
73+
---
74+
75+
## Test flow
76+
77+
### 1. Verify OpenAPI docs
78+
79+
```bash
80+
curl http://localhost:8080/axis2-json-api/openapi.json
81+
curl http://localhost:8080/axis2-json-api/openapi.yaml
82+
# Interactive UI:
83+
curl http://localhost:8080/axis2-json-api/swagger-ui
84+
```
85+
86+
### 2. Login (get Bearer token)
87+
88+
```bash
89+
curl -s -X POST http://localhost:8080/axis2-json-api/services/LoginService \
90+
-H 'Content-Type: application/json' \
91+
-d '{"login":[{"request":{"email":"user@example.com","credentials":"password"}}]}'
92+
```
93+
94+
Response: `{"loginResponse":{"token":"<JWT>","status":"OK"}}`
95+
96+
### 3. Call protected service
97+
98+
```bash
99+
TOKEN="<JWT from step 2>"
100+
curl -s -X POST http://localhost:8080/axis2-json-api/services/TestwsService \
101+
-H 'Content-Type: application/json' \
102+
-H "Authorization: Bearer $TOKEN" \
103+
-d '{"testws":[{"request":{"name":"World"}}]}'
104+
```
105+
106+
### 4. Call public BigData service
107+
108+
```bash
109+
curl -s -X POST http://localhost:8080/axis2-json-api/services/BigDataH2Service \
110+
-H 'Content-Type: application/json' \
111+
-d '{"processBigDataSet":[{"request":{"numRecords":1000}}]}'
112+
```
113+
114+
---
115+
116+
## Axis2 JSON-RPC request format
117+
118+
The top-level key is the **operation name**, and the body is wrapped in an array:
119+
120+
```json
121+
{ "operationName": [{ "request": { ...fields... } }] }
122+
```
123+
124+
---
125+
126+
## Architecture notes
127+
128+
- **No embedded container**`Axis2Application` extends `SpringBootServletInitializer`, not
129+
`SpringApplication.run()`. Spring Boot only provides configuration; Tomcat is the server.
130+
- **No `DispatcherServlet`**`@GetMapping` annotations are dead code in this module. OpenAPI
131+
endpoints are served by `OpenApiServlet`, a plain `HttpServlet` registered directly in
132+
`Axis2WebAppInitializer` at `/openapi.json`, `/openapi.yaml`, and `/swagger-ui`.
133+
- **OpenAPI module**`axis2-openapi-<version>.jar` is copied to
134+
`WEB-INF/modules/openapi-<version>.mar` by the Maven build. It must be present for
135+
`GET /openapi.*` and `GET /swagger-ui` to work.
136+
- **Security** — three Spring Security filter chains: OpenApi (Order 2, unauthenticated),
137+
Login (Order 3, unauthenticated), Token (remaining, requires Bearer JWT).
138+
139+
---
140+
141+
## Relationship to `springbootdemo` (WildFly)
142+
143+
`springbootdemo-tomcat11` is derived from `springbootdemo` (which targets WildFly). The two
144+
modules share the same service logic but differ in:
145+
146+
| Aspect | `springbootdemo` (WildFly) | `springbootdemo-tomcat11` |
147+
|--------|---------------------------|--------------------------|
148+
| Server | WildFly / embedded Undertow | Apache Tomcat 11 |
149+
| Context path | `/axis2-json-api` | `/axis2-json-api` |
150+
| OpenAPI routing | `OpenApiServlet` via `Axis2WebAppInitializer` | Same |
151+
| H2 BigData service | Yes | Yes |

0 commit comments

Comments
 (0)