<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Spring2.5 Component Scan Not Working in JB 7AS
</h3>
<span style="margin-bottom: 10px;">
created by <a href="https://community.jboss.org/people/deepusrp">Deepak S</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/message/729409#729409">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hello Folks,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> I'm using JBoss 7 AS(jboss-as-7.1.0.Final) as my server.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> I have 2 questions...</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> 1.  I'm using Eclipse Helios SR2.  I'm not able to get the proper pluging to have JBOSS AS as my server in eclipse.</p><p>     I got several sites in net for the plugin, but when i tried to install it says conflicting, and it closes.</p><p>     Can i add Jboss 7 AS to my eclipse ?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p> 2.  I'm using spring 2.5, JSF and hibernate application.  </p><p>     The problem is i have used annotation for component and repository  but it is not getting initialized.   Basically  spring component scanner is not working.</p><p>     </p><p>     Please find the code snippets:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>     Web.xml:     </p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="jive-xml-tag"><span><web-app xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
    xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>"
    xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>
      </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd</a><span>"
    version="2.5"></span></span>
    <span class="jive-xml-tag"><listener></span>
        <span class="jive-xml-tag"><listener-class></span>org.springframework.web.context.ContextLoaderListener<span class="jive-xml-tag"></listener-class></span>
    <span class="jive-xml-tag"></listener></span>
    <span class="jive-xml-tag"><listener></span>
      <span class="jive-xml-tag"><listener-class></span>org.springframework.web.context.request.RequestContextListener<span class="jive-xml-tag"></listener-class></span>
    <span class="jive-xml-tag"></listener></span>
   
    <span class="jive-xml-tag"><context-param></span>
        <span class="jive-xml-tag"><param-name></span>contextConfigLocation<span class="jive-xml-tag"></param-name></span>
        <span class="jive-xml-tag"><param-value></span>/WEB-INF/applicationContext.xml<span class="jive-xml-tag"></param-value></span>
    <span class="jive-xml-tag"></context-param></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>applicationContext.xml</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="jive-xml-tag"><span><beans xmlns="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a><span>"
       xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
       xmlns:context="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/context" target="_blank">http://www.springframework.org/schema/context</a><span>"
       xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a><span>
           </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" target="_blank">http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</a><span>
           </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/context" target="_blank">http://www.springframework.org/schema/context</a><span>
           </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/context/spring-context-3.0.xsd" target="_blank">http://www.springframework.org/schema/context/spring-context-3.0.xsd</a><span>"></span></span>
              
    <span class="jive-xml-tag"><context:component-scan base-package="main.controllerbeans" /></span>
    <span class="jive-xml-tag"><context:annotation-config /></span>
   
    <span class="jive-xml-tag"><bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"></span>
        <span class="jive-xml-tag"><property name="locations"></span>
            <span class="jive-xml-tag"><list></span><span class="jive-xml-tag"><value></span>/WEB-INF/configuration.properties<span class="jive-xml-tag"></value></span><span class="jive-xml-tag"></list></span>
        <span class="jive-xml-tag"></property></span>
    <span class="jive-xml-tag"></bean></span>
   
    <span class="jive-xml-comment"><!-- IMPORTING HIBERNATE SETTINGS --></span>
    <span class="jive-xml-tag"><import resource="/db-config.xml"/></span>
</code></pre><p>Component scan is not working... it seems</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>db-config.xml</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0" encoding="UTF-8"?></span>
<span class="jive-xml-tag"><span><beans xmlns="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a><span>"
    xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>" xmlns:p="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/p" target="_blank">http://www.springframework.org/schema/p</a><span>"
    xmlns:context="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/context" target="_blank">http://www.springframework.org/schema/context</a><span>" xmlns:tx="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a><span>"
    xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a><span> </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/beans/spring-beans.xsd" target="_blank">http://www.springframework.org/schema/beans/spring-beans.xsd</a><span>
    </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/tx" target="_blank">http://www.springframework.org/schema/tx</a><span> </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/tx/spring-tx-3.0.xsd" target="_blank">http://www.springframework.org/schema/tx/spring-tx-3.0.xsd</a><span>
    </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/context" target="_blank">http://www.springframework.org/schema/context</a><span> </span><a class="jive-link-external-small" href="http://www.springframework.org/schema/context/spring-context-3.0.xsd" target="_blank">http://www.springframework.org/schema/context/spring-context-3.0.xsd</a><span>"></span></span>
    <span class="jive-xml-tag"><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"></span>
        <span class="jive-xml-tag"><property name="driverClass"></span>
            <span class="jive-xml-tag"><value></span>${jdbc.driver.className}<span class="jive-xml-tag"></value></span>
        <span class="jive-xml-tag"></property></span>
        <span class="jive-xml-tag"><property name="jdbcUrl"></span>
            <span class="jive-xml-tag"><value></span>${jdbc.url}<span class="jive-xml-tag"></value></span>
        <span class="jive-xml-tag"></property></span>
        <span class="jive-xml-tag"><property name="user"></span>
            <span class="jive-xml-tag"><value></span>${jdbc.username}<span class="jive-xml-tag"></value></span>
        <span class="jive-xml-tag"></property></span>
        <span class="jive-xml-tag"><property name="password"></span>
            <span class="jive-xml-tag"><value></span>${jdbc.password}<span class="jive-xml-tag"></value></span>
        <span class="jive-xml-tag"></property></span>
    <span class="jive-xml-tag"></bean></span>
    <span class="jive-xml-tag"><bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"></span>
        <span class="jive-xml-tag"><property name="dataSource"></span>
            <span class="jive-xml-tag"><ref bean="dataSource" /></span>
        <span class="jive-xml-tag"></property></span>
        <span class="jive-xml-comment"><!-- <span class="jive-xml-tag"><property name="packagesToScan" value="main.dbentities" /></span> --></span>
       
        <span class="jive-xml-tag"><property name="hibernateProperties"></span>
            <span class="jive-xml-tag"><props></span>
                <span class="jive-xml-tag"><prop key="hibernate.dialect"></span>${jdbc.hibernate.dialect}<span class="jive-xml-tag"></prop></span>
                <span class="jive-xml-tag"><prop key="hibernate.show_sql"></span>false<span class="jive-xml-tag"></prop></span>
            <span class="jive-xml-tag"></props></span>
        <span class="jive-xml-tag"></property></span>
       
        <span class="jive-xml-tag"><property name="packagesToScan" value="org.adit.spring.hibernate.entity" /></span>
   
        
    <span class="jive-xml-tag"></bean></span>
    <span class="jive-xml-tag"><bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"></span>
        <span class="jive-xml-tag"><property name="sessionFactory"></span>
            <span class="jive-xml-tag"><ref bean="sessionFactory" /></span>
        <span class="jive-xml-tag"></property></span>
    <span class="jive-xml-tag"></bean></span>
    <span class="jive-xml-tag"><context:annotation-config /></span>
    <span class="jive-xml-tag"><tx:annotation-driven /></span>
   
   
   
<span class="jive-xml-tag"></beans></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>faces-config.xml</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag"><?xml version="1.0"?></span>
<span class="jive-xml-tag"><span><faces-config xmlns="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>"
   xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"
   xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee" target="_blank">http://java.sun.com/xml/ns/javaee</a><span>
      </span><a class="jive-link-external-small" href="http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" target="_blank">http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd</a><span>"
   version="2.0"></span></span>
    <span class="jive-xml-tag"><application></span>
         <span class="jive-xml-tag"><el-resolver></span>org.springframework.web.jsf.el.SpringBeanFacesELResolver<span class="jive-xml-tag"></el-resolver></span>
    <span class="jive-xml-tag"></application></span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>NotificationBean.java</p><pre class="jive-pre"><code class="jive-code jive-java"><font color="navy"><b>import</b></font> java.io.Serializable;
 
<font color="navy"><b>import</b></font> javax.faces.bean.RequestScoped;
 
<font color="navy"><b>import</b></font> main.dao.NotificationDAO;
<font color="navy"><b>import</b></font> main.dbentities.Notification;
 
<font color="navy"><b>import</b></font> org.springframework.beans.factory.annotation.Autowired;
<font color="navy"><b>import</b></font> org.springframework.stereotype.Component;
 
@Component(<font color="red">"notificationBean"</font>)
@RequestScoped
<font color="navy"><b>public</b></font> <font color="navy"><b>class</b></font> NotificationBean <font color="navy"><b>implements</b></font> Serializable <font color="navy">{</font>
   
    <font color="navy"><b>private</b></font> <font color="navy"><b>static</b></font> <font color="navy"><b>final</b></font> <font color="navy"><b>long</b></font> serialVersionUID = -3637354326738964505L;
 
    @Autowired
    Notification notification;
   
    @Autowired
    <font color="navy"><b>public</b></font> NotificationDAO notificationDao;
   
    <font color="navy"><b>public</b></font> NotificationBean() <font color="navy">{</font>
        notification = <font color="navy"><b>new</b></font> Notification();
        <font color="darkgreen">//notificationDao = new NotificationDaoImpl();</font>
    <font color="navy">}</font>
 
    <font color="navy"><b>public</b></font> <font color="navy"><b>void</b></font> persist()<font color="navy">{</font>
        System.out.println(<font color="red">"Persist Method"</font>);
        notification.setUserId(111);
        notification.setPriorityId(1);
        notificationDao.save(notification);
    <font color="navy">}</font>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>In my xhtml page i have a  input text box:</p><p><h:inputText id="englishMessageTitle" value="#{notificationBean.notification.notificationTitleEng}" /></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>And there is submit button:</p><p><h:commandButton class="btn_empty" id="submit" value="#{msg['CreateNotification.Submit']}" action="#{notificationBean.persist}" /></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I'm getting the follwoing exception:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><pre class="jive-pre"><code class="jive-code">javax.el.PropertyNotFoundException: /xhtml/postmessage.xhtml @36,111 value="#{notificationBean.notification.notificationTitleEng}": Target Unreachable, identifier 'notificationBean' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(HtmlBasicInputRenderer.java:95)
at javax.faces.component.UIInput.getConvertedValue(UIInput.java:1030)
at javax.faces.component.UIInput.validate(UIInput.java:960)
at javax.faces.component.UIInput.executeValidate(UIInput.java:1233)
at javax.faces.component.UIInput.processValidators(UIInput.java:698)
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Its unable to resolve the bean notificationBean</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Following are the Jars that i have in my web-inf/lib:</p><p style="padding-left: 30px;">c3p0-0.9.1.2.jar</p><p style="padding-left: 30px;">commons-collections-3.2.1.jar</p><p style="padding-left: 30px;">commons-dbcp-1.4.jar</p><p style="padding-left: 30px;">dom4j-1.6.1.jar</p><p style="padding-left: 30px;">hibernate-3.2.1.ga.jar</p><p style="padding-left: 30px;">hibernate-annotations-3.4.0.GA.jar</p><p style="padding-left: 30px;">hibernate-commons-annotations-3.1.0.GA.jar</p><p style="padding-left: 30px;">hibernate-core-3.3.2.GA.jar</p><p style="padding-left: 30px;">jboss-el-2.0.1.GA.jar</p><p style="padding-left: 30px;">jsf-api.jar</p><p style="padding-left: 30px;">jsf-impl.jar</p><p style="padding-left: 30px;">jsp-2.1-6.0.2.jar</p><p style="padding-left: 30px;">jstl-api-1.2.jar</p><p style="padding-left: 30px;">jstl-impl-1.2.jar</p><p style="padding-left: 30px;">mysql-connector-java-3.0.17-ga-bin.jar</p><p style="padding-left: 30px;">org.springframework.context-2.5.6.SEC01.jar</p><p style="padding-left: 30px;">org.springframework.core-2.5.6.SEC01.jar</p><p style="padding-left: 30px;">org.springframework.transaction-2.5.6.A.jar</p><p style="padding-left: 30px;">persistence-api-1.0.jar</p><p style="padding-left: 30px;">spring-2.5.6.SEC01.jar</p><p style="padding-left: 30px;">spring-beans-2.5.6.SEC01.jar</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Please let me know what is the problem, and let me know if u need any other information.</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/729409#729409">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>