facebook

What ways java to access beans in spring applicationcontext

  1. MyEclipse Archived
  2.  > 
  3. Web Development (HTML, CSS, etc.)
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #306264 Reply

    amir55
    Participant

    hi dear all

    1 – //used to be ok in previous versions to version 8
    ApplicationContext applicationContext = new FileSystemXmlApplicationContext(new String (“src/applicationContext.xml”));

    error
    javax.servlet.ServletException: javax.faces.FacesException: Cant instantiate class: component1.ItemHandler.. IOException parsing XML document from file [D:\JBoss_GR\jboss-4.2.2.GA\bin\src\applicationContext.xml]; nested exception is java.io.FileNotFoundException: src\applicationContext.xml (The system cannot find the path specified)

    2 – how to access in jave code the springDAOManager in next applicationContext.xml

    <beans>

    <bean id=”husbandDAOService” class=”org.springframework.transaction.interceptor.TransactionProxyFactoryBean”>
    <property name=”transactionManager”><ref bean=”transactionManager”/></property>
    <property name=”proxyTargetClass”><value>true</value></property><property name=”transactionAttributes”></property>
    <property name=”target”><ref local=”springDAOManager”/></property></bean>

    </beans>

    I tried next but not working for mismatch

    SpringDAOManager springDAOManager = (SpringDAOManager)applicationContext.getBean(“husbandDAOService”); // not ok

    Amir

    #306276 Reply

    Amir,
    Can explain in detail what exactly you are trying to do?

    used to be ok in previous versions to version 8

    Are you working on a project that is imported from an earlier version of MyEclipse?
    Also, can you list out the steps to replicate the above issue?

    #306278 Reply

    amir55
    Participant

    hi dear

    1 – yes I use the projects from earlier versions

    2 – I just try to re run those projects on version 8.

    3 – I started with the jsf spring hibernte. I used to get the applicationContext.xml successfuly but now error thrown

    ApplicationContext applicationContext = new FileSystemXmlApplicationContext(new String (“src/applicationContext.xml”));

    error
    error
    javax.servlet.ServletException: javax.faces.FacesException: Cant instantiate class: component1.ItemHandler.. IOException parsing XML document from file [D:\JBoss_GR\jboss-4.2.2.GA\bin\src\applicationContext.xml]; nested exception is java.io.FileNotFoundException: src\applicationContext.xml (The system cannot find the path specified)

    4 – more important spring question is

    Hhow to access in jave code the springDAOManager in next applicationContext.xml

    <beans>

    <bean id=”husbandDAOService” class=”org.springframework.transaction.interceptor.TransactionProxyFactoryBean”>
    <property name=”transactionManager”><ref bean=”transactionManager”/></property>
    <property name=”proxyTargetClass”><value>true</value></property><property name=”transactionAttributes”></property>
    <property name=”target”><ref local=”springDAOManager”/></property></bean>

    </beans>

    I tried next but not working for mismatch. srurely it is as

    a – SpringDAOManager is not husbandDAOService
    b – husbandDAOService has no corrispondent bean. so how to do that thankfully

    SpringDAOManager springDAOManager = (SpringDAOManager)applicationContext.getBean(“husbandDAOService”); // not ok

    Amir

    #306304 Reply

    Amir,
    Can you try using absolute path for FileSystemXmlApplicationContext?
    Please refer to the following link –
    http://www.coderanch.com/forums/posts/watch/0/476364

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: What ways java to access beans in spring applicationcontext

You must be logged in to post in the forum log in