Announcement Announcement Module
Collapse
No announcement yet.
JSF - Spring Integration Error... Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JSF - Spring Integration Error...

    Hi Every one,

    I'm Trying to use a mix of JSF for view and Spring for middle tier, I suscesfully setup a working spring app (from the manager to the dao part) but I'm now stuck in the JSF-Spring Integration I follow the instructions from the ref manual, but I stil gettin null Spring Objects in faces context..


    Here is my faces-config.xml

    Code:
         <!-- Spring VariableResolver for JSF -->
        <application>
           <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
            <locale-config>
                <default-locale>es</default-locale>
                <supported-locale>en</supported-locale>
                <supported-locale>es</supported-locale>
            </locale-config>
            <message-bundle>messages</message-bundle>
        </application>
    
         <managed-bean>
            <managed-bean-name>TIPOPERFILUSUARIOForm</managed-bean-name>
            <managed-bean-class>co.com.quipux.entapp.qxvehiculos.web.TIPOPERFILUSUARIOForm</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>tipoperfilusuarioManager</property-name>
                <value>#{tipoperfilusuarioManager}</value>
            </managed-property>
        </managed-bean>
    and my application-context

    Code:
          
        <beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
                <!-- results in a setDriverClassName(String) call -->
                <beans:property name="driverClassName"  value="oracle.jdbc.driver.OracleDriver" />
                <beans:property name="url" value="jdbc:oracle:thin:@127.0.1.107:1521:BDHONDU" />
                <beans:property name="username" value="username" />
                <beans:property name="password" value="*****"/>
                <beans:property name="defaultAutoCommit" value="true" />
                <beans:property name="maxActive" value="30"/>
                <beans:property name="maxIdle" value="10"/>
                <beans:property name="maxWait" value="1000"/>
         </beans:bean>
    
        <beans:bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <beans:property name="dataSource" ref="dataSource"/>
        </beans:bean>
        
    
        <!-- Enable @Transactional support -->
        <tx:annotation-driven/>
        
        <!-- Enable @AspectJ support -->
        <aop:aspectj-autoproxy/>
        
        <aop:config>
            <aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))"/>
        </aop:config>
        
        <tx:advice id="txAdvice">
            <tx:attributes>
                <tx:method name="get*" read-only="true"/>
                <tx:method name="*"/>
            </tx:attributes>
        </tx:advice>
    
      <!-- Scans for @Repository, @Service and @Component -->
      <context:component-scan base-package="co.com.quipux.entapp"/>
    The Form has :
    public TIPOPERFILUSUARIOManager tipoperfilusuarioManager;
    and no new() initialization for the TIPOPERFILUSUARIOManager so IOC from Spring is needed..

    the manager implementation class has:

    Code:
    @Service(value = "tipoperfilusuarioManager")
    public class TIPOPERFILUSUARIOManagerImpl implements TIPOPERFILUSUARIOManager {
    I debug thee application and see how the managerimpl is correctly initialized but something is happening and the instance is not being binded to the Form class, any ideas?




    by the way, this is the Stack Trace, that kicks out when in the form constructor I try to acces a function of the null property tipoperfilusuarioManager
    Code:
    Aug 28, 2008 11:33:27 AM org.apache.catalina.core.ApplicationContext log
    SEVERE: Cant instantiate class: co.com.quipux.entapp.qxvehiculos.web.TIPOPERFILUSUARIOForm.
    com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: co.com.quipux.entapp.qxvehiculos.web.TIPOPERFILUSUARIOForm.
    	at com.sun.faces.mgbean.BeanBuilder.newBeanInstance(BeanBuilder.java:191)
    	at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:106)
    	at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:368)
    	at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:230)
    	at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:88)
    	at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
    Last edited by m4rkuz; Aug 31st, 2008, 02:17 PM.

  • #2
    First off all your applicationContext looks weird why both use annotation driven transactions and xml based transactions?

    Code:
        <tx:annotation-driven/>
        
        <!-- Enable @AspectJ support -->
        <aop:aspectj-autoproxy/>
        
        <aop:config>
            <aop:advisor id="managerTx" advice-ref="txAdvice" pointcut="execution(* *..service.*Manager.*(..))"/>
        </aop:config>
        
        <tx:advice id="txAdvice">
            <tx:attributes>
                <tx:method name="get*" read-only="true"/>
                <tx:method name="*"/>
            </tx:attributes>
        </tx:advice>
    Use one of them not both.

    Also I see that you use the @Service annotation but you haven't specified a context:component-scan anywhere. If you don't tell spring to do something with the annotations it doesn't do anything for you.

    Comment


    • #3
      You're right, I miss the Scan part in the fragment I post, but I do have it in my app context, and that part works fine, (I just edit my first post to add it)

      <!-- Scans for @Repository, @Service and @Component -->
      <context:component-scan base-package="com.myapp.entapp"/>
      now the part of xml anotation .... mmm... huh..... mmm

      I get most of my appcontext from an example (appfuse... )

      could that be the problem??
      Last edited by m4rkuz; Aug 31st, 2008, 03:37 PM.

      Comment


      • #4
        Just re-read your post again.

        Originally posted by m4rkuz
        by the way, this is the Stack Trace, that kicks out when in the form constructor I try to acces a function of the null property tipoperfilusuarioManager
        No it completly makes sense. You cannot access it in the constructor, it will be dependency injected AFTER construction. So it isn't available in the constructor.

        Comment


        • #5
          Marten Deinum

          I change the code so it won't use manager in the constructor, and eliminate sentence taht i have write to get the bean from the WebApplicationContext using the get bean method, I've seen now my app starts with out the problem that use to have when I tryed tu bind spring managed objects in the faces context file, so I'm guessing this is working a little better, but I cannot still get the manager reference bind to the Form.. I'm still getting a null manager object, and now I'm also getting a null FacesContext reference... :S

          I getting an stomach ulcer, but I will keep trying

          Now I even put an @Autowired anotation in the form rigth before the manager declaration, but I don't think this is gonna kick, because that bean is instantiated by JSF.. :S

          Comment


          • #6
            IT WORKS!!!!!!

            but not for the @Autowired anotation, the answer was calling the manager only by the getter method, and correct an error in the Faces-COnfig file that has the wrong name for the manager.


            Thanks Again Marten this is the second time you get me out of trouble.

            ps: don't throw me to the flames for this tiny error ^^
            Last edited by m4rkuz; Sep 1st, 2008, 11:23 AM.

            Comment

            Working...
            X