Using IBM Integration Bus V10.0.0.3 on Windows. I encountered an issue in the Integration Toolkit that I can reproduce on a command line. I can create a new local integration node but when I try to create a new integration server on that node, the command never completes successfully.
As an administrator, to create the node I do:
mqsiprofile
mqsicreatebroker NEWNODE
mqsistart NEWNODE
All these commands are successful. Then I try to create the integration server with:
mqsicreateexecutiongroup NEWNODE -e SoapIS -w 500 -v D:\log.txt
The log.txt shows the following:
DUMBLEDORE
serializer.version=1.0
commsmessage.type=com.ibm.broker.config.proxy.Request
commsmessage.sessionId=3c38dc7a08a742e6a8a95f7afd2eed8b
...
commsmessage.operationtype=reregister
commsmessage.configobjecttype=<all>
2016-06-15 13:58:39.0371 com.ibm.broker. { com.ibm.broker.config.proxy.LocalCMPSender.send()
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.LocalCMPSender.send()
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.SendManager.send()
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.AdministeredObjectPool.sendHeartbeatResponse()
2016-06-15 13:58:39.0371 com.ibm.broker. { com.ibm.broker.config.proxy.AdministeredObjectPool.getLogEntriesFromStringTokenizer()
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.AdministeredObjectPool.getLogEntriesFromStringTokenizer() retVal=[]
2016-06-15 13:58:39.0371 com.ibm.broker. { com.ibm.broker.config.proxy.AdministeredObjectPool.findObjectFromResponseElement()
2016-06-15 13:58:39.0371 com.ibm.broker. d[3]: affectedConfigObjectType=<unknown>,affectedUUID=null,affectedObjectsParentUUID=null
2016-06-15 13:58:39.0371 com.ibm.broker. d[3]: referenceParentUUID=null,referenceParentType=null
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.AdministeredObjectPool.findObjectFromResponseElement() retVal=null
2016-06-15 13:58:39.0371 com.ibm.broker. d[3]: The actionresponse does not refer to an instantiable object.
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.AdministeredObjectPool.processResponse()
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.ReceiveManager.action()
2016-06-15 13:58:39.0371 com.ibm.broker. } com.ibm.broker.config.proxy.LocalCMPReceiver.deliverMessage()
2016-06-15 13:58:39.0825 main........... d[2]: AdministeredObjectPool deregistered a thread that is no longer waiting for a 'actionresponse': main
2016-06-15 13:58:39.0825 main........... d[2]: AdministeredObjectPool registered a waiting for 'actionresponse' thread: main
The last 2 lines repeat many times.
Does anyone have any insight on this?
I resolved this issue on Windows 64-bit,
Fixed by applying the IBM Integration Bus 10 fix pack 5 released on Fix Central 2016-05-27. I was able to create the integration server and deply a bar file no problem.
Please note that I also tested the Fix Pack 5 on Linux X86_64, and the issue does not seem to be resolved on Redhat RHEL 7.2 64-it.
Hope this helps someone else.
Related
I have a SpringBoot application that uses a Hikari jdbc connection pool to access a file based H2 database.
application.yml
spring:
datasource:
hikari:
driver-class-name: org.h2.Driver
jdbc-url: jdbc:h2:${media.db.file};DB_CLOSE_ON_EXIT=FALSE
username:
password:
maximum-pool-size: 5
connection-test-query: "SELECT 1"
pool-name: media-pool
Now, I have a requirement that after application shutdown I need to create a local backup of the h2 database file.
Obviously, this will only work after the db connection has been closed and since I have various beans that inject a DataSource, I assume that the db connection will only be closed after those beans have been destroyed (and obviously the class creating the copy cannot be a spring bean).
So my issue is how to detect when all beans have been destroyed and the application context has been destroyed.
Obviously annotation a method with #PreDestroy will not work as such methods are called before beans are destroyed.
I have found various ways to register for application life cycle events, however, if I call BackupUtility.backupDatabase() from any of them I always get the same exception:
java.io.IOException: The process cannot access the file because another process has locked a portion of the file
at java.base/java.io.FileInputStream.readBytes(Native Method)
at java.base/java.io.FileInputStream.read(FileInputStream.java:257)
at ch.bee.mediathek.business.utility.BackupUtility.backupDatabase(BackupUtility.java:63)
I assume that this means that the db connection has not yet been closed and I therefore tried to create the backup too early.
I have tried the following ways to be notified of my application shutdown:
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(MediaSpringApplication.class, args);
context.registerShutdownHook();
log.info("Application started...");
context.addApplicationListener(MediaSpringApplication::onApplicationEvent);
}
private static void onApplicationEvent(final ApplicationEvent event) {
if (event instanceof ContextClosedEvent) {
log.info("===== ContextClosed (1) =====");
BackupUtility.backupDatabase();
}
}
#Bean
ServletListenerRegistrationBean<ServletContextListener> myServletListener() {
ServletListenerRegistrationBean<ServletContextListener> srb = new ServletListenerRegistrationBean<>();
srb.setListener(new MyServletContextListener());
return srb;
}
public class MyServletContextListener implements ServletContextListener {
#Override
public void contextInitialized(ServletContextEvent sce) {
}
#Override
public void contextDestroyed(ServletContextEvent sce) {
log.info("===== ContextDestroyed (2) =====");
BackupUtility.backupDatabase();
}
}
#EventListener({ContextClosedEvent.class})
public void contextClosed() {
log.info("===== ContextClosed (3) =====");
BackupUtility.backupDatabase();
}
Looking at the log output I see the following:
[2021-01-06 19:38:12.023] [Thread-8] [INFO ] c.b.m.a.MediaSpringApplication::contextClosed(144) - ===== ContextClosed (3) =====
[2021-01-06 19:38:12.030] [Thread-8] [ERROR] c.b.m.b.u.BackupUtility::backupDatabase(67) - Error while copying file contents
java.io.IOException: Der Prozess kann nicht auf die Datei zugreifen, da ein anderer Prozess einen Teil der Datei gesperrt hat
at java.base/java.io.FileInputStream.readBytes(Native Method)
at java.base/java.io.FileInputStream.read(FileInputStream.java:257)
at ch.bee.mediathek.business.utility.BackupUtility.backupDatabase(BackupUtility.java:63)
at ch.bee.mediathek.app.MediaSpringApplication.contextClosed(MediaSpringApplication.java:145)
[2021-01-06 19:38:12.030] [Thread-8] [INFO ] c.b.m.a.MediaSpringApplication::onApplicationEvent(56) - ===== ContextClosed (1) =====
[2021-01-06 19:38:12.031] [Thread-8] [ERROR] c.b.m.b.u.BackupUtility::backupDatabase(67) - Error while copying file contents
java.io.IOException: Der Prozess kann nicht auf die Datei zugreifen, da ein anderer Prozess einen Teil der Datei gesperrt hat
at java.base/java.io.FileInputStream.readBytes(Native Method)
at java.base/java.io.FileInputStream.read(FileInputStream.java:257)
at ch.bee.mediathek.business.utility.BackupUtility.backupDatabase(BackupUtility.java:63)
at ch.bee.mediathek.app.MediaSpringApplication.onApplicationEvent(MediaSpringApplication.java:57)
[2021-01-06 19:38:12.138] [Thread-8] [INFO ] c.b.m.a.MediaSpringApplication::contextDestroyed(137) - ===== ContextDestroyed (2) =====
[2021-01-06 19:38:12.140] [Thread-8] [ERROR] c.b.m.b.u.BackupUtility::backupDatabase(67) - Error while copying file contents
java.io.IOException: Der Prozess kann nicht auf die Datei zugreifen, da ein anderer Prozess einen Teil der Datei gesperrt hat
at java.base/java.io.FileInputStream.readBytes(Native Method)
at java.base/java.io.FileInputStream.read(FileInputStream.java:257)
at ch.bee.mediathek.business.utility.BackupUtility.backupDatabase(BackupUtility.java:63)
at ch.bee.mediathek.app.MediaSpringApplication$MyServletContextListener.contextDestroyed(MediaSpringApplication.java:138)
[2021-01-06 19:38:12.393] [Thread-8] [WARN ] o.s.b.f.s.DisposableBeanAdapter::destroy(267) - Invocation of destroy method failed on bean with name 'inMemoryDatabaseShutdownExecutor': org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200]
[2021-01-06 19:38:12.395] [Thread-8] [INFO ] c.z.h.HikariDataSource::close(350) - media-pool - Shutdown initiated...
[2021-01-06 19:38:12.398] [Thread-8] [INFO ] c.z.h.HikariDataSource::close(352) - media-pool - Shutdown completed.
Looking at the last four lines of my logs, I see that when I try to backup the database file after the last of my callbacks (the one triggered by the ServletContextListener), the file is apparently still open. However, on the next line I see that the DisposableBeanAdapter tries to do something which fails because the database has already been closed. The next two lines show that the HikariDataSource class only shuts down even later.
So, it seems I need to find a way to start my Backup after the HikariDataSource has shutdown the media pool. I would have expected that this would happen when those beans are destroyed and that my context destruction callback would only be called after that has happened, but it does not seem to work that way.
I have tried to remove the DB_CLOSE_ON_EXIT=FALSE from spring.datasource.hikari.jdbc-url in my application.yml file but that still fails to creat the backup but in addition also adds the following exception at the end of shutting down multiple times (probably once per data pool member):
[2021-01-06 20:04:30.466] [Thread-9] [WARN ] c.z.h.p.PoolBase::isConnectionAlive(184) - media-pool - Failed to validate connection conn1: url=jdbc:h2:/workspaces/media-spring/database/Media-local user= (Database is already closed (to disable automatic closing at VM shutdown, add ";DB_CLOSE_ON_EXIT=FALSE" to the db URL) [90121-200]). Possibly consider using a shorter maxLifetime value.
Am I doing something wrong? Or is there another way to be notified even later that I haven't found yet?
We are getting the below mentioned error on websphere 8.5
2020-01-07 15:19:37 [] DEBUG InvocableHandlerMethod.java.getMethodArgumentValues:174:
Could not resolve parameter [1] in public org.springframework.http.ResponseEntity
com.mycorp.uap.controller.WorkFlowController.updateTask(int,com.mycorp.uap.rest.vo.TaskVO)
throws java.lang.Exception: HV000041: Call to TraversableResolver.isReachable() threw an exception.
Method is defined as
public ResponseEntity<TaskVO> updateTask(#PathVariable("id") int taskId, #Valid #RequestBody(required=true) TaskVO task) throws Exception{
WEB-INF/lib contains the below jars related to hibernate, validation and spring
hibernate-commons-annotations-5.1.0.Final.jar
hibernate-core-5.4.4.Final.jar
hibernate-ehcache-5.4.4.Final.jar
hibernate-jpa-2.1-api-1.0.2.jar
hibernate-validator-6.0.15.Final.jar
validation-api-2.0.1.Final.jar
spring-aop-5.1.9.RELEASE.jar
spring-beans-5.1.9.RELEASE.jar
spring-context-5.1.9.RELEASE.jar
spring-context-support-5.1.9.RELEASE.jar
spring-core-5.1.9.RELEASE.jar
spring-data-commons-2.1.9.RELEASE.jar
spring-data-jpa-2.1.9.RELEASE.jar
spring-expression-5.1.9.RELEASE.jar
springfox-core-2.1.2.jar
springfox-schema-2.1.2.jar
springfox-spi-2.1.2.jar
springfox-spring-web-2.1.2.jar
springfox-swagger2-2.1.2.jar
springfox-swagger-common-2.1.2.jar
springfox-swagger-ui-2.1.2.jar
spring-hateoas-0.17.0.RELEASE.jar
spring-jcl-5.1.9.RELEASE.jar
spring-jdbc-5.1.9.RELEASE.jar
spring-ldap-core-2.3.2.RELEASE.jar
spring-messaging-5.1.9.RELEASE.jar
spring-orm-5.1.9.RELEASE.jar
spring-plugin-core-1.2.0.RELEASE.jar
spring-plugin-metadata-1.2.0.RELEASE.jar
spring-security-acl-5.1.6.RELEASE.jar
spring-security-cas-client.jar
spring-security-config-5.1.6.RELEASE.jar
spring-security-core-5.1.6.RELEASE.jar
spring-security-ldap-5.1.6.RELEASE.jar
spring-security-oauth2-2.3.6.RELEASE.jar
spring-security-openid-5.1.6.RELEASE.jar
spring-security-taglibs-5.1.6.RELEASE.jar
spring-security-web-5.1.6.RELEASE.jar
spring-test-5.1.9.RELEASE.jar
spring-tx-5.1.9.RELEASE.jar
spring-web-5.1.9.RELEASE.jar
spring-webmvc-5.1.9.RELEASE.jar
spring-websocket-5.1.9.RELEASE.jar
ParentLast setting is present in WebSphere configuration for our application so that WebSphere should give preference to the jars present in the WEB-INF/lib of our application
There is a similar method where #Valid is not present which works properly.
I looked into similar question on the stack overflow however could not quite get the correct solution.
What should be the correct solution?
Should we remove any jars from our WEB-INF/lib?
To fix this problem, you need to add the HibernatePersistenceProviderResolver class to your project:
HibernatePersistenceProviderResolver.java
and register it in the Application class in the onStartup method
#Override
public void onStartup(ServletContext servletContext) throws ServletException {
HibernatePersistenceProviderResolver.register();
...
}
Reference
I am working with Spring Websocket and with ActiveMQ.
For the latter exits two servers, local and remote.
When the local server is enabled (remote is offline) the following works fine:
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableStompBrokerRelay("/topic", "/queue");
config.setApplicationDestinationPrefixes("/app");
config.setUserDestinationPrefix("/user");
}
When only the remote server is enabled (local is offline) the code shown above fails with the following:
[main] INFO o.s.m.s.s.StompBrokerRelayMessageHandler - Starting...
[main] INFO o.s.m.s.s.StompBrokerRelayMessageHandler - Connecting "system" session to 127.0.0.1:61613
...
[tcp-client-loop-nio-4] ERROR o.s.m.s.s.StompBrokerRelayMessageHandler - TCP connection failure in session _system_:
Failed to connect: Connection refused: /127.0.0.1:61613
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: /127.0.0.1:61613
The solution is:
#Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableStompBrokerRelay("/topic","/queue").setRelayHost("192.168.1.88")
.setRelayPort(61613);
config.setApplicationDestinationPrefixes("/app");
config.setUserDestinationPrefix("/user");
}
My question is:
How in runtime is possible update the MessageBrokerRegistry object through the setRelayHost and setRelayPort methods and reflect these changes?. But It through the available #Configuration methods in the Spring Framework API.
Note: if one server is down and other remote server are available, I already have the new the values for the host and port.
resteasy 3.1.3.Final and springboot 1.5.7
I want do somthing before the request go ino the restful method,but it never worked.
here is the restful method interface.
#Path("/demo")
#Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
#Produces({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
public interface DemoService {
#POST
#Path("/query")
List<EntityDemoInfo> queryByType(QueryRequest requst);
}
Here is the filter.
#Provider
#PreMatching
public class RequestFilter implements HttpRequestPreprocessor,ContainerRequestFilter{
#Override
public void filter(ContainerRequestContext requestContext) throws IOException {
System.out.println("-----------------");
}
#Override
public void preProcess(HttpRequest request) {
System.out.println("================");
}
}
It never go in the filter and print the log,even if i tried the annotations #Provider/#PreMatching/#Configuration in any combination.
Later i think maybe something registry problem,and tried to add #Bean in #SpringBootApplication class.This can print what I register,however when debugging request the registry/factory din't have my RequestFilter, thus it didn't work. What's wrong with it? thanks !
#Bean
public SynchronousDispatcher synchronousDispatcher() {
ResteasyProviderFactory providerFactory = ResteasyProviderFactory.getInstance();
RequestFilter requestFilter = new RequestFilter();
providerFactory.getContainerRequestFilterRegistry().registerSingleton(requestFilter);
SynchronousDispatcher dispatcher = new SynchronousDispatcher(providerFactory);
dispatcher.addHttpPreprocessor(requestFilter);
System.out.println("*****************");
System.out.println(providerFactory.getContainerRequestFilterRegistry().preMatch());
return dispatcher;
}
As 'paypal' codes do in https://github.com/paypal/resteasy-spring-boot , I added RequestFilter like Hantsy mentioned below, it didn't work!
Here is the log.
14:44:01.537 [main] INFO org.apache.tomcat.util.net.NioSelectorPool Using a shared selector for servlet write/read
14:44:01.548 [main] INFO org.jboss.resteasy.resteasy_jaxrs.i18n RESTEASY002225: Deploying javax.ws.rs.core.Application: class com.sample.app.JaxrsApplication
#################
################# ------This is what I add in JaxrsApplication
14:44:01.548 [main] INFO org.jboss.resteasy.resteasy_jaxrs.i18n RESTEASY002215: Adding singleton provider java.lang.Class from Application class com.sample.app.JaxrsApplication
14:44:01.554 [main] INFO org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer Tomcat started on port(s): 8080 (http)
14:44:01.559 [main] INFO com.sample.app.Application Started Application in 2.478 seconds (JVM running for 2.978)
//There is when i post a request as it say what happened,nothing,but got the response.Thus it didn't work!
14:45:58.657 [RMI TCP Connection(2)-127.0.0.1] INFO org.springframework.boot.admin.SpringApplicationAdminMXBeanRegistrar$SpringApplicationAdmin Application shutdown requested.
14:45:58.657 [RMI TCP Connection(2)-127.0.0.1] INFO org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext#34f22f9d: startup date [Fri Oct 20 14:43:59 CST 2017]; root of context hierarchy
14:45:58.659 [RMI TCP Connection(2)-127.0.0.1] INFO org.springframework.context.support.DefaultLifecycleProcessor Stopping beans in phase 0
14:45:58.660 [RMI TCP Connection(2)-127.0.0.1] INFO org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter Unregistering JMX-exposed beans on shutdown
14:45:58.660 [RMI TCP Connection(2)-127.0.0.1] INFO org.springframework.boot.actuate.endpoint.jmx.EndpointMBeanExporter Unregistering JMX-exposed beans
14:45:58.660 [RMI TCP Connection(2)-127.0.0.1] INFO org.springframework.jmx.export.annotation.AnnotationMBeanExporter Unregistering JMX-exposed beans on shutdown
The resteasy documentation provides simple guide for intgrating resteasy with Spring and Spring Boot. Hope these links are helpful.
Resteasy and Spring Integration
Spring Boot starter, described in the 43.4. Spring Boot starter section of the Resteasy doc.
If you are using Spring Boot as described in the doc, just register you custom Filter in your Application class.
#Component
#ApplicationPath("/sample-app/")
public class JaxrsApplication extends Application {
#Override
public Set<Object> getSingletons() {
Set<Object> singletons = new HashSet<>();
singletons.add(yourFilter);
return singletons;
}
}
Updated: I forked the paypal/resteasy-spring-boot, and modified the sample-app, added a EchoFitler for demo purpose.
Check the source codes from my Github account.
Run the sample-app via mvn spring-boot:run.
Use curl to test the apis.
# curl -v -X POST -H "Content-Type:text/plain" -H "Accept:application/json" http://localhost:8080/sample-app/echo -d "test"
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> POST /sample-app/echo HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.56.0
> Content-Type:text/plain
> Accept:application/json
> Content-Length: 4
>
* upload completely sent off: 4 out of 4 bytes
< HTTP/1.1 200
< X-Application-Context: application
< Content-Type: application/json
< Content-Length: 45
< Date: Fri, 20 Oct 2017 07:19:43 GMT
<
{"timestamp":1508483983603,"echoText":"test"}* Connection #0 to host localhost left intact
And you will see the filtering info in the spring-boot console.
filtering request context:org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext#1ca8d1e4
filtering request/response context:org.jboss.resteasy.core.interception.jaxrs.ResponseContainerRequestContext#1787a18c
org.jboss.resteasy.core.interception.jaxrs.ContainerResponseContextImpl#4aad828e
Hope this is helpful.
Assume I have a SpringBoot Application deployed as a WAR to Websphere Application Server (WAS). This WAR contains a daemon, so it must start straight away when WAS starts (and only once).
However, I still need to activate the SpringBoot Servlet by doing a http request.
Now I understand that the concept of servlets is to act on http requests, I still want to get it auto started on appserver start. This makes my daemon portable from standalone jar/main to war/webapp.
I tried a ServletContextListener, but the contextInitalized also get only called at the first http request.
I do not have a web.xml (servlet 3).
Code:
#SpringBootApplication
#WebListener
public class DemoApplication extends SpringBootServletInitializer implements ServletContextListener {
#Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.err.println("ONSTARTUP");
super.onStartup(servletContext);
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication.class);
}
#Override
public void contextInitialized(ServletContextEvent sce) {
System.err.println("contextInitialized");
}
#Override
public void contextDestroyed(ServletContextEvent arg0) {
//
}
}
and:
#Component
public class DemoRunner implements ApplicationRunner {
#Override
public void run(ApplicationArguments arg0) throws Exception {
System.err.println("I AM RUNNING");
}
}
When I start WAS I first get this:
Launching defaultServer (WebSphere Application Server
16.0.0.2/wlp-1.0.13.cl160220160526-2258) on Java HotSpot(TM) 64-Bit Server VM, version 1.7.0_79-b15 (en_US)
[...]
[AUDIT ] CWWKT0016I: Web application available (default_host): http://localhost:9080/demo/
[AUDIT ] CWWKZ0001I: Application test started in 17,282 seconds.
To get my Spring Boot application starting, I first need to visit this link (http:/localhost:9080/demo/). Then it starts rolling, starting with the startup method as you can see in the log. But how can I get this starting without doing a http request?
[err] ONSTARTUP
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.4.0.RELEASE)
2016-09-02 10:45:52.670 INFO 23716 --- [dPool-thread-48] com.example.DemoApplication : Starting DemoApplication on [...]
2016-09-02 10:45:58.019 INFO 23716 --- [dPool-thread-48] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
[...]
[err] I AM RUNNING
[...]
2016-09-02 10:45:58.093 INFO 23716 --- [dPool-thread-48] com.example.DemoApplication : Started DemoApplication in 6.372 seconds (JVM running for 31.549)
[...]
[err] contextInitialized
[err] contextInitialized
You can change the loadOnStartup by customize the spring dispatch servlet, here is the sample question and you can use the code
#Bean
public static BeanFactoryPostProcessor beanFactoryPostProcessor() {
return new BeanFactoryPostProcessor() {
#Override
public void postProcessBeanFactory(
ConfigurableListableBeanFactory beanFactory) throws BeansException {
BeanDefinition bean = beanFactory.getBeanDefinition(
DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
bean.getPropertyValues().add("loadOnStartup", 1);
}
};
}
Reference:
how to configure 'dispatcherServlet' load on startup by spring boot?
Upate
Seems there is a more simple way, you can config it in application.properites
spring.mvc.servlet.load-on-startup=1