Announcement Announcement Module
Collapse
No announcement yet.
Compile-time weaving not working spring mvc - hibernate Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Compile-time weaving not working spring mvc - hibernate

    Hi,

    I've been using compile-time weaving for a while now to get some spring components into a Hibernate component.

    PHP Code:
    @Configurable
    public class MultiLingualClassBridge implements FieldBridge,ParameterizedBridge {

        @
    Inject
        MessageSource messages

    Unfortunately, this was a part of the application not well supported by tests and I'm finding it suddenly not working and I'm not sure what I could have changed to create this situation.

    "Not working" meaning: the aspect gets woven (I decompiled the class to check) however, at runtime, the MessageSource doesn't get injected.

    I use Maven to weave the aspect:

    PHP Code:
    <plugin>
                    <
    groupId>org.codehaus.mojo</groupId>
                    <
    artifactId>aspectj-maven-plugin</artifactId>
                    <
    version>1.4</version>

                    <
    executions>
                        <
    execution>
                            <
    phase>process-classes</phase>
                            <
    goals>
                                <
    goal>compile</goal>
                                <
    goal>test-compile</goal>
                            </
    goals>
                        </
    execution>
                    </
    executions>
                    <
    dependencies>
                        <
    dependency>
                            <
    groupId>org.aspectj</groupId>
                            <
    artifactId>aspectjrt</artifactId>
                            <
    version>${aspectj.version}</version>
                        </
    dependency>
                        <
    dependency>
                            <
    groupId>org.aspectj</groupId>
                            <
    artifactId>aspectjtools</artifactId>
                            <
    version>${aspectj.version}</version>
                        </
    dependency>
                    </
    dependencies>
                    <
    configuration>
                        <
    source>1.6</source>
                        <
    target>1.6</target>
                        <
    verbose>true</verbose>
                        <
    complianceLevel>1.6</complianceLevel>
                        <
    encoding>UTF-8</encoding>
                        <
    showWeaveInfo>true</showWeaveInfo>
                        <
    forceAjcCompile>true</forceAjcCompile>
                        <
    aspectLibraries>
                            <
    aspectLibrary>
                                <
    groupId>org.springframework</groupId>
                                <
    artifactId>spring-aspects</artifactId>
                            </
    aspectLibrary>
                        </
    aspectLibraries>
                        <
    weaveDirectories>
                            <
    weaveDirectory>${project.build.directory}/unwoven-classes</weaveDirectory>
                        </
    weaveDirectories>

                    </
    configuration>

                </
    plugin
    I'm using Spring 3.1.2, Hibernate 4.2.1 and Hibernate Search 4.2.0, aspect 1.6.11. I tried upgrading to the latest version of Hibernate and aspectj, but the same problem persists.

    applicationContext.xml

    PHP Code:
    [...]
    <
    context:spring-configured />

        <!-- 
    Activates scanning of @Autowired -->
        <
    context:annotation-config/>

        <
    context:component-scan
            base
    -package="nl.project"/> 
    I'm not sure how to debug this issue. Any pointers are appreciated.

    Kind regards,
    Marc

  • #2
    Please check the following link ,it may be helpfull

    http://nurkiewicz.blogspot.in/2009/1...rticipate.html

    Comment


    • #3
      What I've found to be a ymptom of the problem:
      BeanConfigurerSupport.setBeanFactory is called *after* BeanConfigurerSupport.configureBean, which leaves the to be injected element null.

      This seems to do the trick

      PHP Code:
      <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean" depends-on="org.springframework.context.config.internalBeanConfigurerAspect"
      Last edited by mschipperheyn; Jul 3rd, 2013, 09:20 AM.

      Comment

      Working...
      X