Search code examples
javamavenjava-8maven-jetty-plugin

Java app with Maven and Jetty on Windows 10: HTTP ERROR: 503 Problem accessing /. Reason: Service Unavailable


I'm trying to run an about nine years old Java application on Windows 10 with mvn -Dluke.confdir=file://C:\\ecoconfig\\ecomodules-calculation.conf jetty:run from the command prompt and it gives the following warning (three dots represent a lot of lines at various files):

[WARNING] Failed startup of context o.e.j.m.p.JettyWebAppContext@6bb1d205{/,[file:///C:/Users/03260585/Work%
20Folders/ecomodules-calculation/WebContent/, jar:file:///C:/Users/03260585/.m2/repository/io/springfox/
springfox-swagger-ui/2.8.0/springfox-swagger-ui-2.8.0.jar!/META-INF/resources],STARTING}
{file:///C:/Users/03260585/Work%20Folders/ecomodules-calculation/WebContent/}
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'org.springframework.context.support.PropertySourcesPlaceholderConfigurer#0': 
Cannot resolve reference to bean 'propertyConfigurer' while setting bean property 'properties'; 
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'propertyConfigurer': Invocation of init method failed; nested exception is java.net.UnknownHostException: C
...
...
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'propertyConfigurer': Invocation of init method failed; nested exception is java.net.UnknownHostException: C
...
...
...
Caused by: java.net.UnknownHostException: C

Using single \ instead of \\ and wrapping the file path to single or double quotes gives the same warning. The following line is found from applicationContext.xml:

<util:properties id="propertyConfigurer" location="${luke.confdir}/ecomodules-calculation.conf" />

and I suspect that if my initial command does not have a problem in the file path format, then the .conf file which I filled according to the instructions left by the previous developers has problematic content. The .conf file is below, I commented out two last lines as the password recovery is not needed in the remaining development process. Everything is pre-filled except jdbc.username, jdbc.password and jwt.secret which I inserted.

jdbc.driverClassName=org.postgresql.Driver
jdbc.url=jdbc:postgresql://localhost:5432/ecomodules?currentSchema=ecomodules
# Database username. Probably ecomodules. Configure as appropriate.
jdbc.username=correct_username
# Database user password. Configure as appropriate.
jdbc.password=correct_password

# Generate at least 256-bit key here
# example using openssl command:
# openssl rand -base64 32
# for convenience, here is one: /e+Azj4FkSAhlwtg0yyvcUPulrtxS66pRgvF04vNvvg=
# do not use it for other than local dev environments since it's not a platform secret
jwt.secret=7e+Azj4FkSAhlwtg0yyvcUPulrtxS66pRgvF04vNvvgt
jwt.issuer=Luonnonvarakeskus
jwt.cookieName=ECOMODULES_COOKIE
jwt.ttl=P7D

# SMTP service hostname for forgot password mechanism. smtprelay.ns.luke.fi in luke internal usage
#spring.mail.host=
#spring.mail.port=25

The app is served at localhost:8080/ which says

HTTP ERROR: 503
Problem accessing /. Reason: 
Service Unavailable

I tried also localhost:8080/index.html but the same error is displayed there. Could someone tell me what is the problem here? How can I get the app running properly? I have no experience in Java development so I'm quite lost with this.

java -version:

openjdk version "1.8.0_392"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_392-b08)
OpenJDK 64-Bit Server VM (Temurin)(build 25.392-b08, mixed mode)

javac -version:

javac 1.8.0_392

mvn -version:

Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: C:\Program Files\Maven\apache-maven-3.9.6
Java version: 1.8.0_392, vendor: Temurin, runtime: C:\Program Files\Java\jdk-8.0.392.8\jre
Default locale: fi_FI, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

pom.xml:

<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>fi.luke</groupId>
    <artifactId>ecomodules-calculation</artifactId>
    <version>1.2.20190227.1-SNAPSHOT</version>
    <name>EcoModules calculation service</name>
    <packaging>war</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <doclint>none</doclint>
    </properties>

    <scm>
        <developerConnection>scm:git:${env.GIT_SERVER}/tietohallinto/ecomodules-calculation</developerConnection>
        <tag>HEAD</tag>
    </scm>

    <distributionManagement>
        <repository>
            <id>deployment</id>
            <name>Internal Releases</name>
            <url>https://nexus.ns.luke.fi/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>deployment</id>
            <name>Internal Snapshots</name>
            <url>https://nexus.ns.luke.fi/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <dependencies>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4.1212</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-dbcp2</artifactId>
            <version>2.1.1</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.22</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.7.22</version>
        </dependency>
        <dependency>
            <groupId>fi.luke</groupId>
            <artifactId>ecomodules-common</artifactId>
            <version>4.30-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-web-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-jpa</artifactId>
            <version>1.11.6.RELEASE</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring-orm</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-context</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-tx</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-beans</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-core</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>spring-aop</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.8.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.6.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>9.3.7.v20160115</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.jsonwebtoken/jjwt -->
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer -->
        <dependency>
            <groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
            <artifactId>owasp-java-html-sanitizer</artifactId>
            <version>r239</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>4.3.10.RELEASE</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>ecomodules-calculation</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <argLine>-Dfile.encoding=UTF-8</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                    <systemPropertyVariables>
                        <file.encoding>UTF-8</file.encoding>
                    </systemPropertyVariables>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <parameters>true</parameters>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.0.0</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.5</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <tagNameFormat>@{project.version}</tagNameFormat>
                    <preparationGoals>clean</preparationGoals><!-- default is "clean verify" -->
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <warSourceDirectory>WebContent</warSourceDirectory>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.7.v20160115</version>
                <configuration>
                    <stopPort>9966</stopPort>
                    <stopKey>sidfhsdfh</stopKey>
                    <scanIntervalSeconds>0</scanIntervalSeconds>
                    <webAppConfig>
                        <contextPath>/</contextPath>
                    </webAppConfig>
                    <webAppSourceDirectory>${basedir}/WebContent</webAppSourceDirectory>
                </configuration>
            </plugin>
        
            <plugin>
              <groupId>org.sonatype.ossindex.maven</groupId>
              <artifactId>ossindex-maven-plugin</artifactId>
              <version>3.1.0</version>
              <configuration>
                <fail>false</fail>
              </configuration>
              <executions>
                <execution>
                  <id>audit-dependencies</id>
                  <phase>validate</phase>
                  <goals>
                    <goal>audit</goal>
                  </goals>
                </execution>
              </executions>
            </plugin>
        
        </plugins>
        <resources>
            <resource>
                <directory>properties</directory>
                <includes>
                    <include>constant.properties</include>
                </includes>
            </resource>
        </resources>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>findbugs-maven-plugin</artifactId>
                <version>3.0.4</version>
                <configuration>
                    <excludeFilterFile>FindbugsExcludeFilter.xml</excludeFilterFile>
                    <effort>Max</effort>
                    <threshold>Low</threshold>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.0.1</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.8.1</version>
            </plugin>
        </plugins>
    </reporting>
</project>

Solution

  • Re-installing Maven and Node.js and uncommenting the last lines from the .conf file solved the issue. Turned out that spring.mail.host and spring.mail.port should have values in the .conf file when starting the app even though the password recovery is not used.