maven 2 - is it possible to use class.forname to load a class that exists within a module wired up with Spring? -
I have two Maven modules and in module 1, for class A, to load module 2 for class B, Class is to use .forname
. It works very well and I can call the right methods at class B at all. Module 1 is wired using spring and I want to wade Module 2 in the same way for equality. I tried to do it and did not compile it. But when I try to run the code, I get a lot of problems. First of all it can not get different spring classes like ApplicationContext
. There is dependency in POD in module 2. To solve the problem I had to add all spring jar to my lift folder in Jebus.
Once they are added, it starts to clear those issues, but then I get the following issues: -
org.springframework.beans.FatalBeanException : Org. Springframework.beans.factory.xml.UtilNamespaceHandler] for namespace [http://www.springframework.org/schema/util] [org.springframework.beans.factory.xml.NamespaceHandler] does not apply to the interface
And I do not understand why am I trying to achieve? This is not a problem of maven or spring, because both classes do not spell magic.
This is a problem with your deployment and packaging.
Check that both modules have been declared as scope runtime (or default) in your pom.xml
. .ar
or .ear
You should have both modules jar files and their dependencies, never copy every library into the Libib folder of the server, unless you actually Do not know what you are doing.
Also verify that your last archive should not have duplicate entries ! This is very important if you use Spring, so make sure that you do not have any spring.jar
, but only in your code spring-xxxxx.jar
There are files. If you have spring-beans.jar
and spring.jar
for example, then there is something wrong with your dependency management in poml.xml
. Also remove the Spring Library that you added to the Lib Libro folder of the server.
Check the versions of your dependencies Although Maven should be avoided by most mistakes, make sure that no library is found in your class with multiple versions.
If you are using Class.forName (string)
, you need for the class. Use ForName (string, classloader)
and the application's classloader
. The default classloader
used by class .forName ()
is the ContextClassLoader
(TCCL) of the IMHO thread. Not sure that this is right for your case. If you use any of the settings that do the dynamic class loading or weaving, then you can try to set yourself TCCL.
Another option, if all goes unsuccessful, check that you see "> Classloader JB's delegation model
Comments
Post a Comment