[ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=comments#action_55491 
] 

Roland Klein commented on MNGECLIPSE-25:
----------------------------------------

Hello,

this behavior results from a corrupt tarball i got from ViewCVS, some filenames 
were changed in that way that the extensions are not longer .java. So this 
files weren't compiled. I just changed the filenames back to .java and 
everything ist working fine.

I think especially the Maven2ClasspathContainerInitializer.java file makes this 
trouble because no initialization took place.
There were also some ClassCastExceptions during my testing, but after changing 
the filenames and rebuilding no exceptions anymore.

Roland

> Enable Maven in project causes ClassCastException
> -------------------------------------------------
>
>          Key: MNGECLIPSE-25
>          URL: http://jira.codehaus.org/browse/MNGECLIPSE-25
>      Project: Maven 2.x Plug-in for Eclipse
>         Type: Bug

>  Environment: WIN2K, Eclipse 3.1, JDK 1.5
>     Reporter: Roland Klein
>     Assignee: Eugene Kuleshov
>  Attachments: pzFileReader.zip, src.zip
>
>
> Hello,
> i encounter some problem with the eclipse plugin, when i enable Maven2 for a 
> particular project.
> In the eclipse log are three entries and one of them says that there is a 
> ClassCastException in Maven2Builder.java line 52
> 52: Maven2ClasspathContainer container = ( Maven2ClasspathContainer ) 
> JavaCore.getClasspathContainer( path, project );
> sometimes i got a NPE in the same class line 54, then the variable container 
> is not initialized.
> 54: JavaCore.setClasspathContainer( container.getPath(), new IJavaProject[] { 
> project }, new IClasspathContainer[] { new Maven2ClasspathContainer( entries 
> ) }, monitor );
> After debugging i can say that the method JavaCore.getClasspathContainer() 
> returns a JavaModelManager when you just started eclipse and causes the 
> ClassCastExceptions, but I don't know if we can ignore it.
> I tried to fix this problem, but i don't know the eclipse API very well. So i 
> post it here in the hope someone can use and improve it.
> Then i encounter a problem with MavenEmbedder and i changed the 
> maven-embedder-2.0-beta-4-SNAPSHOT-dep.jar to maven-embedder-2.0.1-dep.jar 
> and rebuild the plugin.
> This problem occurs, everytime i change the pom.xml by hand then the project 
> rebuilds but MavenEmbedder is still running and claims there is a duplicate 
> projectId  in pom.xml. Then i inserted in 
> Maven2Plugin.resolveClasspathEntries() a call to resetMavenEmbedder() before 
> it is got through getMavenEmbedder(), this fixes the problem, but i thing 
> this is shooting with canons on birds. Maybe there is a possibility to reset 
> MavenEmbedder without to instantiate a new one.
> <codesnippet Maven2Builder.build()>
> // line 52-55 are replaced
> //        Maven2ClasspathContainer container = ( Maven2ClasspathContainer ) 
> JavaCore
> //            .getClasspathContainer( path, project );
> //        JavaCore.setClasspathContainer( container.getPath(), new 
> IJavaProject[] { project },
> //            new IClasspathContainer[] { new Maven2ClasspathContainer( 
> entries ) }, monitor );
>         // ############### CHANGES ################
>         IClasspathContainer icContainer = JavaCore.getClasspathContainer( 
> path, project );
>         IJavaProject[] projects = new IJavaProject[] { project };
>         IPath newPath = null;
>         IClasspathContainer[] classpathContainers = null;
>         if( icContainer == null ) {
>           newPath = new Path( Maven2Plugin.CONTAINER_ID );
>           classpathContainers = new IClasspathContainer[] { new 
> Maven2ClasspathContainer( entries ) };
>           JavaCore.setClasspathContainer( newPath, projects, 
> classpathContainers, monitor );
>         } else {
>           newPath = icContainer.getPath();
>           if( icContainer instanceof Maven2ClasspathContainer ) {
>             classpathContainers = new IClasspathContainer[] { new 
> Maven2ClasspathContainer( entries ) };
>             JavaCore.setClasspathContainer( newPath, projects, 
> classpathContainers, monitor );
>           } else {
>             newPath = new Path( Maven2Plugin.CONTAINER_ID );
>             classpathContainers = new IClasspathContainer[] { new 
> Maven2ClasspathContainer( entries ) };
>             JavaCore.setClasspathContainer( newPath, projects, 
> classpathContainers, monitor );
>           }
>         }
>         // ############### CHANGES ################
> </codesnippet>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to