I am running my jar file on linux server with java -Dspring.profiles.active=dev -jar vantage.jar and getting following error.
DEBUG 65057 --- [main] com.company.vantage.VantageApp : Running with Spring Boot v2.2.4.RELEASE, Spring v5.2.3.RELEASE
INFO 65057 --- [main] com.company.vantage.VantageApp : The following profiles are active: dev,swagger
DEBUG 65057 --- [main] i.m.c.u.i.logging.InternalLoggerFactory : Using SLF4J as the default logging framework
DEBUG 65057 --- [main] c.a.vantage.security.jwt.TokenProvider : Using a Base64-encoded JWT secret key
DEBUG 65057 --- [main] com.company.vantage.config.WebConfigurer : Registering CORS filter
INFO 65057 --- [main] com.company.vantage.config.WebConfigurer : Web application configuration, using profiles: dev
DEBUG 65057 --- [main] com.company.vantage.config.WebConfigurer : Initialize H2 console
INFO 65057 --- [main] com.company.vantage.config.WebConfigurer : Web application fully configured
DEBUG 65057 --- [main] c.a.vantage.config.AsyncConfiguration : Creating Async Task Executor
DEBUG 65057 --- [main] c.a.v.config.LiquibaseConfiguration : Configuring Liquibase
ERROR 65057 --- [main] com.zaxxer.hikari.pool.HikariPool : Hikari - Exception during pool initialization.
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:292)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:211)
at org.postgresql.Driver.makeConnection(Driver.java:458)
at org.postgresql.Driver.connect(Driver.java:260)
at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138)
at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354)
at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202)
at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473)
at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554)
at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115)
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:112)
at io.github.jhipster.config.liquibase.AsyncSpringLiquibase.afterPropertiesSet(AsyncSpringLiquibase.java:89)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1855)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1792)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:310)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1108)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:868)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at com.anthem.vantage.VantageApp.main(VantageApp.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:607)
at org.postgresql.core.PGStream.<init>(PGStream.java:75)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:91)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
... 38 common frames omitted
Same jar file works fine in my localhost and windows server (temp dev env). But when I run the same jar on linux box (using putty for this) and throwing above error. App is deployed and I can open the front page. But couldn't get in, as, it is not connecting DB and not LDAP server while i was trying to login using ldap authentication. So I tried ping both postgresql server and also ldap server and I got response successfully. But cannot connect through app. Please advise!
Please note this is linux server is newly mounted and not sure if there is any thing that needs to be configured other than javaidk.
my application-dev.yml looks like below for data source
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql://hostname:15432/vantage
username: XXXXXXXXXX
password: pwd!
hikari:
poolName: Hikari
auto-commit: false
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
database: postgresql
show-sql: true
properties:
hibernate.id.new_generator_mappings: true
hibernate.connection.provider_disables_autocommit: true
hibernate.cache.use_second_level_cache: false
hibernate.cache.use_query_cache: false
hibernate.generate_statistics: false
hibernate.default_schema: filemetadata
hibernate.search.default.directory_provider: filesystem
hibernate.search.default.indexBase: ./lucene/indexes
liquibase:
# Remove 'faker' if you do not want the sample data to be loaded automatically
contexts: dev
default-schema: filemetadata
Related
I am new to the ZAP and trying to pen test XML(SOAP) services. I already have Java based regression tests for the SOAP and trying to proxy them through ZAP, but unable to do so.
I am looking for some guidance as how to successfully use my regression tests to perform security testing on SOAP services using ZAP?
Details:
I add following parameters to Java in my regression tests so that they may successfully connect to SOAP services:
System.setProperty("javax.net.ssl.trustStore", "C:/standalone/configuration/app.keystore"); // certificate
System.setProperty("javax.net.ssl.trustStorePassword", "somepassword"); // password
ZAP is starting up with following command-line and able to intercept other browser calls proxying through localhost:8888:
zap.bat -host localhost -port 8888 -config api.addrs.addr.regex=true -config api.key=12345 -config connection.timeoutInSecs=60
But when I try to run regression tests with following proxy settings, they completely ignore ZAP as proxy and run just fine with or without ZAP server running:
System.setProperty("http.proxyHost", "localhost");
System.setProperty("http.proxyPort", "8888");
System.setProperty("https.proxyHost", "localhost");
System.setProperty("https.proxyPort", "8888");
Then I added SOCKs proxy settings in regression tests:
System.setProperty("socksProxyHost", "localhost");
System.setProperty("socksProxyPort", "8888");
Now, I get following error in tests:
16:52:00.623 [main] ERROR com.dummy.client.ServiceClient - java.net.SocketException: Can't connect to SOCKS proxy:Connection refused: connect
java.net.SocketException: Can't connect to SOCKS proxy:Connection refused: connect
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:428) ~[?:1.8.0_211]
at java.net.Socket.connect(Socket.java:589) ~[?:1.8.0_211]
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.5.jar:4.5.5]
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) ~[httpclient-4.5.5.jar:4.5.5]
at com.dummy.client.AppHttpClient.request(AppHttpClient.java:83) ~[appc3-ws-client-12.00.01.jar:?]
at com.dummy.stub.ServiceStub.authorization(ServiceStub.java:89) ~[appc3-ws-client-12.00.01.jar:?]
at com.dummy.client.ServiceClient.doAuthorization(ServiceClient.java:367) ~[appc3-ws-client-12.00.01.jar:?]
at com.dummy.client.ServiceClient.doAuthorization(ServiceClient.java:397) ~[appc3-ws-client-12.00.01.jar:?]
at com.dummy.ca.reusable.WebService.authorization(WebService.java:65) ~[main/:?]
at com.dummy.ca.reusable.WebService.Change(WebService.java:657) ~[main/:?]
at com.dummy.ca.StepsLibrary.T3_Poster.changeDevice(T3_Poster.java:238) ~[main/:?]
at com.dummy.ca.stepDefinations.PosterUpdatePD.change(PosterUpdatePD.java:219) ~[main/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_211]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_211]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_211]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_211]
at io.cucumber.java.Invoker.doInvoke(Invoker.java:66) ~[cucumber-java-6.1.2.jar:6.1.2]
at io.cucumber.java.Invoker.invoke(Invoker.java:24) ~[cucumber-java-6.1.2.jar:6.1.2]
at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:44) ~[cucumber-java-6.1.2.jar:6.1.2]
at io.cucumber.java.JavaHookDefinition.execute(JavaHookDefinition.java:59) ~[cucumber-java-6.1.2.jar:6.1.2]
at io.cucumber.core.runner.CoreHookDefinition.execute(CoreHookDefinition.java:44) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:21) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runner.TestStep.run(TestStep.java:63) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runner.TestCase.run(TestCase.java:102) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runner.Runner.runPickle(Runner.java:71) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runtime.Runtime.lambda$execute$5(Runtime.java:110) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:131) ~[cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.runtime.Runtime.lambda$execute$6(Runtime.java:110) ~[cucumber-core-6.1.2.jar:6.1.2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_211]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_211]
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:233) ~[cucumber-core-6.1.2.jar:6.1.2]
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112) ~[?:1.8.0_211]
at io.cucumber.core.runtime.Runtime.lambda$run$2(Runtime.java:86) ~[cucumber-core-6.1.2.jar:6.1.2]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) [?:1.8.0_211]
at java.util.stream.SliceOps$1$1.accept(SliceOps.java:204) [?:1.8.0_211]
at java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1359) [?:1.8.0_211]
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126) [?:1.8.0_211]
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498) [?:1.8.0_211]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) [?:1.8.0_211]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) [?:1.8.0_211]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) [?:1.8.0_211]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) [?:1.8.0_211]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) [?:1.8.0_211]
at io.cucumber.core.runtime.Runtime.run(Runtime.java:87) [cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.cli.Main.run(Main.java:78) [cucumber-core-6.1.2.jar:6.1.2]
at io.cucumber.core.cli.Main.main(Main.java:33) [cucumber-core-6.1.2.jar:6.1.2]
And ZAP command-line shows below Socket timeout warning, whenever I fire regression:
6862 [ZAP-BootstrapGUI] INFO org.parosproxy.paros.extension.ExtensionLoader - Initializing Tips and Tricks
6868 [ZAP-BootstrapGUI] INFO org.parosproxy.paros.extension.ExtensionLoader - Initializing Allows to fuzz WebSocket messages.
7259 [ZAP-BootstrapGUI] INFO org.zaproxy.zap.extension.callback.ExtensionCallback - Started callback server on 0.0.0.0:61252
7260 [ZAP-BootstrapGUI] INFO org.zaproxy.zap.extension.keyboard.ExtensionKeyboard - Initializing keyboard shortcuts
9203 [AWT-EventQueue-0] INFO org.parosproxy.paros.control.Control - New Session
9212 [AWT-EventQueue-0] INFO org.parosproxy.paros.control.Control - Create and Open Untitled Db
9219 [AWT-EventQueue-0] INFO hsqldb.db.HSQLDB379AF3DEBD.ENGINE - dataFileCache commit start
9221 [AWT-EventQueue-0] INFO hsqldb.db.HSQLDB379AF3DEBD.ENGINE - dataFileCache commit end
9231 [AWT-EventQueue-0] INFO hsqldb.db.HSQLDB379AF3DEBD.ENGINE - Database closed
9398 [AWT-EventQueue-0] INFO hsqldb.db.HSQLDB379AF3DEBD.ENGINE - dataFileCache open start
9402 [AWT-EventQueue-0] INFO hsqldb.db.HSQLDB379AF3DEBD.ENGINE - dataFileCache commit start
9407 [AWT-EventQueue-0] INFO hsqldb.db.HSQLDB379AF3DEBD.ENGINE - dataFileCache commit end
9408 [AWT-EventQueue-0] INFO hsqldb.db.HSQLDB379AF3DEBD.ENGINE - dataFileCache open end
40538 [ZAP-ProxyThread-1] WARN org.parosproxy.paros.core.proxy.ProxyThread - Socket timeout while reading first message.
50575 [ZAP-ProxyThread-2] WARN org.parosproxy.paros.core.proxy.ProxyThread - Socket timeout while reading first message.
60604 [ZAP-ProxyThread-3] WARN org.parosproxy.paros.core.proxy.ProxyThread - Socket timeout while reading first message.
70630 [ZAP-ProxyThread-4] WARN org.parosproxy.paros.core.proxy.ProxyThread - Socket timeout while reading first message.
80679 [ZAP-ProxyThread-5] WARN org.parosproxy.paros.core.proxy.ProxyThread - Socket timeout while reading first message.
I am trying to boot up a spring application with Atomikos maven dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
</dependency>
Am also autowiring as following
#Autowired
JtaTransactionManager jtaTransactionManager;
application.yaml file is as follows
spring:
mvc:
throw-exception-if-no-handler-found: true
resources:
add-mappings: false
jta:
atomikos:
connectionfactory:
ignore-session-transacted-flag: false
unique-resource-name: xa.amq
min-pool-size: 10
max-pool-size: 20
datasource:
unique-resource-name: xa.db
min-pool-size: 10
max-pool-size: 20
test-query: "select 1"
properties:
default-jta-timeout: 50000
datasource:
url: jdbc:mysql://mydatabasehost:3306/test
driverClassName: com.mysql.jdbc.Driver
username: test
password: test
initialization-mode: always
It starts fine with above yaml configurations.
However, for my use case, I want my transaction manager to skip using the default spring datasource and instead I want to dynamically register datasource beans after the start up. I wanted to know if that is possible. If I remove my datasource settings from above yaml file, I get following error
15:15:19.322 [main] WARN com.atomikos.jdbc.AtomikosXAConnectionFactory - XAConnectionFactory: failed to create pooled connection - DBMS down or unreachable?
java.sql.SQLException: Database not available
at org.apache.derby.jdbc.BasicEmbeddedDataSource40.setupResourceAdapter(Unknown Source)
at org.apache.derby.jdbc.EmbeddedXADataSource.getXAConnection(Unknown Source)
at com.atomikos.jdbc.AtomikosXAConnectionFactory.createPooledConnection(AtomikosXAConnectionFactory.java:28)
at com.atomikos.datasource.pool.ConnectionPool.createPooledConnection(ConnectionPool.java:98)
at com.atomikos.datasource.pool.ConnectionPool.addConnectionsIfMinPoolSizeNotReached(ConnectionPool.java:86)
at com.atomikos.datasource.pool.ConnectionPool.init(ConnectionPool.java:60)
at com.atomikos.datasource.pool.ConnectionPool.<init>(ConnectionPool.java:49)
at com.atomikos.datasource.pool.ConnectionPoolWithConcurrentValidation.<init>(ConnectionPoolWithConcurrentValidation.java:23)
at com.atomikos.jdbc.AbstractDataSourceBean.init(AbstractDataSourceBean.java:294)
at org.springframework.boot.jta.atomikos.AtomikosDataSourceBean.afterPropertiesSet(AtomikosDataSourceBean.java:49)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:307)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:857)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:760)
This is not an Atomikos limitation because it allows dynamic addition of datasources.
It looks like Spring Boot's convention-over-configuration trying to create a default datasource if you have none. I am not a Spring Boot expert so I am not sure if this can be suppressed. However, there is probably no harm in using a dummy default datasource in your configuration if that help.
Best regards
I build Vaadin project in production mode by gradle.
Here build.gradle.kts
plugins {
kotlin("jvm") version "1.3.20"
id("com.github.johnrengelman.shadow") version "4.0.3"
id("com.devsoap.vaadin-flow") version "1.0"
id("org.gretty") version "2.3.1"
id("war")
}
val kotlinVersion = "1.3.20" //by extra("1.3.20")
val jettyVersion = "9.4.14.v20181114"
val vaadinVersion = "12.0.4"
val jettyDep = { dep: String, suffix: String ->
"org.eclipse.jetty${if (suffix.isNotEmpty()) ".$suffix" else suffix}:$dep:$jettyVersion"
}
vaadin.autoconfigure()
vaadin {
setProductionMode(true)
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("com.github.jengelman.gradle.plugins:shadow:4.0.3")
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")
implementation("com.vaadin:vaadin-bom:$vaadinVersion")
implementation("com.vaadin:vaadin-core:$vaadinVersion")
//implementation("com.vaadin:flow-server-production-mode:1.4.0") // Switch to production mode
implementation("com.github.mvysny.karibudsl:karibu-dsl-v10:0.6.2")
implementation("ch.qos.logback:logback-classic:1.2.3")
implementation("javax.servlet:javax.servlet-api:3.1.0")
implementation(jettyDep("jetty-plus", ""))
implementation(jettyDep("jetty-continuation", ""))
implementation(jettyDep("jetty-server", ""))
implementation(jettyDep("websocket-server", "websocket"))
implementation(jettyDep("javax-websocket-server-impl", "websocket"))
implementation("com.auth0:java-jwt:3.7.0")
implementation("org.reflections:reflections:0.9.11")
}
Success create production mode war by command:
gradlew assemble
Nice.
But when I deploy war to Tomcat 9 I get error:
18-Mar-2019 19:23:07.310 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
18-Mar-2019 19:23:07.314 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [831] milliseconds
18-Mar-2019 19:23:07.342 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
18-Mar-2019 19:23:07.342 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.16]
18-Mar-2019 19:23:07.368 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [D:\Programs\apache-tomcat-9.0.16\webapps\booking-sailero-1.0-SNAPSHOT.war]
19:23:28.496 [main] DEBUG org.eclipse.jetty.util.log - Logging to Logger[org.eclipse.jetty.util.log] via org.eclipse.jetty.util.log.Slf4jLog
19:23:28.506 [main] INFO org.eclipse.jetty.util.log - Logging initialized #22304ms to org.eclipse.jetty.util.log.Slf4jLog
18-Mar-2019 19:23:32.302 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Error during ServletContainerInitializer processing
javax.servlet.ServletException: Not running on Jetty, JSR-356 support unavailable
at org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer.onStartup(WebSocketServerContainerInitializer.java:200)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5125)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:978)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1850)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:773)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:427)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
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:929)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:134)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
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:423)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:638)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)
18-Mar-2019 19:23:32.307 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal Context [/booking-sailero-1.0-SNAPSHOT] startup failed due to previous errors
18-Mar-2019 19:23:32.338 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [D:\Programs\apache-tomcat-9.0.16\webapps\booking-sailero-1.0-SNAPSHOT.war] has finished in [24,969] ms
18-Mar-2019 19:23:32.340 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [D:\Programs\apache-tomcat-9.0.16\webapps\karibu10-helloworld-application.war]
18-Mar-2019 19:23:34.874 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enab
I would assume the Jetty entries in your dependencies list causes Jetty classes to end up into the .war and thus also on the classpath. Some of those classes have some generic Servlet API annotations that are picked up by Tomcat, which tries to initialize them during server startup.
I have created spring boot application and tested my project with Rest API call its working fine.I'm applying SSL permission into my RestAPI but its giving exception.Please help me to solve my problem;
Java version: 10.2
Spring boot version:2.0.1
I have used below command to generate keyfile.
keytool -genkey -alias tomcatssl -keyalg RSA -keysize 2048 -keystore keystore.jks -validity 3650
project Structure
application.yml https configuration
While starting my spring boot application I'm getting exception like below:
2019-02-26 17:28:47.726 ERROR 2796 --- [ main] o.apache.catalina.core.StandardService : Failed to start connector [Connector[HTTP/1.1-8082]]
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8082]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.catalina.core.StandardService.addConnector(StandardService.java:225) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:256) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:198) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.startWebServer(ServletWebServerApplicationContext.java:300) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) [spring-context-5.0.5.RELEASE.jar:5.0.5.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.1.RELEASE.jar:2.0.1.RELEASE]
at com.DemoApplication.main(DemoApplication.java:12) [classes/:na]
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1020) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
... 13 common frames omitted
Caused by: java.lang.IllegalArgumentException: keystore password was incorrect
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:116) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:87) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:225) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1150) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:591) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.catalina.connector.Connector.startInternal(Connector.java:1018) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
... 14 common frames omitted
Caused by: java.io.IOException: keystore password was incorrect
at java.base/sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:2097) ~[na:na]
at java.base/sun.security.util.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:243) ~[na:na]
at java.base/java.security.KeyStore.load(KeyStore.java:1479) ~[na:na]
at org.apache.tomcat.util.net.SSLUtilBase.getStore(SSLUtilBase.java:139) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.tomcat.util.net.SSLHostConfigCertificate.getCertificateKeystore(SSLHostConfigCertificate.java:204) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.tomcat.util.net.jsse.JSSEUtil.getKeyManagers(JSSEUtil.java:184) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:114) ~[tomcat-embed-core-8.5.29.jar:8.5.29]
... 19 common frames omitted
Caused by: java.security.UnrecoverableKeyException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
... 26 common frames omitted
2019-02-26 17:28:47.730 INFO 2796 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2019-02-26 17:28:47.742 INFO 2796 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-02-26 17:28:47.745 ERROR 2796 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8082 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8082, or configure this application to listen on another port.
2019-02-26 17:28:47.746 INFO 2796 --- [ main] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext#112f364d: startup date [Tue Feb 26 17:28:44 IST 2019]; root of context hierarchy
2019-02-26 17:28:47.748 INFO 2796 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
2019-02-26 17:28:47.748 INFO 2796 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans
2019-02-26 17:28:47.749 INFO 2796 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2019-02-26 17:28:47.749 INFO 2796 --- [ main] com.zaxxer.hikari.HikariDataSource : masterdb-connection-pool - Shutdown initiated...
2019-02-26 17:28:47.755 INFO 2796 --- [ main] com.zaxxer.hikari.HikariDataSource : masterdb-connection-pool - Shutdown completed.
Please help me to resolve the problem.
source link Refernce:
https://code-adda.com/2018/06/enable-https-with-self-signed-certificate-in-spring-boot/
Are you sure that your key-store-password in application.yml is correct and match the password you entered when creating keystore?
SpringBoot version with SSL:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
With this configuration I was able to configure SSL in my project.
server.port=8443
server.ssl.key-alias=tomcatssl
server.ssl.key-password=tomcatssl
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-provider=SUN
server.ssl.key-store-type=JKS
I made mistake on keytool generation and I have created with againadmin privilege and its working fine.
I am running a grails project that has an android client. I migrated my grails project from my local postgres db to an online database server. After I run the grails app the response is for the first few minutes. After that I start getting this error. When I rerun the app the error disappears for the first few minutes then recurs. Note that this problem was non existent when I was using the local database. Here is the full stacktrace.
2018-07-13 10:01:37.571 ERROR --- [nio-8080-exec-8] o.h.engine.jdbc.spi.SqlExceptionHelper : This connection has been closed.
2018-07-13 10:01:37.586 ERROR --- [nio-8080-exec-8] o.g.web.errors.GrailsExceptionResolver : PSQLException occurred when processing request: [POST] /api/ - parameters:
email: fkamau#gmail.com
action: login
password: 1234
This connection has been closed.. Stacktrace follows:
java.lang.reflect.InvocationTargetException: null
at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:967)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:901)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.exception.JDBCConnectionException: could not prepare statement
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:115)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:148)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1934)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1903)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1881)
at org.hibernate.loader.Loader.doQuery(Loader.java:925)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:342)
at org.hibernate.loader.Loader.doList(Loader.java:2622)
at org.hibernate.loader.Loader.doList(Loader.java:2605)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2434)
at org.hibernate.loader.Loader.list(Loader.java:2429)
at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:109)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1787)
at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:363)
at org.grails.orm.hibernate.query.AbstractHibernateQuery.singleResultViaListCall(AbstractHibernateQuery.java:801)
at org.grails.orm.hibernate.query.AbstractHibernateQuery.singleResult(AbstractHibernateQuery.java:791)
at org.grails.datastore.gorm.finders.AbstractFindByFinder.invokeQuery(AbstractFindByFinder.java:35)
at org.grails.datastore.gorm.finders.AbstractFindByFinder$1.doInSession(AbstractFindByFinder.java:29)
at org.grails.datastore.mapping.core.DatastoreUtils.execute(DatastoreUtils.java:319)
at org.grails.datastore.gorm.finders.AbstractFinder.execute(AbstractFinder.java:42)
at org.grails.datastore.gorm.finders.AbstractFindByFinder.doInvokeInternal(AbstractFindByFinder.java:27)
at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:252)
at org.grails.datastore.gorm.finders.DynamicFinder.invoke(DynamicFinder.java:390)
at org.grails.datastore.gorm.GormStaticApi$_methodMissing_closure2.doCall(GormStaticApi.groovy:181)
at eafyaportal.PatientService.login(PatientService.groovy:55)
at eafyaportal.ApiController.login(ApiController.groovy:43)
... 14 common frames omitted
Caused by: org.postgresql.util.PSQLException: This connection has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Connection.checkClosed(AbstractJdbc2Connection.java:714)
at org.postgresql.jdbc2.AbstractJdbc2Connection.getAutoCommit(AbstractJdbc2Connection.java:680)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.getTargetConnection(LazyConnectionDataSourceProxy.java:422)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy$LazyConnectionInvocationHandler.invoke(LazyConnectionDataSourceProxy.java:376)
at org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy$TransactionAwareInvocationHandler.invoke(TransactionAwareDataSourceProxy.java:240)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:146)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:172)
... 39 common frames omitted
Your problem sounds related to the connection pool abandoning connections. Is there a specific connection pooling implementation that you are using? One of the most commonly used is Hikari. It has options to testOnBorrow which should check if a connection is alive before using it.
How do I configure HikariCP in my Spring Boot app in my application.properties files?