Search code examples
jsf-2annotationsmyfacesspring-3

@Named not working on weblogic while integrating JSF 2.0 and spring 3.0.6


I have read an article on internet for using @Named annotation to inject JSF managed beans.

how to use @Named annotation

But it is not working on weblogic 10.0.2. (Working fine on Jetty)

I am using Myfaces 2.1.6, Spring 3.0.6 for injecttion.

Please find the dependencies of spring and JSF that I have added in POM.xml:

<dependencies>


        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>jsr250-api</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>org.jboss.el</groupId>
            <artifactId>jboss-el</artifactId>
            <version>2.0.1.GA</version>
            <scope>compile</scope>
            <exclusions>
                <exclusion>
                    <groupId>javax.el</groupId>
                    <artifactId>el-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>


        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-api</artifactId>
            <version>2.1.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.myfaces.core</groupId>
            <artifactId>myfaces-impl</artifactId>
            <version>2.1.6</version>
        </dependency>

        <dependency>
            <groupId>commons-el</groupId>
            <artifactId>commons-el</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${org.springframework.version}</version>
        </dependency>

        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>

    </dependencies>

faces-config.xml

<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
      http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    version="1.2">
    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/login.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/wsListing.xhtml</to-view-id>
            <redirect />
        </navigation-case>
        <navigation-case>
            <from-outcome>failure</from-outcome>
            <to-view-id>/failure.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>
    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/wsListing.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>abcService</from-outcome>
            <to-view-id>/abcinput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
        <navigation-case>
            <from-outcome>filterabc</from-outcome>
            <to-view-id>/filterabcinput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>


    <navigation-rule>
        <description>Navigation from the hello page.</description>
        <from-view-id>/abcinput.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
            <to-view-id>/abcoutput.xhtml</to-view-id>
            <redirect />
        </navigation-case>
    </navigation-rule>

    <application>
        <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    </application>
</faces-config>

Please let me know if you can identify what am I doing wrong?


Solution

  • Try using include-filter in applicationContext XML

    <context:component-scan base-package="com.example.scan" >
        <context:include-filter  type="regex" expression="com.example.scan.*Bean"  />
    </context:component-scan>