10

I seem to get a bunch of warnings like this when I make my Spring project. The project uses Compile Time Weaving and various Spring annotations like Transactional, Autowired, and Configurable.

I have three questions: What are they (What's the effect)? Should I be concerned about them? and "What can I do to remove them?"

ajc: this affected type is not exposed to the weaver: com.myapp.domain.UserEntity [Xlint:typeNotExposedToWeaver]

Let me know what you need to help me solve this issue. I can post relevant parts of the POM file, parts of my Java Spring Configuration files, or whatever. I dont' really know what is required so let me know.

I saw it on the spring forum but that place is a ghost town. Several people have asked this question but there are no answers.

I am using Java Configuration for Spring and CTW.

robert_difalco
  • 4,821
  • 4
  • 36
  • 58
  • 2
    I'm starting to get the idea that it has to do with make verses clean builds. Maybe something with binary types not being accessible to the compile time weaver and it accessing the jars instead of the source? I get different sets of these warnings all the time it seems. – robert_difalco May 11 '13 at 23:33

2 Answers2

7

What are they (What's the effect)?

It (ajc) is saying that it has found some class that it thinks ought to be or to have been "woven", but that can't be done / hasn't been done.

Should I be concerned about them?

Yes. It would mean that the AspectJ compile time weaving won't happen properly; i.e. the annotations on some classes won't take effect.

What can I do to remove them?

Change your build configs so that the weaver can find all of the code it needs to weave.

I'm guessing that your application involves multiple Maven modules. If so, then this Answer has some links to the relevant Eclipse/AspectJ and Maven documentation: https://stackoverflow.com/a/13120709/139985. It seems that the AspectJ Maven plugin needs to be explicitly told where to look for stuff.

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • Thanks @Stephen C. As far as I can tell I don not have multiple modules. However, spring has a jar of spring-aspects. I *think* those have to use load time weaving since they come as a jar. Could this be part of the issue? – robert_difalco May 11 '13 at 23:44
  • It could be. But note that it is complaining about one of your classes, not a class in the spring-aspects JAR file. – Stephen C May 12 '13 at 03:26
  • I'm not sure why it can't find them. It is a standard mvn layout. /src/main/java and so on. I have NO .aj files in my project. Just the spring aspects jar. – robert_difalco May 12 '13 at 18:47
  • 1
    in particular, the link from @StephenC above provided me the answer I needed, namely, modifying the configuration of the aspectj maven plugin. – icfantv Jan 30 '14 at 19:47
1

I had a similar problem. On closer inspection, I realized that the warnings were happening during the test-compile phase only, where aspectj was not smart enough to automatically look in the main java source directory as well as in the test source directory. I solved it by splitting the two goals into separate executions, with different configurations. The relevant part of the POM is given below:

        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <version>1.10</version>
        <configuration>
          <complianceLevel>1.8</complianceLevel>
          <aspectLibraries>
            <aspectLibrary>
                <groupId>org.springframework</groupId>
                <artifactId>spring-aspects</artifactId>
            </aspectLibrary>
          </aspectLibraries>
          <source>1.8</source>
          <target>1.8</target>  
        </configuration>
        <executions>
          <execution>
            <id>compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <!-- add explicit instructions for test compile or it can't weave main src classes -->
          <execution>
            <id>test-compile</id>
            <configuration>
                <goals>
                    <goal>test-compile</goal>           
                    <sources>
                        <basedir>${project.basedir}</basedir>
                        <includes>
                            <include>src/main/java/**/*.java</include>
                            <include>src/test/java/**/*.java</include>
                        </includes>
                    </sources>
                </goals>
            </configuration>
        </execution>
        </executions>
    </plugin>
Erica Kane
  • 3,137
  • 26
  • 36