Announcement Announcement Module
No announcement yet.
Does Autowiring work in Java EE 6 and JBoss 7? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does Autowiring work in Java EE 6 and JBoss 7?

    Hello All,
    I am trying to port our application to JBoss 7 and am having issues getting Spring 2.5 autowiring working. I found that if I declare my bean manually in XML, I can see them being registered correctly. If I rely on component-scan, Spring says it's initializing Spring, but not my beans. Any tips on debugging this?

    Thanks in advance,

    PS - I just tested this in Spring 3.0 and it works exactly as expected. However, the application I am porting is huge and moving to Spring 3.0 would be a non-trivial investment, so we'd love to get it working in 2.5 for now.

    Here's my Spring config - applicationContext.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="" xmlns:xsi=""
    	xmlns:context="" xmlns:tx=""
    	<!-- Activates annotation-based bean configuration -->
    	<context:annotation-config />
    	<!-- Fails...never appears to be run. -->
    	<context:component-scan base-package="com.mycompany" />
    	<!-- Works when uncommented. -->
    	<!-- <bean class="com.mycompany.ChatterBox"/> -->
    Here's my web.xml
    <web-app xmlns="" xmlns:xsi=""
    	xsi:schemaLocation="" version="3.0">
    	<description>Our canary in a coal mine - Can we get Spring working?</description>
    Here's the bean in question.
    package com.mycompany;
    import java.util.Date;
    import javax.annotation.PreDestroy;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.stereotype.Component;
     *  Tracing class designed to output when constructed. 
    public class ChatterBox {
        private final Log logger = LogFactory.getLog(getClass());
        public ChatterBox() {
            //we want this to be very visible and easy to read.
          logger.fatal("\n\n\n\n\nSingleton was constructed at " + new Date() + " (you should only see me once)\n\n\n\n");
            if(true){//to avoid compiler error, RuntimeException used to get indisputable proof this was run.
              throw new RuntimeException("Did I get run?");
        protected void finalize2(){
            logger.warn("\n\nI was destroyed by @PreDestory on " + new Date() + "\n\n");
    Last edited by JavaGeek_Boston; Apr 19th, 2012, 03:24 PM.