org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions - spring

I am developing a OSGI based Spring MVC application, I am using Karaf for deploying the bundles. My spring MVC application is a war file. I placed my bundle file in the deploy directory
karaf#root()> web:list
ID | State | Web-State | Level | Web-ContextPath | Name
125 | Active | Deployed | 80 | /sample | tomcat-sample (0)
168 | Active | Deployed | 80 | /spring-kalees-mvc-host | spring-kalees-mvc-host (0.0.1.SNAPSHOT)
I am having a servlet(To verify teh bundle) and Others are Spring
Url: http://*a****t:8181/spring-kalees-mvc-host/hello (Servlet mapping) works fine
But,
Url : http://*a*****t:8181/spring-kalees-mvc-host/osgi/osgi.htm (Spring based controller ) is not working
It is throwing error like,
HTTP ERROR 503
Problem accessing /spring-kalees-mvc-host/osgi/saySomething. Reason:
org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class' for property 'contextClass'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext]
Caused by:
org.eclipse.jetty.servlet.ServletHolder$1: org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Class' for property 'contextClass'; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext]
at org.eclipse.jetty.servlet.ServletHolder.makeUnavailable(ServletHolder.java:483)
at org.eclipse.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:537)
at org.eclipse.jetty.servlet.ServletHolder.getServlet(ServletHolder.java:402)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:642)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1448)
at org.ops4j.pax.web.service.internal.WelcomeFilesFilter.doFilter(WelcomeFilesFilter.java:192)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1419)
In karaf log file, There was a error entry like below :
org.ops4j.pax.web.pax-web-extender-war - 3.0.0.M3 | Registration exception. Skipping.
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener not found by org.danielsoft.learn.spring-kalees-mvc-host [167]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1460)[org.apache.felix.framework-4.0.3.jar:]
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:72)[org.apache.felix.framework-4.0.3.jar:]
at
I specified the classpath like
<classpath>WEB-INF/lib,WEB-INF/lib/org.springframework.context-3.2.2.RELEASE.jar,WEB-INF/lib/org.springframework.context.support-3.2.2.RELEASE.jar,WEB-INF/classes/,.</classpath>
And packed war file with lib files(WEB-INF/lib)
My bundle information is
Any Idea on this error ?

Related

Error at pipeline after increasing version of spring to latest one

After upgrading spring.version from 5.3.18 to 5.3.19 I got the following error in the Jenkins. Do you know the reason behind that error ?
application-logs_1 | APPLICATION FAILED TO START
application-logs_1 | ***************************
application-logs_1 | Description:application-logs_1 | Parameter 6 of constructor in springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper required a bean of type 'springfox.documentation.PathProvider' that could not be found.
application-logs_1 | Action:
application-logs_1 | Consider defining a bean of type'springfox.documentation.PathProvider' in your configuration.

Problem running project from s4sdk archtypes with artifact id: scp-cf-spring

I'm getting issues in running hello world project when I created it from below command:
mvn archetype:generate -DarchetypeGroupId=com.sap.cloud.s4hana.archetypes -DarchetypeArtifactId=scp-cf-spring -DarchetypeVersion=LATEST
The project gets created fine but when I'm running the application I get an error in creating beans, the error looks something like this:
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name
'com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor': Cannot create
inner bean '(inner bean)#630d4350' of type
[com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor] while setting
bean property 'listener'; nested exception is
org.springframework.beans.factory.CannotLoadBeanClassException: Error
loading class [com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor] for
bean with name '(inner bean)#630d4350' defined in URL
[jar:file:/Users/setup/.m2/repository/com/sap/cloud/s4hana/cloudplatform/caching/2.4.2-SNAPSHOT/caching-2.4.2-SNAPSHOT.jar!/com/sap/cloud/sdk/cloudplatform/cache/CacheMonitor.class]:
problem with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError:
com/sap/cloud/sdk/cloudplatform/monitoring/JmxMonitor . . .
Caused by:
org.springframework.beans.factory.CannotLoadBeanClassException: Error
loading class [com.sap.cloud.sdk.cloudplatform.cache.CacheMonitor] for
bean with name '(inner bean)#630d4350' defined in URL
[jar:file:/Users/setup/.m2/repository/com/sap/cloud/s4hana/cloudplatform/caching/2.4.2-SNAPSHOT/caching-2.4.2-SNAPSHOT.jar!/com/sap/cloud/sdk/cloudplatform/cache/CacheMonitor.class]:
problem with class file or dependent class; nested exception is
java.lang.NoClassDefFoundError:
com/sap/cloud/sdk/cloudplatform/monitoring/JmxMonitor . . .
Caused by: java.lang.ClassNotFoundException:
com.sap.cloud.sdk.cloudplatform.monitoring.JmxMonitor
Please let me know if I should furnish more details.
The fix is: I generated project with version: 2.3.1, it is working fine now.:
mvn archetype:generate -DarchetypeGroupId=com.sap.cloud.s4hana.archetypes -DarchetypeArtifactId=scp-cf-spring -DarchetypeVersion=2.3.1

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)

Installing Jasper WAR file -- Missing dependencies?

When I run the command: js-ant import-minimal-ce I get an exception error:
[java] Resource name: applicationContext-virtual-data-source.xml
Followed by:
[java] org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'executionOwnerVoter': Injection of
resouorg.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'executionOwnerVoter': Injection of resource
dependencies failed; nested exception
I can only best determine I am somehow missing a dependency (perhaps that of Hibernate.jar?) as this appears to occur when performing database operations.
Any ideas? Frustrated and out of options...
Alex

BundleContext is no longer valid

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

Resources