Nabla Bower Sample

January 28, 2026 · View on GitHub

License: APACHE License: MIT Build Status Quality Gate Status

A Maven-based Java web application demonstrating a Bower sample with Eclipse Jetty server deployment. This project showcases the integration of Java backend (JAX-RS/Jersey REST APIs) with HTML/JavaScript frontend assets.

Table of Contents

Features

  • Java 11+ backend with JAX-RS (Jersey) REST APIs
  • Eclipse Jetty 9.4.x embedded server
  • Maven build system with wrapper
  • Integration tests with JUnit
  • Static content serving (HTML, CSS, JavaScript)
  • CI/CD with GitHub Actions
  • Code quality monitoring with SonarCloud

Prerequisites

  • Java: JDK 11 or higher
  • Maven: 3.6+ (or use included Maven wrapper ./mvnw)
  • curl or web browser for testing

Quick Start

  1. Clone the repository

    git clone https://github.com/AlbanAndrieu/nabla-servers-bower-sample.git
    cd nabla-servers-bower-sample
    
  2. Build the project

    ./mvnw clean package -DskipTests -Dmaven.exec.skip=true
    
  3. Run the application

    ./mvnw jetty:run -Dmaven.exec.skip=true
    
  4. Test the application

    curl http://localhost:9090/test/rest/books/test
    # Expected output: Test
    

Building

Standard Build (Java Backend Only)

This skips the frontend build which requires Node.js:

./mvnw clean package -DskipTests -Dmaven.exec.skip=true

Full Build (with Frontend)

If you have Node.js installed and want to build frontend assets:

PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true ./mvnw clean package

Build Output

After a successful build, you'll find:

  • WAR file: target/test.war (deployable web archive)
  • Compiled classes: target/classes/
  • Test classes: target/test-classes/

Running

Using Jetty Maven Plugin (Development)

./mvnw jetty:run -Dmaven.exec.skip=true

The application will be available at:

Press Ctrl+C to stop the server.

Using Standalone Jetty (Production)

  1. Build the WAR file:

    ./mvnw clean package -DskipTests -Dmaven.exec.skip=true
    
  2. Deploy to Jetty:

    # Copy target/test.war to your Jetty installation's webapps directory
    cp target/test.war $JETTY_HOME/webapps/
    

Custom Port Configuration

To run on a different port:

./mvnw jetty:run -Djetty.port=8080 -Djetty.stop.port=8081 -Dmaven.exec.skip=true

Testing

Run Unit Tests

./mvnw test

Run Integration Tests

Integration tests start an embedded Jetty server and test the deployed application:

./mvnw verify -Prun-integration-test

Manual Testing

With the server running, test the REST endpoints:

# Test the books endpoint
curl http://localhost:9090/test/rest/books/test

# Expected output: Test

Project Structure

nabla-servers-bower-sample/
├── .github/
│   ├── copilot-instructions.md    # GitHub Copilot instructions
│   └── workflows/                  # GitHub Actions CI/CD
├── app/                            # Frontend assets (HTML, CSS, JS)
│   ├── index.html
│   ├── scripts/
│   └── styles/
├── src/
│   ├── main/
│   │   ├── java/                   # Java source code
│   │   │   └── com/test/project/sample/
│   │   │       ├── App.java        # Main application class
│   │   │       ├── BookResource.java  # REST API endpoints
│   │   │       └── ...
│   │   ├── resources/              # Application resources
│   │   └── webapp/WEB-INF/         # Web application config
│   │       └── web.xml
│   └── test/
│       └── java/                   # Test code
│           └── com/test/project/sample/
│               └── DeploymentITest.java
├── pom.xml                         # Maven build configuration
├── mvnw                            # Maven wrapper script (Linux/Mac)
├── mvnw.cmd                        # Maven wrapper script (Windows)
└── README.md                       # This file

Configuration

Maven Configuration

Key properties in pom.xml:

<properties>
    <jetty.port>9090</jetty.port>           <!-- Jetty HTTP port -->
    <jetty.stop.port>8089</jetty.stop.port> <!-- Jetty shutdown port -->
    <jdk.level>11</jdk.level>               <!-- Java version -->
    <jetty9.version>9.4.19.v20190610</jetty9.version>
</properties>

Web Application Configuration

The application is deployed with context path /test, configured in pom.xml:

<webApp>
    <contextPath>/test</contextPath>
</webApp>

Development

Adding New REST Endpoints

  1. Create a new class in src/main/java/com/test/project/sample/:
@Path("/myresource")
public class MyResource {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return "Hello World!";
    }
}
  1. Register it in MyApplication.java or let Jersey auto-discover it.

  2. Rebuild and test:

    ./mvnw clean package -DskipTests -Dmaven.exec.skip=true
    ./mvnw jetty:run -Dmaven.exec.skip=true
    curl http://localhost:9090/test/rest/myresource
    

Modifying Frontend Assets

Frontend files are in the app/ directory:

  1. Edit HTML/CSS/JS files in app/
  2. Rebuild the WAR:
    ./mvnw clean package -DskipTests -Dmaven.exec.skip=true
    
  3. Restart Jetty to see changes

Hot Reload (Development Mode)

For Java code changes, Jetty maven plugin supports hot reload:

./mvnw jetty:run -Dmaven.exec.skip=true
# Make code changes, Jetty will automatically reload

Troubleshooting

Build Fails with "Parent POM not found"

Solution: The project is configured to work without the parent POM. This error should not occur in the current version.

Build Fails with NPM/Puppeteer Errors

Solution: Skip the frontend build:

./mvnw clean package -DskipTests -Dmaven.exec.skip=true

Or set the environment variable:

export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
./mvnw clean package

Port Already in Use

Solution: Either stop the process using the port or use a different port:

./mvnw jetty:run -Djetty.port=8080 -Djetty.stop.port=8081 -Dmaven.exec.skip=true

Web Resources Not Found (404 errors)

Solution: Ensure the app/ directory exists and contains your frontend files. The build copies files from app/ to the WAR.

Integration Tests Fail

Solution: Make sure no other process is using port 9090:

lsof -i :9090
# Kill any process using the port

Clean Build

If you encounter persistent build issues:

./mvnw clean
rm -rf target/
rm -rf ~/.m2/repository/com/nabla/
./mvnw clean package -DskipTests -Dmaven.exec.skip=true

Maven Repository Issues

If you encounter errors about missing artifacts from a private Nexus repository, the project is configured to use Maven Central by default. The commands in this README use the Maven Wrapper (./mvnw) which should work out of the box without additional configuration.

Note for developers: If you need to use a custom Maven settings file (e.g., for corporate proxies), you can specify it with the -s flag:

./mvnw clean package -s /path/to/settings.xml

Docker Support

Build and run with Docker:

# Build Docker image
docker build -t nabla-bower-sample .

# Run container
docker run -p 9090:9090 nabla-bower-sample

Access at: http://localhost:9090/test/

CI/CD

This project uses GitHub Actions for continuous integration:

  • maven-build.yml: Builds and tests the project on every push
  • Quality checks: SonarCloud analysis, security scanning

View build status: GitHub Actions

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

Reporting Issues

Use the GitHub issue tracker to report bugs or request features.

Pull Requests

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes and commit: git commit -am 'Add new feature'
  4. Push to the branch: git push origin feature/my-feature
  5. Submit a pull request

License

This project is licensed under both:

Choose the license that best suits your needs.

Resources

Contact

Maintainer: Alban Andrieu


Note: For GitHub Copilot users, see .github/copilot-instructions.md for detailed development guidelines.