Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
Injecting @Autowired & @PersistenceContext NullPointer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting @Autowired & @PersistenceContext NullPointer

    Hi everyone,

    I've been having some problem with a webapp deployed using spring-dm web extender. The issue is that @Autowired and @PersistenceContext seems to be ignored by spring-dm entirely.

    I have enabled annotation scanning within the bundle by including
    Code:
    <bean class="org.springframework.osgi.extensions.annotation.ServiceReferenceInjectionBeanPostProcessor"/>
    But it doesn't seem to help, so I tried to create a fragment bundle to config the Extender

    XML annotation.xml in META-INF/spring:
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd">
    
        <bean id="extenderProperties" class="java.util.Properties">
            <property name="process.annotations" value="true"/>
        </bean>
    </beans>
    and MANIFEST.MF
    Code:
    Fragment-Host: org.springframework.bundle.osgi.extender
    I can see the config bundle resolves and attached to extender bundle but I got the following on the log:
    Code:
    21/08/2008 14:05:39 org.springframework.osgi.extender.internal.support.ExtenderConfiguration <init>
    INFO: No custom extender configuration detected; using defaults...
    21/08/2008 14:05:39 org.springframework.scheduling.timer.TimerTaskExecutor afterPropertiesSet
    INFO: Initializing Timer
    21/08/2008 14:05:39 org.springframework.osgi.extender.internal.activator.ContextLoaderListener addDefaultPostProcessors
    INFO: Disabled automatic Spring-DM annotation processing
    Which seem to suggest the configuration is ignored.

    Any help would be greatly appreciated.

    Thanks,

    Kevin

  • #2
    I've noticed another thread that had a similar situation as mine, is it possible there is a bug in the dm extender version 1.1.1 that prevents extender config bundles from loading?

    Can anyone successfully deployed a config bundle for the extender share their experience here?

    Comment


    • #3
      Stupid me, just realized that the annotation.xml and its location is totally wrong.

      The file should sit in META-INF/spring/extender directory.

      Contents are
      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://www.springframework.org/schema/beans
             http://www.springframework.org/schema/beans/spring-beans.xsd">
      
          <bean id="extenderProperties" class="java.util.Properties">
              <constructor-arg>
                  <props>
                      <prop key="process.annotations">true</prop>
                  </props>
              </constructor-arg>
          </bean>
      </beans>
      However I am now getting the following error:
      Code:
      22/08/2008 12:00:17 org.springframework.osgi.extender.internal.support.ExtenderConfiguration addDefaultDependencyFactories
      WARNING: Spring-DM annotation package not found, annotation processing disabled.
      java.lang.ClassNotFoundException: ANNOTATION FACTORY
              at java.lang.ClassLoader.findClass(ClassLoader.java:358)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
              at org.eclipse.osgi.framework.internal.core.BundleLoader.findClassInternal(BundleLoader.java:429)
      Which is weird because I have the extension annotation bundle loaded:

      Code:
      13      ACTIVE      org.springframework.bundle.osgi.extender_1.1.1
                          Fragments=74
      14      ACTIVE      org.springframework.bundle.osgi.extensions.annotations_1.1.1
      Can anyone shed any lights?

      Thanks,

      Kevin

      Comment


      • #4
        I did a little more digging into the code the class not found exception came from:

        Line 302-303 of class ExtenderConfiguration

        Code:
        annotationProcessor = Class.forName(ANNOTATION_DEPENDENCY_FACTORY, false, ExtenderConfiguration.class.getClassLoader());
        Where ANNOTATION_DEPENDENCY_FACTORY is a
        Code:
        private static final String ANNOTATION_DEPENDENCY_FACTORY = "ANNOTATION FACTORY";
        Does anyone know where the ANNOTATION_DEPENDENCY_FACTORY is supposed to be initialized?

        Thanks,

        Kevin

        Comment


        • #5
          The ANNOTATION_DEPENDENCY_FACTORY is not properly initialized - this is a bug that can be tracked here:
          http://jira.springframework.org/browse/OSGI-613
          As for your initial question, to use Spring annotations (and not Spring-DM's extension annotation), you simply use the Spring schema tags.
          If it's possible, take a look in the trunk and you'll see an MVC application, using @Autowired and @Controller.
          Hope this helps,

          Comment

          Working...
          X