Announcement Announcement Module
Collapse
No announcement yet.
how to access spring used project JAR file from none spring project Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to access spring used project JAR file from none spring project

    Hi All,

    how to access spring used project JAR file from none spring project
    1. I have a standalone JAR project which use spring. output is JAR flle. Let's say project A.
    2. I wanna use that JAR from other non spring standalone project.Let's say project B.


    Project B need to access Project A JAR.
    but it occurs NoSuchBeanDefinitionException: No bean named 'priceManager' is defined Exception

    Please help me.

    Notes:

    Project A exposed class to outside : ApplicationRun

    Code:
    public class ApplicationRun {
    public static void getPrice() {
    ClassPathXmlApplicationContext contex = new ClassPathXmlApplicationContext("classpath*:**/spring-context*.xml");
    contex.registerShutdownHook();
    PriceManager priceManager = (PriceManager) contex.getBean("priceManager");
    try {
    priceManager.getNewPrice(getPriceParamDTOSample());
    } catch (PriceTestingFramworkException e) {
    e.printStackTrace();
    }
    
    }
    }


    Project B call to

    Code:
    import com.whf.ashol.run.ApplicationRun;
    
    public class Main {
    
    public static void main(String[] args) {
    ApplicationRun.getPrice();
    }
    
    }
    Error console

    Code:
    00:30:51.094 [main] DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver - Looking for matching resources in directory tree [D:\works\c\workspace\springws\test\bin]
    00:30:51.095 [main] DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver - Searching directory [D:\works\c\workspace\springws\test\bin] for files matching pattern [D:/works/c/workspace/springws/test/bin/**/spring-context*.xml]
    00:30:51.097 [main] DEBUG o.s.c.i.s.PathMatchingResourcePatternResolver - Resolved location pattern [classpath*:**/spring-context*.xml] to resources []
    00:30:51.097 [main] DEBUG o.s.b.f.xml.XmlBeanDefinitionReader - Loaded 0 bean definitions from location pattern [classpath*:**/spring-context*.xml]
    00:30:51.097 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Bean factory for org.springframework.context.support.ClassPathXmlApplicationContext@12498b5: org.springframework.beans.factory.support.DefaultListableBeanFactory@1c39a2d: defining beans []; root of factory hierarchy
    00:30:51.113 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Unable to locate MessageSource with name 'messageSource': using default [[email protected]b7]
    00:30:51.116 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@1c1ea29]
    00:30:51.117 [main] INFO  o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@1c39a2d: defining beans []; root of factory hierarchy
    00:30:51.118 [main] DEBUG o.s.c.s.ClassPathXmlApplicationContext - Unable to locate LifecycleProcessor with name 'lifecycleProcessor': using default [[email protected]a37c]
    00:30:51.118 [main] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'lifecycleProcessor'
    Exception in thread "main" 00:30:51.121 [Thread-0] INFO  o.s.c.s.ClassPathXmlApplicationContext - Closing org.springframework.context.support.ClassPathXmlApplicationContext@12498b5: startup date [Wed Jul 17 00:30:51 IST 2013]; root of context hierarchy
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'priceManager' is defined

    project was created using STS.
    spring-context.xml is on src/main/resources folder.



    JAR create using Maven pom.xml

    Code:
    <build>
    <plugins>
    <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
    <archive>
    <manifest>
    <mainClass>com.wtf.travelinsurance.run.ApplicationRun</mainClass>
    </manifest>
    </archive>
    <descriptorRefs>
    <descriptorRef>jar-with-dependencies</descriptorRef>
    </descriptorRefs>
    </configuration>
    </plugin>
    </plugins>
    </build>
Working...
X