This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
To reproduce (Netbeans 6.0 running on Ubuntu 2.6.22-14-generic): 1. Remove and re-add dependency (or change version number in pom.xml) In the editor window, the import statements for classes in the dependency are flagged with "package org.company.myprog does not exist". As expected, code completion does not then work for these classes. Running a clean & rebuild shows no build errors at all, but rebuilding doesn't solve the problem. In fact the only solution I have found so far is to completely uninstall Netbeans 6 (removing the hidden directories as well) and then reinstalling it. However, the next time I rebuild my dependency JAR, the problem happens again. I'm not sure if this is a Netbeans problem or a Maven IDE problem; however, the project builds fine both in Netbeans and at the command line.
Reassigning to Maven.
do you have a sample project that exhibits this behaviour? Similar stuff works for me fine. Does the "Refresh project" action on the project's popup help?
Unfortunately, I don't have a sample project I can give you as the software is commercially sensitive, but I can give you the pom.xml (below) of the project that is causing the most problems. All it contains is a single, simple xsd file, from which it builds some JAXB classes. I did have some success with it yesterday evening by: 1. removing all traces of the dependency from my local maven repository, 2. running 'mvn install' (from the command line) on the dependency 3. running the "Index Now" Options->Miscellaneous->Maven 2 to re-scan the repository 4. re-adding the dependencies After that, whenever I changed stuff in my xsd file in the dependency, I just needed to re-run the 'mvn install' and then re-scan the repository in Netbeans. That worked consistently for the rest of yesterday evening, but this morning I fired up Netbeans only to find red squiggly lines under my import statements in every project that depends on that project. One thing I noticed that was very odd - if I just remove (as in 'delete') the local repository entry and then re-scan, the dependencies have a red minus sign to indicate that they're missing, I get those red squiggly lines underneath the lines of code that make calls to classes in the dependency, but I don't necessarily get any errors for the import statements. This is why I think it's a Netbeans editor problem, rather than a Maven IDE problem. It's as if whatever parses the import statements to check the packages exist is having problems detecting what's in the libraries area. ---- pom.xml ---- <?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> <groupId>net.rockshore.cdm.messaging</groupId> <artifactId>CDMMessaging</artifactId> <packaging>jar</packaging> <version>0.3-SNAPSHOT</version> <name>CDMMessaging project</name> <url>http://maven.apache.org</url> <repositories> <repository> <id>maven2-repository.dev.java.net</id> <name>Java.net Maven 2 Repository</name> <url>http://download.java.net/maven/2</url> </repository> <repository> <id>maven-repository.dev.java.net</id> <name>Java.net Maven 1 Repository (legacy)</name> <url>http://download.java.net/maven/1</url> <layout>legacy</layout> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>maven2-repository.dev.java.net</id> <name>Java.net Maven 2 Repository</name> <url>http://download.java.net/maven/2</url> </pluginRepository> <pluginRepository> <id>maven-repository.dev.java.net</id> <name>Java.net Maven 1 Repository (legacy)</name> <url>http://download.java.net/maven/1</url> <layout>legacy</layout> </pluginRepository> </pluginRepositories> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> <scope>provided</scope> </dependency> </dependencies> <build> <directory>build</directory> <outputDirectory>build/classes</outputDirectory> <defaultGoal>package</defaultGoal> <testOutputDirectory>build/test-classes</testOutputDirectory> <sourceDirectory>src/main/java</sourceDirectory> <testSourceDirectory>src/test/java</testSourceDirectory> <plugins> <plugin> <groupId>org.jvnet.jaxb2.maven2</groupId> <artifactId>maven-jaxb2-plugin</artifactId> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <schemaDirectory>src/main/xsd</schemaDirectory> <includeSchemas> <includeSchema>**/*.xsd</includeSchema> </includeSchemas> <includeBindings> <includeBinding>*.xjb</includeBinding> </includeBindings> <strict>true</strict> <verbose>true</verbose> <generatePackage>net.rockshore.cdm.messaging.cdmmessaging</generatePackage> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build> </project>
scanning the local repository (through the Tools/Options dialog panel) shall have no effect whatoever on editor classpath just useful for dependency completion in Add Library dialog or when editing pom. the project should always reload classpath when build is run, when pom file is edited, or when the Reload project action is invoked. Is it the generated sources in project A that are marked as error in the same project or in project B that depends on A? Or is is jars from 3rd party libraries stored in local repository that are marked as error?
> Is it the generated sources in project A that are marked as error in the same project or in project B that depends on A? Just in project B. Everything builds fine, but any files in project B that refer to classes from project A contain show as containing errors in the project window. When I edit those files, there are errors under the import statements, telling me the package does not exist, and then any references further on in the code also have errors. > Or is is jars from 3rd party libraries stored in local repository that are marked as error? I don't have any problems with any 3rd party libraries (e.g. log4j, jboss, etc) or with other Maven projects. The only problem I have is with Maven projects that generate JAXB classes from an xsd.
> the project should always reload classpath when build is run, when pom file is edited, or when the Reload project action is invoked. Ah... then I think I can see the problem. First of all, the Reload project action is not causing the classpath to be reloaded... in fact it seems to do nothing at all. Secondly, if I edit the pom.xml file and remove a dependency, it disappears from the Libraries list in the Project view. Any code that relies on that dependency shows errors in the editor window (and is marked in the Project view with an exclamation mark in a red circle). However, when I add that same dependency back in exactly as it was (again, by editing the pom.xml), although it reappears in the Libraries list, the files that depend on it still show errors, both in the project view and in their respective editor windows. Neither running a build nor reloading the project fixes this problem, even though the builds still complete successfully. Now my project appears to have errors in it and, most inconveniently, I can't use the auto code completion for anything that is related to the dependencies it thinks are missing.
duplicate of #128326 *** This issue has been marked as a duplicate of 128326 ***