[AnnotationConfigEmbeddedWebApplicationContext:559] - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedActiveMQ' defined in class path resource [com/els/galaxy/gateway/ArtemisConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.apache.activemq.artemis.core.protocol.mqtt.MQTTProtocolManagerFactory.stripPasswordParameters(Ljava/util/Map;)V
[LocalContainerEntityManagerFactoryBean:597] - Closing JPA EntityManagerFactory for persistence unit 'readPersistenceUnit'
=[LocalContainerEntityManagerFactoryBean:597] - Closing JPA EntityManagerFactory for persistence unit 'writePersistentUnit'
[session:167] - node0 Stopped scavenging
[ContextHandler:1045] - Stopped o.s.b.c.e.j.JettyEmbeddedWebAppContext#7bebe5de{application,/galaxy-gateway,[file:///C:/Users/basireddym/AppData/Local/Temp/jetty-docbase.7636853341168462882.86/],UNAVAILABLE}
[AutoConfigurationReportLoggingInitializer:102] -
Related
Sometimes when Tomcat has been running for a while and I terminate the embeded Tomcat (Ctrl+c) the application throws the following exception:
2019-10-17 10:23:10.704 INFO 20020 --- [ Thread-3] o.s.b.f.support.DisposableBeanAdapter : Invocation of destroy method failed on bean with name 'entityManagerFactory': java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/springframework/orm/hibernate5/SpringBeanContainer$SpringContainedBean
Exception in thread "Thread-3" java.lang.NoClassDefFoundError: org/apache/catalina/Lifecycle$SingleUse
at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:269)
at org.apache.catalina.startup.Tomcat.stop(Tomcat.java:466)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stopTomcat(TomcatWebServer.java:254)
at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.stop(TomcatWebServer.java:309)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.stopAndReleaseWebServer(ServletWebServerApplicationContext.java:305)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onClose(ServletWebServerApplicationContext.java:171)
at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1032)
at org.springframework.context.support.AbstractApplicationContext$1.run(AbstractApplicationContext.java:945)
It seems that the exception is thrown when Tomcat has been running for a long time and my application has not been used.
I checked my application jar file and spring-orm-5.1.8.RELEASE.jar is embeded and the class org/springframework/orm/hibernate5/SpringBeanContainer is there.
Any idea is apreciated.
Try to shutdown the application before replacing or renaming the jar.
#see Graceful shutdown fails
We have some existing source code which connect to JMS using TCP protocol . We are providing EMS URL as shown below in properties file:
tib.ems.url=tcp://UK_ONES_DEV_0000.ldn.mywork.com:9222
Now our EMS URL has been changed to SSL but when we are making any changes to ems URL in properties file, it is changing SSL to TCP automatically and failing connection. I am wondering if we need to make any changes for SSL connection.
<bean id="orcaReplayConnectionFactory"
class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
<property name="targetConnectionFactory" ref="orcaProviderReplayConnectionFactory"/>
<property name="username" value="${jms.orca.username}"/>
<property name="password" value="${jms.orca.password}"/>
</bean>
<jee:jndi-lookup id="orcaProviderReplayConnectionFactory"
jndi-name="${jndi.orca.name.replay}">
<jee:environment>
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.provider.url=${jndi.orca.url}
java.naming.factory.url.pkgs=com.tibco.tibjms.naming
</jee:environment>
</jee:jndi-lookup>
15:43:12.923 [main] INFO o.s.s.c.ThreadPoolTaskScheduler -Initializing ExecutorService 'taskScheduler'
15:43:13.528 [main] WARN o.s.c.s.ClassPathXmlApplicationContext -Exception encountered during context initialization - cancelling refresh attempt
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jms.listener.DefaultMessageListenerContainer#0': Cannot resolve reference to bean 'orcaConnectionFactory_v2' while setting bean property 'connectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orcaConnectionFactory_v2' defined in class path resource [spring/integration-context.xml]: Cannot resolve reference to bean 'orcaProviderConnectionFactory_v2' while setting bean property 'targetConnectionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orcaProviderConnectionFactory_v2': Invocation of init method failed; nested exception is javax.naming.ServiceUnavailableException: Failed to query JNDI: Failed to connect to the server at tcp://UK_ONES_UAT_0000.ldn.mywork.com:9222 [Root exception is javax.jms.JMSException: Failed to connect to the server at tcp://UK_ONES_UAT_0000.ldn.mywork.com:9222]
Normally, when using JNDI, the connection URL is configured in the provider not the JNDI client. You need to fix the url in the provider.
After adding highlighted configuration while doing JNDI l, issue is resolved
<jee:environment>
java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
java.naming.provider.url=${jndi.orca.url}
java.naming.factory.url.pkgs=com.tibco.tibjms.naming
**com.tibco.tibjms.naming.security_protocol=ssl
com.tibco.tibjms.naming.ssl_enable_verify_host=false**
java.naming.security.principal=${jms.orca.username}
java.naming.security.credentials=${jms.orca.password}
</jee:environment>
Can you please help with this:
I start my application but it is closing down after few seconds error below:
2018-09-21 17:34:59,500 INFO | main | com.zaxxer.hikari.HikariDataSource 93 | springHikariCP - is starting. |
2018-09-21 17:35:29,535 INFO | main | com.zaxxer.hikari.pool.HikariPool 213 | springHikariCP - is closing down. |
2018-09-21 17:35:29,855 WARN | main | o.s.context.support.ClassPathXmlApplicationContext 551 | Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appEntityManagerFactory' defined in class path resource [META-INF/spring/app.repositories.xml]: Invocation of init method failed; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Exception during pool initialization: springHikariCP - Connection is not available, request timed out after 30002ms. |
2018-09-21 17:35:29,870 ERROR | main | com.my.jos.jmx.Driver 72 | CRITICAL ERROR: Error encountered starting application. |
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appEntityManagerFactory' defined in class path resource [META-INF/spring/app.repositories.xml]: Invocation of init method failed; nested exception is com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Exception during pool initialization: springHikariCP - Connection is not available, request timed out after 30002ms.
If you don't need to use HikariCP you may check your POM and consider removing it if it's defined already.
Also you can make sure of using the following dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Assuming you are using xml configuration, you can make sure of the setting datasource properly:
How to Define a MySql datasource bean via XML in Spring
We have a Spring Boot application (multiple micro-services), packaged with Google Container Builder and published to the registry. Our cloudbuild.yaml looks like this:
steps:
- name: 'gcr.io/cloud-builders/java/gradle'
id: 'java-build'
args: ['build']
- name: 'gcr.io/cloud-builders/docker'
args: ['build',
'-t', 'gcr.io/$PROJECT_ID/api-auth:$COMMIT_SHA',
'-t', 'gcr.io/$PROJECT_ID/api-auth:latest',
'-f', './api-auth/Dockerfile', './api-auth']
waitFor: ['java-build']
- name: 'gcr.io/cloud-builders/docker'
args: ['build',
'-t', 'gcr.io/$PROJECT_ID/api-user:$COMMIT_SHA',
'-t', 'gcr.io/$PROJECT_ID/api-user:latest',
'-f', './api-user/Dockerfile', './api-user']
waitFor: ['java-build']
images:
- 'gcr.io/$PROJECT_ID/api-auth:$COMMIT_SHA'
- 'gcr.io/$PROJECT_ID/api-auth:latest'
- 'gcr.io/$PROJECT_ID/api-user:$COMMIT_SHA'
- 'gcr.io/$PROJECT_ID/api-user:latest'
which is called by a trigger on push into the repository on GitHub.
If I run this locally:
container-builder-local --dryrun=false .
resulting images run fine, e.g.:
docker run -e "SPRING_PROFILES_ACTIVE=development" -p 9000:9000 gcr.io/.../api-auth:latest
but when the image is built in the cloud with the Container Builder, the application doesn't work and fails with error that never ocurred before.
Even when pulled:
gcloud docker -- pull gcr.io/.../api-auth:latest
and run locally the new error stops the application from loading:
2017-10-11 16:35:27.661 WARN 5 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webSecurityConfig': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in class path resource [org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.authentication.AuthenticationManager]: Factory method 'authenticationManager' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'OAuth2Config': Unsatisfied dependency expressed through field 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'authenticationManager': Requested bean is currently in creation: Is there an unresolvable circular reference?
2017-10-11 16:35:27.663 INFO 5 --- [ main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2017-10-11 16:35:27.676 INFO 5 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2017-10-11 16:35:27.718 INFO 5 --- [ main] utoConfigurationReportLoggingInitializer :
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-10-11 16:35:27.730 ERROR 5 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
The dependencies of some of the beans in the application context form a cycle:
webSecurityConfig (field private org.springframework.security.authentication.AuthenticationManager com.project.auth.config.WebSecurityConfig.authenticationManager)
┌─────┐
| authenticationManager defined in class path resource [org/springframework/boot/autoconfigure/security/AuthenticationManagerConfiguration.class]
↑ ↓
| OAuth2Config (field private org.springframework.security.authentication.AuthenticationManager com.project.auth.config.OAuth2Config.authenticationManager)
└─────┘
This only happens when the image goes through the Cloud Container Builder - neither the local one, nor with a local gradle build.
Could this possibly be a problem in the cloud, or am I missing something trivial?
I have also filed an issue on GitHub, but since it's a broader problem along with the Spring Boot nature of the application, I thought I'd ask here to see if it rings any bell.
I'm running TomEE 7.0.1 in Eclipse Neon. I've defined a DataSource resource in the "tomee.xml" file. The DataSource connects to an Oracle DB, and I'm getting the driver from my local Maven repo.
When TomEE starts up, I get the following error in the console:
org.apache.tomcat.jdbc.pool.PoolExhaustedException: [main] NoWait: Pool empty. Unable to fetch a connection, none available[5 in use].
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:679)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143)
at org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEConnectionPool.<init>(TomEEDataSourceCreator.java:221)
Here is my Resource definition:
<Resource id="global/foo/bar" type="DataSource" classpath="mvn:oracle:ojdbc6:11.2.0.3">
JdbcDriver = oracle.jdbc.driver.OracleDriver
MaxActive = 5
MinIdle = 2
MaxIdle = 2
MaxWait = 10000
JdbcUrl = jdbc:oracle:thin:#<host>:1521:sus2
UserName = <userid>
Password = <password>
</Resource>
I've elided the host, user, and password, but the id is as written. I'm still unsure about the JNDI lookup, but that's obviously a separate problem.
Here's my JNDI lookup reference in my Spring context:
<jee:jndi-lookup jndi-name="java:global/foo/bar" id="sus2ds"/>
And here is more of the Tomcat console output:
INFO: Configuring Service(id=global/foo/bar, type=Resource, provider-id=Default JDBC Database)
...
INFO: Creating Resource(id=global/foo/bar)
Aug 03, 2016 11:08:27 AM org.apache.tomcat.jdbc.pool.ConnectionPool checkPoolConfiguration
WARNING: initialSize is larger than maxActive, setting initialSize to: 5
Aug 03, 2016 11:08:27 AM org.apache.tomcat.jdbc.pool.ConnectionPool init
SEVERE: Unable to create initial connections of pool.
org.apache.tomcat.jdbc.pool.PoolExhaustedException: [main] NoWait: Pool empty. Unable to fetch a connection, none available[5 in use].
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:679)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143)
at org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEConnectionPool.<init>(TomEEDataSourceCreator.java:221)
...
Aug 03, 2016 11:08:27 AM org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEDataSource <init>
SEVERE: Can't create DataSource
org.apache.tomcat.jdbc.pool.PoolExhaustedException: [main] NoWait: Pool empty. Unable to fetch a connection, none available[5 in use].
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:679)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:468)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:143)
at org.apache.tomee.jdbc.TomEEDataSourceCreator$TomEEConnectionPool.<init>(TomEEDataSourceCreator.java:221)
...
...
2016-08-03 11:08:30,080 WARN [localhost-startStop-1] support.AbstractApplicationContext (AbstractApplicationContext.java:549) - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sus2ds': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name "foo/bar" not found.
2016-08-03 11:08:30,084 ERROR [localhost-startStop-1] context.ContextLoader (ContextLoader.java:351) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sus2ds': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name "foo/bar" not found.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
...
Caused by: javax.naming.NameNotFoundException: Name "foo/bar" not found.
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:199)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:151)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:291)
at org.apache.naming.NamingContext.lookup(NamingContext.java:828)
...
Aug 03, 2016 11:08:30 AM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sus2ds': Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: Name "foo/bar" not found.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
...
Caused by: javax.naming.NameNotFoundException: Name "foo/bar" not found.
at org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:199)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:151)
at org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:291)
at org.apache.naming.NamingContext.lookup(NamingContext.java:828)
...
I would start the server and use an MBean explorer, or the JNDI explorer webapp, to take a look at the JNDI tree and get the correct name. My suspicion is you do not need id="global/foo/bar" but id="foo/bar" and keep the lookup the same in your Spring code.