I have a rest api in Spring Framework with Java, it works with amazon aws services, using the "aws-java-sdk-1.5.0.jar" file, working very well. But, I have to implement Amazon SES and that version of that jar doesn't support it, for that reason I downloaded a most recent version "aws-java-sdk-1.11.269.jar", I replaced it and deleted the previous version, and rebuild the project. It works fine again but only locally. Remotely the WAR file cannot be deployed, It shows an error about Unsatisfied dependency exception, but remember locally deploys and works fine. Do you know what I'm doing wrong?
13-Sep-2019 20:43:16.892 INFO [main] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
13-Sep-2019 20:43:16.909 INFO [main] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
13-Sep-2019 20:43:19.363 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.springframework.web.context.ContextLoaderListener]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'settingsRestFacade': Unsatisfied dependency expressed through field 'fileStorageServices'; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fileStorageServices' defined in com.desafioguerreros.SpringConfiguration: Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.desafioguerreros.infrastructure.storage.FileStorageServices]: Factory method 'fileStorageServices' threw exception; nested exception is
java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLConnectionSocketFactory.<init>(Ljavax/net/ssl/SSLContext;Ljavax/net/ssl/HostnameVerifier;)V
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1348)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578)
...
Related
I'm updating a service's dependencies from Spring Boot 2.3.12.RELEASE to 2.7.0 and Spring Cloud from Hoxton.Release to 2021.0.3
Upon doing this, I'm starting to get kubernetes errors that I didn't see with the previous dependency versions.
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeDiscoveryClient' defined in class path resource [org/springframework/cloud/client/discovery/composite/CompositeDiscoveryClientAutoConfiguration.class]: Unsatisfied dependency expressed through method 'compositeDiscoveryClient' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kubernetesDiscoveryClient' defined in class path resource [org/springframework/cloud/kubernetes/discovery/KubernetesDiscoveryClientAutoConfiguration$Servlet.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.client.discovery.DiscoveryClient]: Factory method 'kubernetesDiscoveryClient' threw exception;
nested exception is org.springframework.cloud.kubernetes.discovery.DiscoveryServerUrlInvalidException: spring.cloud.kubernetes.discovery-server-url must be specified and a valid URL.
I've read a few tutorials about using the #EnableDiscoveryClient annotation in the application as well as autowiring the DiscoveryClient in the controllers, including the Baeldung tutorial. However, I have yet to see anything mention a discovery-server-url.
Where do I set this value, or how to I tell Spring and Kubernetes what to look for?
Notice that "spring.cloud.kubernetes.discovery-server-url" has a spelling error in Springs error message. The parameter name is spring.cloud.kubernetes.discovery.discovery-server-url.
It can be set anywhere in Springs external configuration (.properties, .yaml). Regarding K8s, the quickest way is perhaps the args in your deployment.yaml:
template:
metadata:
labels:
...
spec:
containers:
- name: ...
image: ...
command: ["java"]
args: ["-Dspring.profiles.active=kubernetes", "-Dspring.cloud.kubernetes.discovery.discovery-server-url=http://spring-cloud-kubernetes-discoveryserver.default.svc.cluster.local", "-Dspring.cloud.kubernetes.discovery.enabled=true", "org.springframework.boot.loader.JarLauncher"]
ports:
...
The project current runs fine via IntelliJ. Its built with Java 11, spring-boot 2.4.3, and gradle 6.8.3
The error as I read it states that it cannot find a 'RestDriver'( which is annotated as #RestController) nor the interface 'DriverService' which has no annotations on it. That class uses a a class annotated with #Service 'DriverServiceImp'.
Its as if I will have to state in main where these classes are because it cannot find them.
2021-10-21 12:04:45 [main] ERROR o.s.boot.SpringApplication at 856 - Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'restDriver':
Unsatisfied dependency expressed through field 'driverService';
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'DriverService': Lookup method resolution failed;
nested exception is java.lang.IllegalStateException:
Failed to introspect Class [com.xxx.wfmDriverservice.service.DriverServiceImp] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader#5c7fa833]
I want jboss to read properties from spring-boot.war file's inner application.properties file. When i deploy my application as war i get these error
java.lang.RuntimeException: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.web.servlet.
DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration':
Unsatisfied dependency expressed through constructor parameter 0;
nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException:
Error creating bean with name 'spring.mvc-org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties': Could not bind properties to 'WebMvcProperties' : prefix=spring.mvc, ignoreInvalidFields=false, ignoreUnknownFields=true;
nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.mvc.servlet' to org.springframework.boot.autoconfigure.web.servlet.WebMvcProperties$Servlet
What can i do to configure this?
Thanks
EDIT: Before reading the question: deleting the folder in wildfly deployment "solved" the issue. But I didn't put back my code for the other DB. Is the way I did it was right?
I was working this morning, everything was going fine.
I added a dependency which is the core of another maven project and the goal was to use that project to add data in the database of that project, not the one of my current project.
So I tried a lot of stuff, but at the end it was working. And then, I left to go eat.
The server is host on my computer, so localhost and I left it like that for about an hour.
Here's what I did:
Create new hibernate.cfg.xml in src/main/resources with properties.
So I had 2 hibernate.cfg.xml in my project. The original one in src/main/resources/my/hibernate/package/ and the new one in the default package.
In my code ->
Configuration cfg = new Configuration();
cfg.configure();
Note that before doing only that, I was setting the properties programmatically and it was working fine.
I thought it was taking the one in default package. That was working earlier.
So I came back, try to run the application and get this exception:
Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
I haven't touch a thing... so I removed all my work (the new hibernate.cfg.xml too), restarted the server, even the computer.
I read about the exception, it says that maybe I have two dom4j, or that I need to put <scope>provided</scope> to some dependencies.
I added the scope everywhere, removed the dependency of the other project, but it won't help.
I have these logs in my wildfly server.log
WFLYCTL0186: Services which failed to start:
service jboss.undertow.deployment.default-server.default-host./PROJECT_NAME:
org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./PROJECT_NAME:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'firstControllerInMyDispatcher':
Unsatisfied dependency expressed through field 'DAO_name':
Error creating bean with name 'DAO_name' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Cannot resolve reference to bean 'mySessionFactory' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed;
nested exception is org.hibernate.InvalidMappingException:
Unable to read XML;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'DAO_name' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Cannot resolve reference to bean 'mySessionFactory' while setting constructor argument;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mySessionFactory' defined in ServletContext resource [/WEB-INF/dispatcher-servlet.xml]:
Invocation of init method failed;
nested exception is org.hibernate.InvalidMappingException:
Unable to read XML
The dom4j exception only shows in the Netbeans console log and it's after all those same lines:
"{\"WFLYCTL0080: Failed services\" => {\"[previous exceptions lines]
Caused by:
org.dom4j.DocumentException:
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception:
org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory\"}}"
I'm clueless, can anyone help with this? Thanks.
I ran into a problem trying to use Spring-roo in STS ide.
I created a project and added EclipseLink ORM, and that is about it.
In persistence.xml i added all the details for the database connectivity.
When I tried to run the spring project, it failed to show the default jspx page i was expecting.
Here is the error:
2012-07-02 10:45:39,411 [pool-2-thread-1] ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [/home/ubuntu/springsource/vfabric-tc-server-developer-2.7.0.RELEASE/spring-insight-instance/wtpwebapps/SpringRooStats/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [/home/ubuntu/springsource/vfabric-tc-server-developer-2.7.0.RELEASE/spring-insight-instance/wtpwebapps/SpringRooStats/WEB-INF/classes/META-INF/spring/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.reflect.UndeclaredThrowableException
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
It is complaining it seems that it needs to create an entity manager, but I think that
it should not since it should run a project that does not connect to a database and just run a simple jspx page.
Does one need to go thru the whole thing with entities just to run a simple project.
Hope someone can help.
Your applicationcontext.xml has a transactionManager defined. This needs a entity manager. Your would need to remove the transaction manager or add the entity manager.
I'm also not sure why you added the ORM framework if your not going to use it.