BundleContext is no longer valid - osgi-bundle

I am having a Java web application which runs in an OSGi container. I have deployed my application on a Tomcat server. When I restart my server sometimes I am randomly getting mutiple instaces of error "BundleContext is no longer valid" and hence I am unable to deploy the application. It doesn't happen all the time when we restart our application server but happens sometimes only. The only solution we found is just to restart the server. Following is the stack trace:
org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager] : Adding
OSGi service dependency for importer [&simplyticOsgiSaeAdapter] matching OSGi filter [(objectClass=c
om.moodysanalytics.sae.simplytic.adapter.SimplyticSaeAdapter)]
[org.springframework.osgi.service.importer.support.OsgiServiceProxyFactoryBean] : Creating a single
service proxy ...
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (
1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'dataSource
' threw exception; nested exception is java.lang.IllegalStateException: **BundleContext is no longer valid**
org.ops4j.pax.logging.pax-logging-api[org.springframework.beans.factory.xml.BeanDefinitionParserDele
gate] : No XML 'id' specified - using 'templateElement' as bean name and [] as aliases
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAcce
ssor.java:102)
[org.springframework.beans.factory.support.DefaultListableBeanFactory] : FactoryBean threw exception
from getObjectType, despite the contract saying that it should return null if the type of its objec

Related

Problems while restore nifi version 1.12.1 with old configs

In general, the update was successful. But after transferring the configs from the old version (authorizers.xml, nifi.properties, keystore.jks, flow.xml.gz) to the new version, it starts to swear that they are not valid, and the keystore password is incorrect, but open it with the old password successfully. Below presented errors in the log:
WARN [main] org.eclipse.jetty.webapp.WebAppContext Failed startup of context o.e.j.w.WebAppContext#6bb4dd34{nifi-api,/nifi-api,file:///opt/nginx/nifi-ift/nifi/work/jetty/nifi-web-api-1.12.1.war/webapp/,UNAVAILABLE}{./work/nar/framework/nifi-framework-nar-1.12.1.nar-unpacked/NAR-INF/bundled-dependencies/nifi-web-api-1.12.1.war}
org.apache.nifi.web.NiFiCoreException: Unable to start Flow Controller.
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'flowService': FactoryBean threw
exception on object creation; nested exception is
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'flowController': FactoryBean threw exception
on object creation; nested exception is
java.lang.IllegalStateException: Flow controller TLS configuration is
invalid
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'flowController': FactoryBean threw
exception on object creation; nested exception is
java.lang.IllegalStateException: Flow controller TLS configuration is
invalid
Caused by: java.lang.IllegalStateException: Flow controller TLS
configuration is invalid
Caused by: org.apache.nifi.security.util.TlsException: The truststore
properties are not valid
WARN [main] org.apache.nifi.web.server.JettyServer Failed to start web server... shutting down.
java.io.IOException: Keystore was tampered with, or password was incorrect
Caused by: java.security.UnrecoverableKeyException: Password verification failed

mongodb on tomcat with spring

I have written an RestAPI server that uses mongodb with spring, and successfully tested it locally. But, when I am deploying the war file on my server (tomcat) it causes an error.
After searching, I added "compile 'org.mongodb:mongo-java-driver:2.13.3'" to my build.gradle/pom.xml file based on a tutorial. But, I don't know what to do next to solve the error. I assume it has something to do with initializing a mongodb. Here is my error on Jenkins when it tries do deploys it:
BUILD SUCCESSFUL in 6s
4 actionable tasks: 4 executed
Build step 'Invoke Gradle script' changed build result to SUCCESS
Deploying /var/jenkins_home/workspace/AddressBook/build/libs/AddressBook.war to container Tomcat 8.x Remote with context
Redeploying [/var/jenkins_home/workspace/AddressBook/build/libs/AddressBook.war]
Undeploying [/var/jenkins_home/workspace/AddressBook/build/libs/AddressBook.war]
Deploying [/var/jenkins_home/workspace/AddressBook/build/libs/AddressBook.war]
ERROR: Build step failed with exception
org.codehaus.cargo.container.ContainerException: Failed to deploy [/var/jenkins_home/workspace//AddressBook/build/libs/AddressBook.war]
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:106)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:184)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
at hudson.FilePath.act(FilePath.java:997)
at hudson.FilePath.act(FilePath.java:975)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1749)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded "FAIL - Deployed application at context path [/AddressBook] but context failed to start
" instead of the expected "OK" message
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:715)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:761)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:312)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:101)
... 18 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded "FAIL - Deployed application at context path [/AddressBook] but context failed to start
" instead of the expected "OK" message
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:715)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:761)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:312)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:101)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:184)
at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
at hudson.FilePath.act(FilePath.java:997)
at hudson.FilePath.act(FilePath.java:975)
at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1749)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE
My application is something like https://spring.io/guides/gs/accessing-data-mongodb/, with some RestAPI mappings.
And here is the tomcat log:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'per
sonController': Unsatisfied dependency expressed through field 'PersonRepo'; nested exception is org
.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personRepositor
y': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating
bean with name 'mongoTemplate' defined in class path resource [org/springframework/boot/autoconfigu
re/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency expressed through method 'mo
ngoTemplate' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependenc
yException: Error creating bean with name 'mongoDbFactory' defined in class path resource [org/sprin
gframework/boot/autoconfigure/data/mongo/MongoDataAutoConfiguration.class]: Unsatisfied dependency e
xpressed through method 'mongoDbFactory' parameter 0; nested exception is org.springframework.beans.
factory.BeanCreationException: Error creating bean with name 'mongo' defined in class path resource
[org/springframework/boot/autoconfigure/mongo/MongoAutoConfiguration.class]: Bean instantiation via
factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Fai
led to instantiate [com.mongodb.MongoClient]: Factory method 'mongo' threw exception; nested excepti
on is java.lang.IllegalAccessError: tried to access method org.bson.types.ObjectId.<init>(III)V from
class com.mongodb.Bytes
UPDATE (fix of above error):
So, I had this as dependency in my build.gradle:
compile 'org.mongodb:mongo-java-driver:2.13.3'
I changed it to (not enforcing version):
compile group: 'org.mongodb', name: 'mongo-java-driver'
But, now when I request a GET from my server, I see:
Sun Mar 04 21:05:23 UTC 2018
There was an unexpected error (type=Internal Server Error, status=500).
Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]; nested exception is com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
Here is my application.properties:
spring.data.mongodb.host=<server_address>
spring.data.mongodb.port=27017
spring.data.mongodb.user=<username>
MongoDB server on localhost:27017 (user , pwd: same as /var/jenkins_home).
Should I somehow tell my application about the path of mongoDB?
Or should I tell my application about the database name? (I think it will use some default one)

Error running CXF REST web service on Apache Tomee

I'm trying to build a RESTful web service using the "org.apache.cxf.archetype:cxf-jaxrs-service" maven archetype. When I deploy it on Apache Tomee I get the following error:
SEVERE: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'services': Invocation of init method failed; nested exception is org.apache.cxf.service.factory.ServiceConstructionException
...
...
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:219)
...
...
Caused by: java.lang.ClassCastException: Cannot cast org.apache.cxf.management.jmx.InstrumentationManagerImpl to org.apache.cxf.management.InstrumentationManager*
My guess is I'm missing some configuration but I thought the archetype would 'just work'.
Any ideas?
this error means you have a conflict between cxf in the webapp (WEB-INF/lib) and tomee. You either have to configure the classloading to do that or (recommanded and expected by EE) just remove CXF from the webapp since it is in tomee and tomee does the job for you.
Side note: you will also likely need to clean up the web.xml since tomee will handle the deployment without the need to register a servlet.

HTTP ERROR 503 with Spring Framework

I am using appEngine with Spring Framework and maven. I run the application from maven and everything is fine in command line but in browser I found this error.
HTTP ERROR: 503
Problem accessing /. Reason:
SERVICE_UNAVAILABLE
I don't know where I have to fix. Below is the error code in terminal when I try to run with maven. I think Spring framework has big problem in my PC.
[INFO] WARNING: Nested in org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.handler.MappedInterceptor#0': Cannot create inner bean '(inner bean)' of type [org.springframework.web.servlet.handler.ConversionServiceExposingInterceptor] while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)': Cannot resolve reference to bean 'org.springframework.format.support.FormattingConversionServiceFactoryBean#0' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.format.support.FormattingConversionServiceFactoryBean#0': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: java.time.format.FormatStyle is a restricted class. Please see the Google App Engine developer's guide for more details.:
[INFO] java.lang.NoClassDefFoundError: java.time.format.FormatStyle is a restricted class. Please see the Google App Engine developer's guide for more details.

Can't start application in IDE with <jar-find> error, but 'gradle bootRun' - works fine

So, i have a problem that can't solve.
I have a multi module gradle project with spring boot runners. With Jpa, Elastic, OrientDb and another configurations provided by spring-data and spring-integration. And i try to start my web application! Write web starter, make annotation scan, so when I use task 'gradle bootRun' - everything start perfectly - app works, all contexts up and life is good.BUT, when i try use my favorite IDE like Intellij idea, or colleague use Eclipse - get an error :
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with
name 'org.springframework.integration.config.IdGenerato rConfigurer#0':
BeanPostProcessor before instantiation of bean failed; nested exception is
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with
name org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration':
Initialization of bean failed; nested exception is java.lang.NoSuchMethodError:
org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration.setBeanFactory(Lo rg/springframework/beans/factory/BeanFactoryV
That cause by (projectName - is fake):
java.lang.RuntimeException: error trying to scan <jar-file>:
file:/home/<user>/project/<projectName>/classes/production/<projectName>-system-webapp/
But i have NO /projectName/classes/production/ folder! Anyway - with gradle it's work fine.
And to be honestly, before this another error catched:
Error creating bean with name 'entityManagerFactory' defined in class com.project.system.jpa.PepperJpaConfiguration: Invocation of init method failed
caused by:
error trying to scan <jar-file>: file:/home/<user>/project/<projectName>/classes/production/<projectName>-system-webapp/
Thank you for advice! Can give additional info.
P.S : Edited
So, the problem was solved:
I do not provide important error stacktrace like:
at org.hibernate.ejb.packaging.NativeScanner.getFilesInJar(NativeScanner.java:195)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:506)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:861)
... 21 more
Caused by: java.io.IOException: invalid constant type: 18 at 50
And this was and JDK8-Hibernate-javassist problem https://hibernate.atlassian.net/browse/HHH-8286
When upgrade javassist version to 3.18.1-GA - all problems was solved(but why run through gradle worked perfectly...)

Resources