7

I've inherited a huge maven java project and can't get it to compile.

mvn compile 

Its telling me it can't find a class even though its right there in the local repo.

Failed to execute goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:assemble (default) on project VCWH_Core_QueryService: Execution default of goal org.codehaus.enunciate:maven-enunciate-plugin:1.25:assemble failed: A required class was missing while executing org.codehaus.enunciate:maven-enunciate-plugin:1.25:assemble: com/sun/mirror/apt/AnnotationProcessorFactory 

Here is the pom.xml snippet that tells it where to look:

 <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.7</version> </dependency> 

And sure enough, tools-1.7.jar and tools-1.7.pom are located in the local repo at

\.m2\repository\com\sun\tools\1.7

And if I look inside the jar with jar tf tools-1.7.jar I can see class

com/sun/mirror/apt/AnnotationProcessorFactory.class

I also blew away the sun folder in my local repo and did a "Clean and Build" in NetBeans and watched the sun folder come back into my local repo, so I know the connectivity to the remote repo is good.

Why can't it find it?

6 Answers 6

2

The jar file is located in the wrong folder compared to the coordinates you are using for the dependency. Maven would not look in your location. The correct path would be .m2/repository/com/sun/mirror/apt/apt-mirror-api/0.1/apt-mirror-api-0.1.jar.

The local repository you have created is invalid. I would suggest to instead use a repository manager like Nexus and upload the jars there and then get Maven to download from there. This way you get pom files created and the structure will be automatically correct compared to the GAV coordinates you use.

Sign up to request clarification or add additional context in comments.

2 Comments

small correction: the version is missing .m2/repository/com/sun/mirror/apt/apt-mirror-api/0.1/apt-mirror-api-0.1.jar
I just typed the path wrong in the post. Just fixed it. I slept on the problem last night and came to a similar conclusion. One of the repos it pulls from is a nexus so I'll see if I can upload to it.
1

try mvn clean compile -U OR mvn clean install -U

1 Comment

Actually I'm getting a different error with mvn clean install -e -U. [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Problem assembling the enunciate app. Embedded error: com.sun.tools.apt.mirror.type.ClassTypeImpl cannot be cast to com.sun.mirror.type.AnnotationType [INFO] ------------------------------------------------------------------------ [INFO] Trace org.apache.maven.lifecycle.LifecycleExecutionException: Problem assembling the enunciate app.
1

Need to add this to the maven-enunciate-plugin:

 <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jdk1.7.0_79\lib\tools.jar</systemPath> <optional>true</optional> </dependency> </dependencies> 

Now it looks like this:

<plugin> <groupId>org.codehaus.enunciate</groupId> <artifactId>maven-enunciate-plugin</artifactId> <version>1.25</version> <configuration> <configFile>${basedir}/src/main/webapp/WEB-INF/enunciate.xml</configFile> <compileDebug>false</compileDebug> <addGWTSources>false</addGWTSources> <addActionscriptSources>false</addActionscriptSources> </configuration> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jdk1.7.0_79\lib\tools.jar</systemPath> <optional>true</optional> </dependency> </dependencies> <executions> <execution> <goals> <goal>assemble</goal> </goals> </execution> </executions> </plugin> 

And then Downgraded to java 7 from 8.

1 Comment

Downgraded to java 7 from 8 and the error went away.
1

First, double-check that you have the correct Maven coordinates in the file (groupId, artifactId and version). Look for typos.


This could be caused by a corrupt local Maven repo. You can resolve it with these steps.

Option 1:

1. On your project, right-click: Maven > Update Project

2. In the dialog, check the box: Force Update of Snapshots/Releases

3. Click Ok

Maven will perform a rebuild.

If that doesn't solve your problem then move to option 2

Option 2:

1. Delete your local Maven repo, the .m2 directory on your computer

On MS Windows

either

C:\Documents and Settings\<yourUserName>\.m2 c:\Users\<yourUserName>\.m2 

On Mac/Linux

~/.m2 

Note, on your OS, you may need to configure your OS to show hidden files.

  1. Once .m2 directory is deleted, restart Eclipse

  2. On your project, right-click: Maven > Update Project

This will resolve your issue.

Comments

0

go to your m2 repository.delete all the jars.

Do mvn clean install.

If you are using eclipse do a project clean.right click project->maven->update project.

1 Comment

I can't do that. I'm operating in offline mode using the -o option because the pom I inherited tries to access repos that no longer exist and nobody knows what replaced them. I have installed all the needed jars from the previous war file into the local repo. Why can't it find them?
0

For me the solution was:

  • Reimport all Maven projects (1)
  • Pull with rebase (2-3)
  • mvn clean install (4)

All points showed into this image

1 Comment

please post image here rather than having an link.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.