1

anyone can explain to me why my spring jpms module exited ?
my code is too simple :

package ir.moke.module.spring;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication(scanBasePackages = "ir.moke.module.spring.api")
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

Controller class:

package ir.moke.module.spring.api;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestApi {

    @GetMapping("/hello")
    public String sayHello() {
        return "Hello dear !";
    }
}

this is module-info.java

module spring.jpms {
    requires spring.web;
    requires spring.boot.autoconfigure;
    requires spring.boot;
    requires spring.core;

    opens ir.moke.module.spring to spring.core, spring.beans,spring.context ;
    opens ir.moke.module.spring.api to spring.beans, spring.web;
}

pom.xml :

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.0</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>ir.moke.module</groupId>
    <artifactId>spring</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring</name>
    <description>Demo project for Spring Boot</description>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>

            <!-- Compiler -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <release>21</release>
                </configuration>
            </plugin>

            <!-- copy compiled jar file to target/lib , only needed for test jpms -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <outputDirectory>${project.build.directory}/lib/</outputDirectory>
                </configuration>
            </plugin>

            <!-- Copy dependencies , only needed for test jpms -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

I compiled project with this command :

mvn -DskipTests clean compile package

and try to run :

> java --module-path target/lib -m spring.jpms/ir.moke.module.spring.Application     
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.0)

[2024-06-03 22:19:05.264] - 85702 INFO [main] --- ir.moke.module.spring.Application: Starting Application using Java 21 with PID 85702 (/home/mah454/Downloads/spring/target/lib/spring-0.0.1-SNAPSHOT.jar started by mah454 in /home/mah454/Downloads/spring)
[2024-06-03 22:19:05.293] - 85702 INFO [main] --- ir.moke.module.spring.Application: No active profile set, falling back to 1 default profile: "default"
[2024-06-03 22:19:05.860] - 85702 INFO [main] --- ir.moke.module.spring.Application: Started Application in 0.888 seconds (process running for 1.197)

Spring application just exited without any error or exception !
how to debug this problem ?


Update Question:

I changed log level to DEBUG:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.1.0)

[2024-06-04 12:44:19.891] - 21151 INFO [main] --- org.example.Main: Starting Main using Java 21 with PID 21151 (/home/mah454/Downloads/spring-jpms/target/modules/spring-jpms-0.0.1-SNAPSHOT.jar started by mah454 in /home/mah454/Downloads/spring-jpms)
[2024-06-04 12:44:19.915] - 21151 FINE [main] --- org.example.Main: Running with Spring Boot, Spring
[2024-06-04 12:44:19.917] - 21151 INFO [main] --- org.example.Main: No active profile set, falling back to 1 default profile: "default"
[2024-06-04 12:44:19.918] - 21151 FINE [main] --- org.springframework.boot.SpringApplication: Loading source class org.example.Main
[2024-06-04 12:44:19.965] - 21151 FINE [main] --- org.springframework.context.annotation.AnnotationConfigApplicationContext: Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@157853da
[2024-06-04 12:44:19.978] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.context.annotation.internalConfigurationAnnotationProcessor'
[2024-06-04 12:44:19.989] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory'
[2024-06-04 12:44:20.076] - 21151 FINE [main] --- org.springframework.context.annotation.ClassPathBeanDefinitionScanner: Identified candidate component class: URL [jar:file:///home/mah454/Downloads/spring-jpms/target/modules/spring-jpms-0.0.1-SNAPSHOT.jar!/org/example/Sample.class]
[2024-06-04 12:44:20.382] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'propertySourcesPlaceholderConfigurer'
[2024-06-04 12:44:20.388] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.sql.init.dependency.DatabaseInitializationDependencyConfigurer$DependsOnDatabaseInitializationPostProcessor'
...
...
...
[2024-06-04 12:44:20.447] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'standardJacksonObjectMapperBuilderCustomizer'
[2024-06-04 12:44:20.450] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties'
[2024-06-04 12:44:20.452] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.context.properties.BoundConfigurationProperties'
[2024-06-04 12:44:20.470] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Autowiring by type from bean name 'standardJacksonObjectMapperBuilderCustomizer' via factory method to bean named 'spring.jackson-org.springframework.boot.autoconfigure.jackson.JacksonProperties'
[2024-06-04 12:44:20.473] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'parameterNamesModule'
[2024-06-04 12:44:20.473] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$ParameterNamesModuleConfiguration'
[2024-06-04 12:44:20.476] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'jsonMixinModule'
[2024-06-04 12:44:20.477] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration$JacksonMixinConfiguration'
[2024-06-04 12:44:20.478] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'jsonMixinModuleEntries'
[2024-06-04 12:44:20.479] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Autowiring by type from bean name 'jsonMixinModuleEntries' via factory method to bean named 'org.springframework.context.annotation.AnnotationConfigApplicationContext@157853da'
[2024-06-04 12:44:20.480] - 21151 FINE [main] --- org.springframework.boot.autoconfigure.AutoConfigurationPackages: @EnableAutoConfiguration was declared on a class in the package 'org.example'. Automatic @Repository and @Entity scanning is enabled.
...
...
...
[2024-06-04 12:44:20.567] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration'
[2024-06-04 12:44:20.569] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties'
[2024-06-04 12:44:20.571] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Autowiring by type from bean name 'org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration' via constructor to bean named 'spring.info-org.springframework.boot.autoconfigure.info.ProjectInfoProperties'
[2024-06-04 12:44:20.572] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.sql.init.SqlInitializationAutoConfiguration'
[2024-06-04 12:44:20.572] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'spring.sql.init-org.springframework.boot.autoconfigure.sql.init.SqlInitializationProperties'
[2024-06-04 12:44:20.577] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration'
[2024-06-04 12:44:20.577] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'sslPropertiesSslBundleRegistrar'
[2024-06-04 12:44:20.578] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'spring.ssl-org.springframework.boot.autoconfigure.ssl.SslProperties'
[2024-06-04 12:44:20.579] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Autowiring by type from bean name 'sslPropertiesSslBundleRegistrar' via factory method to bean named 'spring.ssl-org.springframework.boot.autoconfigure.ssl.SslProperties'
[2024-06-04 12:44:20.580] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'sslBundleRegistry'
[2024-06-04 12:44:20.581] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Autowiring by type from bean name 'sslBundleRegistry' via factory method to bean named 'sslPropertiesSslBundleRegistrar'
[2024-06-04 12:44:20.584] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration'
[2024-06-04 12:44:20.585] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'taskExecutorBuilder'
[2024-06-04 12:44:20.586] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'spring.task.execution-org.springframework.boot.autoconfigure.task.TaskExecutionProperties'
[2024-06-04 12:44:20.587] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Autowiring by type from bean name 'taskExecutorBuilder' via factory method to bean named 'spring.task.execution-org.springframework.boot.autoconfigure.task.TaskExecutionProperties'
[2024-06-04 12:44:20.590] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.task.TaskSchedulingAutoConfiguration'
[2024-06-04 12:44:20.592] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'taskSchedulerBuilder'
[2024-06-04 12:44:20.593] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'spring.task.scheduling-org.springframework.boot.autoconfigure.task.TaskSchedulingProperties'
[2024-06-04 12:44:20.595] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Autowiring by type from bean name 'taskSchedulerBuilder' via factory method to bean named 'spring.task.scheduling-org.springframework.boot.autoconfigure.task.TaskSchedulingProperties'
[2024-06-04 12:44:20.597] - 21151 FINE [main] --- org.springframework.beans.factory.support.DefaultListableBeanFactory: Creating shared instance of singleton bean 'org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfiguration'
[2024-06-04 12:44:20.609] - 21151 FINE [main] --- org.springframework.context.support.DefaultLifecycleProcessor: Starting beans in phase -2147483647
[2024-06-04 12:44:20.610] - 21151 FINE [main] --- org.springframework.context.support.DefaultLifecycleProcessor: Successfully started bean 'springBootLoggingLifecycle'
[2024-06-04 12:44:20.623] - 21151 FINE [main] --- org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLogger: 


============================
CONDITIONS EVALUATION REPORT
============================


Positive matches:
-----------------

   AopAutoConfiguration matched:
      - @ConditionalOnProperty (spring.aop.auto=true) matched (OnPropertyCondition)

   AopAutoConfiguration.ClassProxyingConfiguration matched:
      - @ConditionalOnMissingClass did not find unwanted class 'org.aspectj.weaver.Advice' (OnClassCondition)
      - @ConditionalOnProperty (spring.aop.proxy-target-class=true) matched (OnPropertyCondition)

   ApplicationAvailabilityAutoConfiguration#applicationAvailability matched:
      - @ConditionalOnMissingBean (types: org.springframework.boot.availability.ApplicationAvailability; SearchStrategy: all) did not find any beans (OnBeanCondition)

   GenericCacheConfiguration matched:
      - Cache org.springframework.boot.autoconfigure.cache.GenericCacheConfiguration automatic cache type (CacheCondition)

   ...
   ...
   ...

Negative matches:
-----------------

   ActiveMQAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.jms.ConnectionFactory' (OnClassCondition)

   AopAutoConfiguration.AspectJAutoProxyingConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.aspectj.weaver.Advice' (OnClassCondition)

   ArtemisAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.jms.ConnectionFactory' (OnClassCondition)

         ...
         ...
         ...
         ...
         
         
   TaskSchedulingAutoConfiguration#scheduledBeanLazyInitializationExcludeFilter:
      Did not match:
         - @ConditionalOnBean (names: org.springframework.context.annotation.internalScheduledAnnotationProcessor; SearchStrategy: all) did not find any beans named org.springframework.context.annotation.internalScheduledAnnotationProcessor (OnBeanCondition)

   TaskSchedulingAutoConfiguration#taskScheduler:
      Did not match:
         - @ConditionalOnBean (names: org.springframework.context.annotation.internalScheduledAnnotationProcessor; SearchStrategy: all) did not find any beans named org.springframework.context.annotation.internalScheduledAnnotationProcessor (OnBeanCondition)

   ThymeleafAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.thymeleaf.spring6.SpringTemplateEngine' (OnClassCondition)

   TransactionAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.springframework.transaction.PlatformTransactionManager' (OnClassCondition)

   UserDetailsServiceAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.springframework.security.authentication.AuthenticationManager' (OnClassCondition)

   ValidationAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.validation.executable.ExecutableValidator' (OnClassCondition)

   WebClientAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.springframework.web.reactive.function.client.WebClient' (OnClassCondition)

   WebFluxAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.springframework.web.reactive.config.WebFluxConfigurer' (OnClassCondition)

   WebMvcAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.servlet.Servlet' (OnClassCondition)

   WebServiceTemplateAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.springframework.oxm.Marshaller' (OnClassCondition)

   WebServicesAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.springframework.ws.transport.http.MessageDispatcherServlet' (OnClassCondition)

   WebSessionIdResolverAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'reactor.core.publisher.Mono' (OnClassCondition)

   WebSocketMessagingAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer' (OnClassCondition)

   WebSocketReactiveAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.servlet.Servlet' (OnClassCondition)

   WebSocketServletAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.servlet.Servlet' (OnClassCondition)

   XADataSourceAutoConfiguration:
      Did not match:
         - @ConditionalOnClass did not find required class 'jakarta.transaction.TransactionManager' (OnClassCondition)


Exclusions:
-----------

    None


Unconditional classes:
----------------------

    org.springframework.boot.autoconfigure.context.ConfigurationPropertiesAutoConfiguration

    org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration

    org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration

    org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration

    org.springframework.boot.autoconfigure.availability.ApplicationAvailabilityAutoConfiguration

    org.springframework.boot.autoconfigure.info.ProjectInfoAutoConfiguration



[2024-06-04 12:44:20.633] - 21151 INFO [main] --- org.example.Main: Started Main in 1.053 seconds (process running for 1.41)
[2024-06-04 12:44:20.635] - 21151 FINE [main] --- org.springframework.boot.availability.ApplicationAvailabilityBean: Application availability state LivenessState changed to CORRECT
[2024-06-04 12:44:20.637] - 21151 FINE [main] --- org.springframework.boot.availability.ApplicationAvailabilityBean: Application availability state ReadinessState changed to ACCEPTING_TRAFFIC

this simple code does work without any problem on spring 2.1.2.RELEASE and java 11.
but in spring 3.3.0 does not work !

4
  • Remove all your plugins and just add spring-boot-maven-plugin to build the right jar. Specify java.version as a property in your pom.xml instead of overriding the compiler plugin. Commented Jun 4, 2024 at 5:47
  • I can confirm that with the changes suggested by @M.Deinum and then using mvn package followed by java -jar target/spring-0.0.1-SNAPSHOT.jar works. Not sure about the particular need to execute with the complete command line. On the other hand I agree, the logs are not much of help here in terms of what is wrong with your current approach. Commented Jun 4, 2024 at 13:28
  • Another possibly related thread. Commented Jun 4, 2024 at 13:41
  • I want to have jpms project with spring framework , i know normal jar file working without any problem but why application exited with java --module-path target/lib -m spring.jpms/ir.moke.module.spring.Application Commented Jun 4, 2024 at 14:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.