Q: Issue using component-scan (spring) - not injecting dependencies I am starting a new app development, and I received some code (the prototype). I noticed the spring-servlet.xml is using the tag:
<context:component-scan...
I never worked with that tag before, and I am very confused. I suppose some config is missing, because my mapping is just not working.
If I use it like
<context:component-scan base-package="my.app.mainpackage">, the app fails to deploy
If I use it like:
<context:component-scan base-package="my.app.mainpackage.controller" />
the app deploys, as far as I don't use @Autowired on my controller (otherwise it don't deploy as well), but then, all the other packages out of the controller package won't have the dependencies injected. 
In the end, I am not being able to inject the dependencies!
The server log displays the error when it is starting as:
      "Calling "C:\jboss-eap-6.0\bin\standalone.conf.bat"
    ===============================================================================

      JBoss Bootstrap Environment

      JBOSS_HOME: C:\jboss-eap-6.0

      JAVA: C:\jdk1.7.0_07\bin\java

      JAVA_OPTS: -XX:+TieredCompilation -XX:+UseCompressedOops -Dprogram.name=standalone.bat -Xms1303M -Xmx1303M -XX:MaxPerm
    Size=256M -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djava.net.preferIPv4Stack=tru
    e -Dorg.jboss.resolver.warning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.server.default.config=standalo
    ne.xml

    ===============================================================================

    17:37:30,602 INFO  [org.jboss.modules] JBoss Modules version 1.1.2.GA-redhat-1
    17:37:31,296 INFO  [org.jboss.msc] JBoss MSC version 1.0.2.GA-redhat-1
    17:37:31,338 INFO  [org.jboss.as] JBAS015899: JBoss EAP 6.0.0.GA (AS 7.1.2.Final-redhat-1) starting
    17:37:33,865 INFO  [org.xnio] XNIO Version 3.0.4.GA-redhat-1
    17:37:33,884 INFO  [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-h
    ttp)
    17:37:33,888 INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.0.4.GA-redhat-1
    17:37:33,941 INFO  [org.jboss.remoting] JBoss Remoting version 3.2.8.GA-redhat-1
    17:37:33,984 INFO  [org.jboss.as.clustering.infinispan] JBAS010280: Activating Infinispan subsystem.
    17:37:33,984 INFO  [org.jboss.as.configadmin] JBAS016200: Activating ConfigAdmin Subsystem
    17:37:34,009 INFO  [org.jboss.as.naming] JBAS011800: Activating Naming Subsystem
    17:37:34,023 INFO  [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
    17:37:34,032 INFO  [org.jboss.as.security] JBAS013101: Activating Security Subsystem
    17:37:34,032 INFO  [org.jboss.as.webservices] JBAS015537: Activating WebServices Extension
    17:37:34,054 INFO  [org.jboss.as.security] (MSC service thread 1-1) JBAS013100: Current PicketBox version=4.0.9.Final-re
    dhat-1
    17:37:34,066 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-8) JBAS010408: Starting JCA Subsystem (JBoss I
    ronJacamar 1.0.11.Final-redhat-1)
    17:37:34,634 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
    17:37:34,637 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-1) JBAS015400: Bound mail session [java:jboss/mai
    l/Default]
    17:37:34,747 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deployi
    ng JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
    17:37:34,768 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deployi
    ng JDBC-compliant driver class org.h2.Driver (version 1.3)
    17:37:34,951 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deployi
    ng JDBC-compliant driver class oracle.jdbc.driver.OracleDriver (version 11.2)
    17:37:35,040 INFO  [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-4) JBoss Web Services - S
    tack CXF Server 4.0.4.GA-redhat-1
    17:37:35,095 INFO  [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-6) Starting Coyote HTTP/1.1 on http-/
    127.0.0.1:8080
    17:37:35,103 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-6) JBAS010400: Bound data sourc
    e [java:jboss/datasources/ExampleDS]
    17:37:35,219 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) JBAS015012: Started FileSystemDeplo
    ymentService for directory C:\jboss-eap-6.0\standalone\deployments
    17:37:35,222 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "myApp.war

17:37:35,227 INFO  [org.jboss.as.remoting] (MSC service thread 1-4) JBAS017100: Listening on 127.0.0.1:4447
    17:37:35,230 INFO  [org.jboss.as.remoting] (MSC service thread 1-8) JBAS017100: Listening on 127.0.0.1:9999
    17:37:38,082 ERROR [stderr] (MSC service thread 1-2) log4j:ERROR No appender named [logfile] could be found.
    17:37:38,096 WARN  [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springfr
    amework.web.context.request.async.StandardServletAsyncWebRequest due to exception: org.jboss.as.server.deployment.Deploy
    mentUnitProcessingException: JBAS011054: Could not find default constructor for class org.springframework.web.context.re
    quest.async.StandardServletAsyncWebRequest
            at org.jboss.as.ee.component.ComponentDescription$DefaultComponentConfigurator.configure(ComponentDescription.ja
    va:606) [jboss-as-ee-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]
            at org.jboss.as.ee.component.deployers.EEModuleConfigurationProcessor.deploy(EEModuleConfigurationProcessor.java
    :83) [jboss-as-ee-7.1.2.Final-redhat-1.jar:7.1.2.Final-redhat-1]
            at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:116)
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
            at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]

    17:37:38,234 INFO  [org.jboss.as.osgi] (MSC service thread 1-1) JBAS011907: Register module: Module "deployment.myApp.war:
    main" from Service Module Loader
    **17:37:38,591 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Error listenerStart
    17:37:38,591 ERROR [org.apache.catalina.core.StandardContext] (MSC service thread 1-8) Context [/myApp] startup failed due
     to previous errors
    17:37:38,603 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.web.de
    ployment.default-host./myApp: org.jboss.msc.service.StartException in service jboss.web.deployment.default-host./myApp: JBAS
    018040: Failed to start context**
            at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:95)
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-ms
    c-1.0.2.GA-redhat-1.jar:1.0.2.GA-redhat-1]
            at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.G
    A-redhat-1.jar:1.0.2.GA-redhat-1]
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_07]
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_07]
            at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_07]

    17:37:38,814 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "myApp.war"
    17:37:38,817 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
    JBAS014777:   Services which failed to start:      service jboss.web.deployment.default-host./myApp: org.jboss.msc.service
    .startException in service jboss.web.deployment.default-host./myApp: JBAS018040: Failed to start context

web.xml
<web-app 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-app_2_5.xsd"
          version="2.5">    

    <display-name>MyApp</display-name>

    <welcome-file-list>
        <!-- welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file> -->
        <welcome-file>/WEB-INF/jsps/menu.jsp</welcome-file> 
    </welcome-file-list>

    <filter>
        <description>SSOAuthFilter</description>
        <filter-name>SSOAuthFilter</filter-name>
        <filter-class>auth.system.SSOAuthFilter</filter-class>
        <!-- this parameter is added from 2.1.1-SNAPSHOT and is optional -->
        <!-- init-param>
            <param-name>exclude</param-name>
            <param-value>.*index.*</param-value>
        </init-param-->
    </filter>


    <filter-mapping>
        <filter-name>SSOAuthFilter</filter-name>
        <url-pattern>/myApp</url-pattern>
        <dispatcher>REQUEST</dispatcher>
    </filter-mapping>

    <servlet>
        <servlet-name>mvc-dispatcher</servlet-name>
        <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>mvc-dispatcher</servlet-name>
        <url-pattern>/myApp/*</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
    </context-param>

    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>


    <servlet>
        <servlet-name>SSOLogoutServlet</servlet-name>
        <servlet-class>auth.system.SSOLogoutServlet</servlet-class>    
    </servlet>
    <servlet-mapping>
        <servlet-name>SSOLogoutServlet</servlet-name>
        <url-pattern>/logout</url-pattern>
    </servlet-mapping>

</web-app>

Any help is very appreciated. 
Thank you in advance!

A: If you are using @Autowired annotation make sure that beans are initialized by spring container. You can create bean by  <bean id="test" class="com.demo.Test"></bean>or just provide the package name to context: component-scan tag to say that Spring has to scan package searching the stereotype annotations and register beans within the application context.

A: On the post: Error deploying WAR file to Jboss EAP 6.0, which works under JBOSS AS 7.1
I found the advice to startup with the command as below:
standalone.sh -Dorg.jboss.as.logging.per-deployment=false

Doing that, I could see the real cause:
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not
 autowire field: private packages.StudentSearchDao packages.studentSearchDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException
: No qualifying bean of type [packages.StudentSearchDao] found for dependency: expected at
 least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

So, I added the "@Qualifier" after the @Autowired, as below:
@Autowired @Qualifier("studentSearchDaoImpl") 
private StudentSearchDao studentSearchDao;

