1

I need one help. i am trying to create a Spring moven project in multiple module. just assume, there is Maven project with below module: Module-root(parent Module of all submodule) Module-persistance(Having code logic for DAO operation and package type jar) Module-service(Having code logic for controller implementation and package type war)

Module-service is dependent on Module-persistance submodule. Module-persistance is having Spring-context1.xml file in it's src/main/resources classpath. Module-service is having spring-context2.xml file in it's src/main/resources classpath.

So, My question is how spring-context2.xml can import Spring-context1.xml? Thanks in Advance!

Now importing of the spring.xml file from one module to another working fine :).

But but here i am getting error while deploying the war.

HibernateCfg.java is a file defined in module Module-persistance. and imported this file in the Module-service. compile and build of the all module is successful. but at the time of deploying the Module-service war file on the server, it is throwing ClassNotFoundException for "HibernateCfg".

I checked the war file, inside of that Module-persistance.jar file is available with class file of HibernateCfg. but i am not sure why it is throwing exception. Could you please help me with this. Below is the exception:

Caused by: java.lang.ClassNotFoundException: org.munsiji.hibernateUtil.HibernateCfg from [Module "deployment.munsiji-service.war:main" from Service Module Loader] at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:198) at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:363) at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:351) at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:93) ... 48 more

Rohit
  • 406
  • 1
  • 5
  • 21
  • 1
    Possible duplicate of [How to import spring-config.xml of one project into spring-config.xml of another project?](https://stackoverflow.com/questions/5113579/how-to-import-spring-config-xml-of-one-project-into-spring-config-xml-of-another) – Koitoer Jan 11 '18 at 17:07

2 Answers2

0

Simply add this to the child xml document

<import resource="classpath:second-config.xml" />
Jeryl Cook
  • 989
  • 17
  • 40
  • Thanks Jeryl For your comment. it helped me. but here i am getting error while deploying the war, and i have updated that in the question. Could you help me in that? Thanks again! – Rohit Jan 12 '18 at 15:56
  • can you accept my answer. and update or make new question about the .war deployment. Thanks! – Jeryl Cook Jan 12 '18 at 16:45
0

I have same problem in maven child project. If you have written as :

    <import resource="second-config.xml" />

change it to :

    <import resource="classpath:second-config.xml" />