My application uses Spring XML configuration. I must add Spring Social's functionality(i want to configure it also by XML) but i encounter an error:
nested exception is java.lang.ClassNotFoundException: org.springframework.social.connect.signin.web.ProviderSignInController
I have tried configuring by XML in my application and also in the spring-social-showcase sample app but the same error... All the jars are in the right place... I took the configuration model from the Spring Social guide. Did anyone configured it by XML?
found the probelm... It seems that there are 2 ProviderSignInController classes in different packages. In the docs there is org.springframework.social.connect.signin.web.ProviderSignInController
and in the jar there is org.springframework.social.connect.web.ProviderSignInController
The ClassNotFoundException tells you that your don't have all the jars in the right place. You're probably missing spring-social-web-1.x.x.RELEASE.jar.
Related
My question is similar to this one (Spring boot application with apache axis) but I am running Spring Boot v2.2.6. When I execute the command
java -jar -Dspring.profiles.active=local myjar-0.0.1-SNAPSHOT.jar
I get the error
2021-06-01 00:41:53,152 myjar [http-nio-9090-exec-1] ERROR
org.apache.axis2.deployment.ModuleDeployer - deploy:94 - The addressing-1.6.3-classpath-
module.jar module, which is not valid, caused The /Users/xxxx/workspace/myjar/build/libs/myjar-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/addressing-1.6.3-classpath-
module.jar file cannot be found.
org.apache.axis2.AxisFault: The /Users/xxxx/workspace/.../build/libs/myjar-0.0.1-
SNAPSHOT.jar!/BOOT-INF/lib/addressing-1.6.3-classpath-module.jar file cannot be found.
I also have the relevant build.gradle snippet
api "org.apache.axis2:addressing:1.6.3:classpath-module"
api "org.apache.axis2:axis2:1.6.3"
api "org.apache.axis2:axis2-adb:1.6.3"
api "org.apache.axis2:axis2-transport-local:1.6.3"
api "org.apache.axis2:axis2-transport-http:1.6.3"
I confirmed that the file /Users/xxxx/workspace/myjar/build/libs/myjar-0.0.1-SNAPSHOT.jar!/BOOT-INF/lib/addressing-1.6.3-classpath-module.jar does exist. Can anyone help fix this issue?
It looks like Axis cannot cope with one jar file being nested inside another. For situations like this, you can configure Spring Boot to automatically unpack the nested jar when you start your application:
bootJar {
requiresUnpack '**/addressing-*-classpath-module.jar'
}
This may be an impossible task, but here goes...
Is it possible to register a spring bean, by (ONLY) adding a jar to the classpath of a spring-boot application?
Scenario: I would like to create a non-intrusive plugin jar, which when imported into a spring-boot project's classpath, will automatically be picked up and provide a service (e.g. via a RestController).
Constraints
I don't want to change or reconfigure the existing spring-boot application (i.e. no additional scan paths or bean config).
I don't have any knowledge of the target spring-boot application's package structure/scan paths.
I guess I was hoping that by default Spring scan's its own package structure (i.e. org.springframework.** looking for the presence of database libs, etc) and I could piggy-back off that - I haven't had any luck (so far).
I've setup an example project in github, to further clarify/illustrate my example and attempts.
** Solution Addendum **
This bit that got it working, was to add the following file, which points to an #Configuration config file...
plugin-poc\src\main\resources\META-INF\spring.factories
org.springframework.boot.autoconfigure.EnableAutoConfiguration=org.thirdpartyplugin.PluginConfiguration
I think in such cases you would try to add a spring auto configuration that is annotated with #ConditionalOnClass to be only evaluated if the given class is on the classpath. This class can register the bean and would just be evaluated if the conditional evaluates to true
Here is the relevant part of the spring boot documentation : Creating your own auto-configuration
In a Spring-boot application, I was having a single module and I was able to inject a configuration file, e.g. "my.properties", that was located in src/main/resources as follows:
#Configuration
#PropertySource("/my.properties")
public class MyConf{
}
Everything was ok, but then I created submodules and now I moved that configuration file in a submodule. When I start the main application I gedt the following exception:
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.myapp.MainApplication]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/home/jeanvaljean/workspace/mainmodule/secondarymodule/my.properties]
As I see, I can solve the issue by writing
#PropertySource("/src/main/resources/my.properties")
Doing this, the path is correct and the file can be loaded.
Anyway, that is an horrible solution, and I'm pretty sure that there is a more elegant and flexible alternative. Any solution?
Spring has a few different implementations of how to find a resource. By using the prefix classpath: you are telling Spring to search for the resource in all the classpath, rather than in the classes that are bundled with your application.
Depending on the ApplicationContenxt, Spring will use a different default Resource class. It looks like in your case, Spring was instantiating a FileSystemResource, which only finds files available on the filesystem with either relative or absolute paths (but not inside jars!). My rule of thumb is to never prefix something if it's in the same module/component/jar, and always prefix it with classpath: if I know it's in a different module/component/jar (some people get mad at this :).
You can read a more in the Spring Documentation - Resources
I'm having hibernate3.jar and hibernate-core-4.2.0.CR1.jar in my classpath and I'm using Spring 3.1.3 version. Code got compiles sucessfully but while runtime I'm getting following error
2014-10-28 10:51:25,174 DEBUG [RMI TCP Connection(2)-10.126.30.203] -
Target method failed for RemoteInvocation: method name
'getPriceByKeys'; parameter types [java.util.List, java.util.Date]
java.lang.NoSuchMethodError:
org.hibernate.SessionFactory.openSession()Lorg/hibernate/Session;
I google it but not find any solution. Please note : My project needs hibernate3.jar but at the same time my project dependent on some other 3rd party jar which inturn using hibernet4.2.0 jar.
Any help Pls ??
You need to remove multiple hibernate JAR files from your classpath. Without doing this, your application may not work as you expect; which means you need to migrate the hibernate version of your application from 3 to 4.1.
Although Spring 3.1 uses Hibernate 3 JAR files, you can still migrate to Hibernate 4. Check out Spring blog gives a small tutorial to do so.
Migrating to Spring 3.1 and Hibernate 4.1
As part of the Core-Spring course, we have a lab application that we
use to show how to integrate Spring and JPA/Hibernate together. We
have just upgraded it to Spring 3.1 / Hibernate 4.1, and thought we
should share a few tips.
Just an update. The cause of problem is , I'm having two spring-context xml files in project (one of my project and one related to another module that I'm integrating). I'm loading context xmls from two different classes. So one of the DAO class loaded by one of spring-context xml not getting the hibernate Session.
Later on using import tag, I included 2nd spring application context file in 1st application context file and then loaded a Single application context file from the class. It solved the error.
Thanks,
I am developing an application using Struts 2.x. I am using Spring Security to provide security to my application. However, when I am not connect to the internet I always get an exception. If I have internet connect, there will be no exception. The exception is:
javax.faces.FacesException: Can't parse configuration file:
jar:file:/home/dev7/springsource/vfabric-tc-server-developer-2.8.2.RELEASE/base-instance/wtpwebapps/UNHPM_5/WEB-INF/lib/skyway-spring-utils-7.1.3.jar!/META-INF/faces-config.xml:
Error at line 5 column 16: cvc-elt.1: Cannot find the declaration of
element 'faces-config'.
I have also added the jar file skyway-spring-utils-7.1.3.jar to project but the exception remains when I am not connected to the internet. What may be the solution?
Probably this problem belongs to jar version miss-match.because it's create incompatibility between the DTD version.
Another problem may be you have multiple versions of jar in your build-path.
My suggestion is use maven to add the dependency jar