Spring Application-应用程序服务器拒绝了连接。 (未设置密码。)

时间:2019-01-23 13:49:15

标签: java spring-boot tomcat db2 spring-jdbc

我在2个其余api中使用Spring boot,它们在Tomcat服务器下运行,而Tomcat服务器在IBM I上的JVM中运行。现在的问题是,总是剩下的第二个api不会从JVM获取任何用户信息。 / p>

似乎第一个正在运行的API阻止了来自JVM的用户信息,因此第二个Api却没有从JVM中获取用户信息。

有人知道这个问题吗?有人知道我在做什么错吗?

依赖项:

  • spring-boot-starter-web,1.5.2
  • spring-boot-starter-jdbc,1.5.2
  • spring-boot-configuration-processor。 1.5.2
  • net.sf.jt400,9.1

application.yml

spring:
  profiles: default
  datasource:
    driver-class-name: com.ibm.as400.access.AS400JDBCDriver
    url: jdbc:as400://localhost:446;libraries=TESTLIB

启动类

package com.restApi2.rest;

import com.ibm.as400.access.*;
import org.apache.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Paths;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@SpringBootApplication
@EnableConfigurationProperties
@EnableScheduling
public class StartUp extends SpringBootServletInitializer {

    private final static Logger log = Logger.getLogger(StartUp.class);

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        initLogger();

        return application.sources(StartUp.class);
    }

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

    @Bean
    public ThreadPoolTaskExecutor taskExecutor() {
        ThreadPoolTaskExecutor pool = new ThreadPoolTaskExecutor();
        pool.setCorePoolSize(5);
        pool.setMaxPoolSize(10);
        pool.setWaitForTasksToCompleteOnShutdown(true);
        return pool;
    }
}

Tomcat服务器的日志记录:

    [2019-01-23 13:57:55.676] [    12979 ms] [restApi1] [main] [INFO ] o.s.j.e.a.AnnotationMBeanExporter - Registering beans for JMX exposure on startup
[2019-01-23 13:57:55.700] [    13003 ms] [restApi1] [main] [INFO ] o.s.c.s.DefaultLifecycleProcessor - Starting beans in phase 2147483647
[2019-01-23 13:57:55.700] [    13003 ms] [restApi1] [main] [INFO ] s.d.s.w.p.DocumentationPluginsBootstrapper - Context refreshed
[2019-01-23 13:57:55.746] [    13049 ms] [restApi1] [main] [INFO ] s.d.s.w.p.DocumentationPluginsBootstrapper - Found 1 custom documentation plugin(s)
[2019-01-23 13:57:55.815] [    13118 ms] [restApi1] [main] [INFO ] s.d.s.w.s.ApiListingReferenceScanner - Scanning for api listing references
[2019-01-23 13:57:56.258] [    13561 ms] [restApi1] [main] [INFO ] com.restApi1.rest.StartUp - Started StartUp in 12.748 seconds (JVM running for 26.373)
[2019-01-23 13:58:07.204] [     1797 ms] [main] [restApi2] [ERROR] o.s.boot.SpringApplication - Application startup failed
java.lang.RuntimeException: Error fetching properties from db
    at com.restApi2.rest.config.DBPropertiesPostProcessor.postProcessEnvironment(DBPropertiesPostProcessor.java:76)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEnvironmentPreparedEvent(ConfigFileApplicationListener.java:171)
    at org.springframework.boot.context.config.ConfigFileApplicationListener.onApplicationEvent(ConfigFileApplicationListener.java:157)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:167)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:122)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:73)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:336)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
    at org.springframework.boot.web.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:151)
    at org.springframework.boot.web.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:131)
    at org.springframework.boot.web.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:86)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:169)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5186)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:522)
    at java.util.concurrent.FutureTask.run(FutureTask.java:277)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:738)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:407)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1551)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:284)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:976)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:872)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1439)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1429)
    at java.util.concurrent.FutureTask.run(FutureTask.java:277)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:953)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:793)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:656)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:90)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:508)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:355)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:495)
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The application server rejected the connection. (Password is not set.)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
    at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:394)
    at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:474)
    at org.springframework.jdbc.core.JdbcTemplate.queryForRowSet(JdbcTemplate.java:515)
    at com.menten.ieffect.rest.config.DBPropertiesPostProcessor.postProcessEnvironment(DBPropertiesPostProcessor.java:46)
    ... 53 common frames omitted
Caused by: java.sql.SQLException: The application server rejected the connection. (Password is not set.)
    at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:824)
    at com.ibm.as400.access.JDError.throwSQLException(JDError.java:553)
    at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3387)
    at com.ibm.as400.access.AS400JDBCDriver.prepareConnection(AS400JDBCDriver.java:1419)
    at com.ibm.as400.access.AS400JDBCDriver.initializeConnection(AS400JDBCDriver.java:1256)
    at com.ibm.as400.access.AS400JDBCDriver.connect(AS400JDBCDriver.java:395)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:310)
    at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:732)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:664)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:479)
    at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:154)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:118)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:107)
    at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:131)
    at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
    at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
    ... 57 common frames omitted
Caused by: com.ibm.as400.access.AS400SecurityException: Password is not set.
    at com.ibm.as400.access.AS400.sendSignonRequest(AS400.java:3292)
    at com.ibm.as400.access.AS400.promptSignon(AS400.java:2901)
    at com.ibm.as400.access.AS400.signon(AS400.java:4209)
    at com.ibm.as400.access.AS400.connectService(AS400.java:1336)
    at com.ibm.as400.access.AS400JDBCConnection.setProperties(AS400JDBCConnection.java:3383)
    ... 71 common frames omitted

0 个答案:

没有答案