Results 1 to 6 of 6

Thread: JSF - Spring Integration Error...

  1. #1
    Join Date
    Jul 2008
    Location
    Medellín, Colombia
    Posts
    135

    Default 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 at 02:17 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2008
    Location
    Medellín, Colombia
    Posts
    135

    Default

    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 at 03:37 PM.

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Just re-read your post again.

    Quote 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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Jul 2008
    Location
    Medellín, Colombia
    Posts
    135

    Unhappy

    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

  6. #6
    Join Date
    Jul 2008
    Location
    Medellín, Colombia
    Posts
    135

    Default

    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 at 11:23 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •