Can't Make/compile or run my project (eclipse user transitioning to IDEA)

This is my third attempt to replace eclipse as my IDE and buy a personal license for Idea. Each time, I remember, I got stuck unable proceed with basic dev tasks and gave up and went back to eclipse.

I've been an eclipse and mac user for seven years.

I'm working on a multi-module maven project which uses the entire Spring stack. There's Spring Roo, so AspectJ is being used as a post-compile hook through a maven plugin. I'm a heavy eclipse user and as such SpringSource Tool Suite has worked well. When I created a new project in IDEA (from existing sources using maven) , code completion, refactoring, etc worked well. However, I can't get to "Make" the project. I can't run unit test by right clicking on a source file because it has to "Make" and it can't make. I can't "Run." I can't even deploy to a Tomcat 6 server that I configured very clearly in the preferences section. I verified the project structure, modules and source and library paths -- everything looks fine.

What are the errors? Well, IDEA doesn't understand the classpath and shows errors on every class ("import can't be resolved"). I've used both ajc and eclipse compiler in the settings, nothing changed. And sometimes, there's an issue with Roo entities being identified since IDEA doesn't know how to compile them. Yes, I had Roo plugin installed.

Any suggestions?

---------------
-- IntelliJ 10.5 Ultimate trial version
-- Mac, JDK 6
-- Spring Stack 3.x,  Roo, AspectJ, JPA/Hibernate, Maven

23 comments
Comment actions Permalink

Have you made sure that the project is imported correctly?
The maven tool window on the right of the editor should help.
What happens if you execute the tasks from there?

Are all your dependencies downloaded?

Is your project open source?
Its a bit easier to answer some things like this by looking at the project directly.

0
Comment actions Permalink

Have you made sure that the project is imported correctly?

-- yes, I suppose.

The maven tool window on the right of the editor should help.
What happens if you execute the tasks from there?
-- Maven tasks work just fine. No errors. So it looks like my setup is fine, right?


Are all your dependencies downloaded?
-- Yes; fact that I can run maven builds inside and outside of the IDE.

Is your project open source?
-- No. I wish.

Please let me know if there's anything I need to know how to troubleshoot.

0
Comment actions Permalink

Do you have an JDK configured for your project (File | Project Structure | Project | Project SDK) ?
Have you verified Ajc works (File | Settings | Compiler | Java Compiler | Test) ?
(Eclipse compiler won't build your projects as it doesn't contain AJDT).

1
Comment actions Permalink

Yes & Yes.

I now get this error again (and the several trivial compile errors):

can't determine annotations of missing type javax.persistence.Entity

It seems it was an issue raised on Spring forums but I'm not sure if I'd like to make changes to my existing poms just to make an IDE happy. As mentioned in the original thread, this works fine via mvn cmd line and eclipse/Springsource toolsuite.

Suggestions?

0
Comment actions Permalink

Just to be sure: does the error persist on full project rebuild (Build | Rebuild Project) ?

0
Comment actions Permalink

When I rebuild my project I get the same error:

can't determine annotations of missing type javax.persistence.Entity

0
Comment actions Permalink

Ok, then it should be a bug :)
Which versions of Spring (the framework), Roo, and AspectJ do you use?
Could you please also post <plugin> section for aspectj-maven-plugin from pom.xml?

0
Comment actions Permalink

<properties>
      <environment.type>local</environment.type>
      <aspectj.version>1.6.11.RELEASE</aspectj.version>
      <hibernate.version>3.6.1.Final</hibernate.version>
      <spring.version>3.0.5.RELEASE</spring.version>
      <spring.batch.version>2.1.7.RELEASE</spring.batch.version>
      <spring.batch.admin.version>1.2.0.RELEASE</spring.batch.admin.version>
      <spring.integration.version>2.0.3.RELEASE</spring.integration.version>
      <spring.security.version>3.0.5.RELEASE</spring.security.version>
      <spring.webflow.version>2.2.1.RELEASE</spring.webflow.version>
      <joda-time.version>1.6.2</joda-time.version>
      <mockito-all.version>1.8.5</mockito-all.version>
      <junit.version>4.8.2</junit.version>
      <java.source.version>1.6</java.source.version>
      <java.target.version>1.6</java.target.version>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <dependency.locations.enabled>false</dependency.locations.enabled>
      <maven.test.failure.ignore>false</maven.test.failure.ignore>
      <slf4j.version>1.6.1</slf4j.version>
      <jetty.version>6.1.22</jetty.version>
 </properties>


parent pom.xml

<build>
     ...
     ....
     ...

          <!-- AspectJ Support Parent -->
                    <plugin>
                       <groupId>org.codehaus.mojo</groupId>
                       <artifactId>aspectj-maven-plugin</artifactId>
                       <version>1.0</version>
                       <dependencies>
                           <!-- NB: You must use Maven 2.0.9 or above or these are ignored (see MNG-2972) -->
                           <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>
                       <executions>
                           <execution>
                               <goals>
                                   <goal>compile</goal>
                                   <goal>test-compile</goal>
                               </goals>
                           </execution>
                       </executions>
                       <configuration>
                           <outxml>true</outxml>
                           <aspectLibraries>
                               <aspectLibrary>
                                   <groupId>org.springframework</groupId>
                                   <artifactId>spring-aspects</artifactId>
                               </aspectLibrary>
                           </aspectLibraries>
                           <source>1.6</source>
                           <target>1.6</target>
                       </configuration>
                    </plugin>
                    <plugin>
                       <groupId>org.apache.maven.plugins</groupId>
                       <artifactId>maven-eclipse-plugin</artifactId>
                       <!-- Note 2.8 does not work with AspectJ aspect path -->
                       <configuration>
                           <downloadSources>true</downloadSources>
                           <downloadJavadocs>false</downloadJavadocs>
                           <wtpversion>2.0</wtpversion>
                           <additionalBuildcommands>
                               <buildCommand>
                                   <name>org.eclipse.ajdt.core.ajbuilder</name>
                                   <arguments>
                                       <aspectPath>org.springframework.aspects</aspectPath>
                                   </arguments>
                               </buildCommand>
                               <buildCommand>
                                   <name>org.springframework.ide.eclipse.core.springbuilder</name>
                               </buildCommand>
                           </additionalBuildcommands>
                           <additionalProjectnatures>
                               <projectnature>org.eclipse.ajdt.ui.ajnature</projectnature>
                               <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                           </additionalProjectnatures>
                       </configuration>
                    </plugin>

                </plugins>

                <pluginManagement>
                    <plugins>
                        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                        <plugin>
                            <groupId>org.eclipse.m2e</groupId>
                            <artifactId>lifecycle-mapping</artifactId>
                            <version>1.0.0</version>
                            <configuration>
                                <lifecycleMappingMetadata>
                                    <pluginExecutions>
                                        <pluginExecution>
                                            <pluginExecutionFilter>
                                                <groupId>
                                                    org.codehaus.mojo
                                                </groupId>
                                                <artifactId>
                                                    aspectj-maven-plugin
                                                </artifactId>
                                                <versionRange>
                                                    [1.0,)
                                                </versionRange>
                                                <goals>
                                                    <goal>compile</goal>
                                                    <goal>test-compile</goal>
                                                </goals>
                                            </pluginExecutionFilter>
                                            <action>
                                                <ignore></ignore>
                                            </action>
                                        </pluginExecution>
                                    </pluginExecutions>
                                </lifecycleMappingMetadata>
                            </configuration>
                        </plugin>
                    </plugins>
             </pluginManagement>
     </build>

0
Comment actions Permalink

Sorry, forgot to ask about version of spring-aspects.

0
Comment actions Permalink

It's same as spring version (3.0.5)

0
Comment actions Permalink

Well... so far I still not succeed in reproducing the failure. I.e. in my tests compilation either fails in both Maven and IDEA, or passes in both.

As it's all true that spring-aspects requires JPA in a classpath in order to compile, the reason may be in your project's compilation settings (e.g. one of the modules uses javac instead of ajc for compile goal - such configuration isn't yet supported by IDEA). Or may be there was a bug at a project import (so that Maven provides a JPA to all modules' classpath but IDEA doesn't).

I'm afraid I can't say more without seeing actual pom.xml files.

0
Comment actions Permalink

Which pom files would you want me to share exactly?

Here's the aspectj parent module that other aspectj projects included.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>xyz-aspectj-parent</artifactId>
    <name>XYZ AspectJ Parent</name>
    <description>XYZ parent project for modules that need aspectj support</description>
    <packaging>pom</packaging>

    <parent>
        <artifactId>xyz-parent</artifactId>
        <groupId>com.xyz</groupId>
        <version>1.0.0-SNAPSHOT</version>
        <relativePath>../xyz-parent/pom.xml</relativePath><!– empty to workaround 3.0.x warning: see
            http://jira.codehaus.org/browse/MNG-4687 –>
    </parent>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>1.0</version>
                <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>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <outxml>true</outxml>
                    <aspectLibraries>
                        <aspectLibrary>
                            <groupId>org.springframework</groupId>
                            <artifactId>spring-aspects</artifactId>
                        </aspectLibrary>
                    </aspectLibraries>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-eclipse-plugin</artifactId>
                <!– Note 2.8 does not work with AspectJ aspect path –>
                <configuration>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>false</downloadJavadocs>
                    <wtpversion>2.0</wtpversion>
                    <additionalBuildcommands>
                        <buildCommand>
                            <name>org.eclipse.ajdt.core.ajbuilder</name>
                            <arguments>
                                <aspectPath>org.springframework.aspects</aspectPath>
                            </arguments>
                        </buildCommand>
                        <buildCommand>
                            <name>org.springframework.ide.eclipse.core.springbuilder</name>
                        </buildCommand>
                    </additionalBuildcommands>
                    <additionalProjectnatures>
                        <projectnature>org.eclipse.ajdt.ui.ajnature</projectnature>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.codehaus.mojo
                                        </groupId>
                                        <artifactId>
                                            aspectj-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.0,)
                                        </versionRange>
                                        <goals>
                                            <goal>compile</goal>
                                            <goal>test-compile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

0
Comment actions Permalink

Is it possible for you to attach an archive with all POMs of the project? Or at least the POM of the module which fails to compile.

0
Comment actions Permalink

What is your email id and WHAT files do you want me to bundle for investigation?

Sorry, I can't put all my code on public domain since it's a financial company.

This is a sumary:

1) I can't run a test or debug inside IntelliJ since it has to 'Make' and I don't understand why intelliJ can't simply look at maven for build (why is this hard to configure?)
   I get the following error:

can't determine annotations of missing type javax.persistence.Entity

on all my domain objects (since they're configured using Spring Roo).

2) I followed the instructions on a Spring JIRA and included the following in the respective module's pom.

<dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>persistence-api</artifactId>
         <version>1.0</version>
         <scope>provided</scope>
       </dependency>  


I STILL get the same error.

I've already written over 10 posts detailing the problem and I'm losing my patience.

Thanks.
0
Comment actions Permalink

My email is in the profile.

I didn't asked for any of your code at all. What's needed to reproduce the problem is a structure of your project - i.e. modules and their dependencies. The structure is fully described in pom.xml files. That's all what I've asked for.

Alternatively, you can create a sample project which reproduces the problem.

1) Actually, you can. In your run/debug configurations (Before Launch section) you can un-check Make checkbox and pick Run Maven Goal.

2) I would love to help - but as I said I need more info.

0
Comment actions Permalink

I downloaded 11 EAP beta version and the problem still persists.

It is clear to me that InteliJ doesn't support Aspectj projects with Maven. The rest of the IDE works great. But without AspectJ support, I can't recommend this product or buy a commerical license.

Please update your licence and/or documentation stating clearly your limitation so other prospective buyers are aware of this issue.

0
Comment actions Permalink

Easy now! Lets not be so hasty!

Start from a simple example.
e.g. http://www.mkyong.com/spring3/spring-aop-aspectj-annotation-example/

You need to add this to the pom so that maven compiles it correctly.

 <build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>2.0.2</version>
      <configuration>
        <source>1.6</source>
        <target>1.6</target>
      </configuration>
    </plugin>
  </plugins>
</build>


Then try running com.mkyong.core.App#main

It worked fine for me, which show that Intellij does support Aspectj projects with Maven. :p

Can you try and duplicate the problem that you are seeing in a similarly simple project (so you don't have to share your private code)?

0
Comment actions Permalink

GOOD NEWS.

It works.

What happened? Seems like the same issue Roman had been suggesting:

- Deleted EVERYTHING.
- RE-INSTALLED IntelliJ 11 EAP
- Reimported multi maven module from scratch
- {make sure maven-compiler-plugin = 1.6 in parent pom} ==> in my case it was correct.
- Change the Project Settings->Project->Project Language Level == <6.0>
  {make sure you double check project and module each time. Sometimes, IntelliJ changes this on reload!}

What surprises me is I have DONE these steps each time in 10.5 -- and it's embarassing to find out it works now.

I've tested this in 11 EAP and it works. In 10.5, I had AspectJ weaver plugin so that probably explains why it wasn't working there.

Anyway, hopefully someone else will find this thread useful.

Thank you, all.

I'll take my frustration out and buy a license now :)

0
Comment actions Permalink

After a few days, this problem has resurrected BACK.

- Maven builds the project successfully.
- Idea Project settings has always been set to 6.0 and Maven parent pom compiler settings is set to 6.0 and this has NEVER CHANGED.
- Idea 11 EAP with default plugins. Currently I see it's bundled with 1)Aspectj Support and 2)Spring AOP & AspectJ support
- This problem occurs inconsistently as new aspectJ source files are added/modified.

See sample error below:
(code obfuscated/reduced for privacy)


Information:Compilation completed with 69 errors and 24 warnings
Information:69 errors
Information:24 warnings
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.Activity [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.AddressChange [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.PhoneCall [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.ClaimantAddress [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.Check [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.Letter [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.Payment [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.AlternatePayeeActivity [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.CheckActivity [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.ContactChange [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.NameChange [Xlint:typeNotExposedToWeaver]
Warning:this affected type is not exposed to the weaver: xxx.domain.activity.TaxInfoChange [Xlint:typeNotExposedToWeaver]
Warning:advice defined in org.springframework.orm.jpa.aspectj.JpaExceptionTranslatorAspect has not been applied [Xlint:adviceDidNotMatch]
Warning:advice defined in org.springframework.scheduling.aspectj.AbstractAsyncExecutionAspect has not been applied [Xlint:adviceDidNotMatch]
Warning:advice defined in org.springframework.mock.staticmock.AnnotationDrivenStaticEntityMockingControl has not been applied [Xlint:adviceDidNotMatch]
Warning:advice defined in org.springframework.mock.staticmock.AbstractMethodMockingControl has not been applied [Xlint:adviceDidNotMatch]
xxx/foo-domain/src/main/javaxxx/activity/AddressResearchChangeActivity_Roo_JavaBean.aj
    Warning:Warning:line (12)this affected type is not exposed to the weaver: xxx.domain.activity.AddressResearchChangeActivity (needed for privileged access) [Xlint:typeNotExposedToWeaver]
    Warning:Warning:line (20)this affected type is not exposed to the weaver: xxx.domain.activity.AddressResearchChangeActivity (needed for privileged access) [Xlint:typeNotExposedToWeaver]
    Warning:Warning:line (28)this affected type is not exposed to the weaver: xxx.domain.activity.AddressResearchChangeActivity (needed for privileged access) [Xlint:typeNotExposedToWeaver]
    Warning:Warning:line (36)this affected type is not exposed to the weaver: xxx.domain.activity.AddressResearchChangeActivity (needed for privileged access) [Xlint:typeNotExposedToWeaver]
    Warning:Warning:line (44)this affected type is not exposed to the weaver: xxx.domain.activity.AddressResearchChangeActivity (needed for privileged access) [Xlint:typeNotExposedToWeaver]
xxx/foo-domain/src/main/java/xxx/domain/Claimant.java
    Error:Error:line (217)The method getAddresses() is undefined for the type Claimant
    Error:Error:line (226)The method getAddresses() is undefined for the type Claimant
    Error:Error:line (234)The method getAddresses() is undefined for the type Claimant
    Error:Error:line (242)The method getAddresses() is undefined for the type Claimant
    Error:Error:line (254)The method getAddresses() is undefined for the type Claimant
    Error:Error:line (279)The method getPhoneCall() is undefined for the type Claimant
    Error:Error:line (294)The method getPhoneCall() is undefined for the type Claimant
    Error:Error:line (300)The method getActivity() is undefined for the type Claimant
    Error:Error:line (308)The method getPayments() is undefined for the type Claimant
    Error:Error:line (342)The method getPayments() is undefined for the type Claimant
    Error:Error:line (346)The method getPayments() is undefined for the type Claimant
    Error:Error:line (349)The method getPayments() is undefined for the type Claimant
    Error:Error:line (352)The method getPayments() is undefined for the type Claimant
    Error:Error:line (354)The method getPayments() is undefined for the type Claimant
    Error:Error:line (371)The method getReferenceNo() is undefined for the type Claimant
    Error:Error:line (376)The method getActivity() is undefined for the type Claimant
    Error:Error:line (474)The method setClaimant(Claimant) is undefined for the type Contact
    Error:Error:line (483)The method getId() is undefined for the type Claimant
    Error:Error:line (484)The method getId() is undefined for the type Claimant
    Error:Error:line (490)The method getId() is undefined for the type Claimant
    Error:Error:line (491)The method getId() is undefined for the type Claimant
    Error:Error:line (501)The method entityManager() is undefined for the type Claimant
    Error:Error:line (501)The method getId() is undefined for the type Claimant
    Error:Error:line (508)The method getId() is undefined for the type Claimant
    Error:Error:line (508)The method entityManager() is undefined for the type Claimant
    Error:Error:line (509)The method entityManager() is undefined for the type Claimant
xxx/foo-domain/src/main/java/xxx/domain/Contact.java
    Error:Error:line (64)The method setName(Name) is undefined for the type Contact
    ...
    ...
    ...



The issues reported are on JavaBean accessor methods, currently present in Spring Roo (@RooJavaBean, @RooEntity) generated domain classes. Again, this compiles via Maven.

In addition, IDEA continues to label the AspectJ JavaBean accesor methods as errros.

Seems to me, AspectJ compilation in Idea is still BROKEN and has to be tested fully to consider ALL cases.

It's hard for me to simulate this in a dedicated example (as I have a 100k+ multi module project) but I'll be glad to assist your team to debug this issue in any other way possible.

0
Comment actions Permalink

After troubleshooting, I think I know what's happening.

1) Module A: aspectj files are modified
2) Module B (as aspectj too) is dependent on A. intelliJ can no longer compile aspectJ classes
3) run maven install (parent pom) via console --> doesnt work.
4) run mvn install (parent pom) in IntelliJ --> WORKS

Is this the desired functionality to compile aspectJ files? That is, to run the ntire

FYI, Eclipse has a very useful feature of adding dependent projects on the classpath of other modules thus removing this redundant step of building the entire project (18 modules)

Still, why IntelliJ doesn't recognize the target classes if build outside IntelliJ ... beats me.

Hope this helps.

0
Comment actions Permalink

Sorry for being quite for a while.

You're right, sometimes IDEA doesn't compile AspectJ projects right. Workaround for this is to rebuild a project.
It's a known problem and I'm going to fix this soon. You can monitor this issue for progress.

0
Comment actions Permalink

In IDEA it works (well, at least should work) same way: if you have a module B which depends on module A then A's output path is included in -classpath when compiling B.

0

Please sign in to leave a comment.