Skip to content

fix: PROD-INSIGHTS-API-26 support external servlet container#228

Open
Komzpa wants to merge 1 commit intomasterfrom
codex/fix-beandefinitionstoreexception-in-api
Open

fix: PROD-INSIGHTS-API-26 support external servlet container#228
Komzpa wants to merge 1 commit intomasterfrom
codex/fix-beandefinitionstoreexception-in-api

Conversation

@Komzpa
Copy link
Copy Markdown
Member

@Komzpa Komzpa commented Sep 3, 2025

Summary

  • allow running inside external servlet container by extending SpringBootServletInitializer

Testing

  • make precommit (fails: No rule to make target 'precommit')
  • mvn -q test (fails: Non-resolvable parent POM; could not transfer artifact)

https://chatgpt.com/codex/tasks/task_e_68b888459d3c832481b164230e77ddce

Summary by CodeRabbit

  • Chores
    • Enabled deployment to external servlet containers (WAR-style), expanding hosting options for enterprise app servers.
    • Maintains support for standalone execution with no changes to API behavior.
    • Improves compatibility with managed environments and simplifies infrastructure integration.
    • No user-facing functionality changes; this is a deployment enhancement.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Sep 3, 2025

Walkthrough

Enables deployment in an external servlet container by making InsightsApiApplication extend SpringBootServletInitializer and adding a configure(SpringApplicationBuilder) method while retaining the existing SpringApplication.run(...) main entry point.

Changes

Cohort / File(s) Summary
Bootstrapping & Deployment
src/main/java/io/kontur/insightsapi/InsightsApiApplication.java
Class now extends SpringBootServletInitializer; imports added; new protected configure(SpringApplicationBuilder) returning application.sources(InsightsApiApplication.class); main method unchanged.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant User
  participant JVM
  participant InsightsApiApplication
  participant SpringBoot
  participant ServletContainer

  alt Standalone execution (unchanged)
    User->>JVM: run main()
    JVM->>InsightsApiApplication: main(String[] args)
    InsightsApiApplication->>SpringBoot: SpringApplication.run(InsightsApiApplication.class, args)
    SpringBoot-->>User: Application started (JAR)
  else External servlet container (new path)
    ServletContainer->>InsightsApiApplication: initialize via SpringBootServletInitializer
    InsightsApiApplication->>InsightsApiApplication: configure(SpringApplicationBuilder)
    InsightsApiApplication->>SpringBoot: application.sources(InsightsApiApplication.class)
    SpringBoot-->>ServletContainer: Application initialized (WAR)
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-beandefinitionstoreexception-in-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between fc45798 and 4f23ed1.

📒 Files selected for processing (1)
  • src/main/java/io/kontur/insightsapi/InsightsApiApplication.java (1 hunks)
🔇 Additional comments (1)
src/main/java/io/kontur/insightsapi/InsightsApiApplication.java (1)

13-13: LGTM: correct hook for external servlet containers

Extending SpringBootServletInitializer is the standard approach for WAR deployment on Spring Boot 2/3 and works alongside the existing main method.

Comment on lines +5 to +6
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

External container support requires WAR packaging and provided container starter

Imports look correct. To actually run in an external servlet container, verify the Maven setup: packaging should be war and your servlet container starter (tomcat/jetty/undertow) should be scope provided. Otherwise you may end up with an embedded container conflict or an undeployable artifact.

Run this to check:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Packaging (expect: war):"
rg -nP '<packaging>\s*(war|jar)\s*</packaging>' pom.xml || echo "No <packaging> tag found"

echo -e "\nServlet container starters present:"
rg -nP 'spring-boot-starter-(tomcat|jetty|undertow)' pom.xml -n -C2 || true

echo -e "\nProvided-scope check for container starters (expect: provided):"
rg -nP '(?s)<dependency>\s*<groupId>org\.springframework\.boot</groupId>\s*<artifactId>spring-boot-starter-(tomcat|jetty|undertow)</artifactId>.*?<scope>provided</scope>.*?</dependency>' pom.xml -n -C2 || echo "No provided-scope container starter found"

Length of output: 799


pom.xml needs WAR packaging and provided-scope servlet starter
pom.xml currently has no <packaging>war</packaging> (defaults to JAR) and no external servlet container starter. To deploy as a WAR, add under <project>:

<packaging>war</packaging>

and include, for example:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-tomcat</artifactId>
  <scope>provided</scope>
</dependency>
🤖 Prompt for AI Agents
In src/main/java/io/kontur/insightsapi/InsightsApiApplication.java around lines
5 to 6, the project is preparing for WAR deployment (imports of
SpringBootServletInitializer) but pom.xml is still configured for JAR; update
pom.xml to set <packaging>war</packaging> under the <project> element and add
the servlet container starter with provided scope (e.g.,
spring-boot-starter-tomcat with <scope>provided</scope>) so the app can be
deployed as a WAR to an external servlet container.

Comment on lines +15 to +21
/**
* Allow running the application inside an external servlet container.
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(InsightsApiApplication.class);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

configure(...) is correct; tighten the Javadoc (nit)

Implementation is standard. Consider sharpening the Javadoc to clarify WAR/traditional deployment context.

-    /**
-     * Allow running the application inside an external servlet container.
-     */
+    /**
+     * Configure the application for traditional (WAR) deployment to an external Servlet 3.0+ container.
+     */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* Allow running the application inside an external servlet container.
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(InsightsApiApplication.class);
}
/**
* Configure the application for traditional (WAR) deployment to an external Servlet 3.0+ container.
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(InsightsApiApplication.class);
}
🤖 Prompt for AI Agents
In src/main/java/io/kontur/insightsapi/InsightsApiApplication.java around lines
15 to 21, the configure(...) method is fine but the Javadoc is vague; update the
comment to explicitly state that this override enables running the Spring Boot
application as a WAR in an external servlet container (traditional servlet
deployment) by providing the SpringApplicationBuilder source, mentioning
WAR/traditional deployment context and why it's needed (e.g., when deploying to
Tomcat/Jetty as a WAR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant