You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by "Roland Klein (JIRA)" <ji...@codehaus.org> on 2006/01/05 16:56:20 UTC

[jira] Created: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

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
 Assigned to: Eugene Kuleshov 


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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Commented: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Roland Klein (JIRA)" <ji...@codehaus.org>.
    [ 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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Closed: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Roland Klein (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=all ]
     
Roland Klein closed MNGECLIPSE-25:
----------------------------------

    Resolution: Fixed

Oh, i just entered some comment look above ;)

> 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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Commented: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Eugene Kuleshov (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=comments#action_55093 ] 

Eugene Kuleshov commented on MNGECLIPSE-25:
-------------------------------------------

Thanks Roland. 

BTW, for the future, it would be easier if you actually submit patch and not the changed source archive.

> 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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Updated: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Eugene Kuleshov (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=all ]

Eugene Kuleshov updated MNGECLIPSE-25:
--------------------------------------

        Version: 0.0.3
    Fix Version: 0.0.4

> 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

>     Versions: 0.0.3
>  Environment: WIN2K, Eclipse 3.1, JDK 1.5
>     Reporter: Roland Klein
>     Assignee: Eugene Kuleshov
>      Fix For: 0.0.4
>  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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Reopened: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Eugene Kuleshov (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=all ]
     
Eugene Kuleshov reopened MNGECLIPSE-25:
---------------------------------------


> 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

>     Versions: 0.0.3
>  Environment: WIN2K, Eclipse 3.1, JDK 1.5
>     Reporter: Roland Klein
>     Assignee: Eugene Kuleshov
>      Fix For: 0.0.4
>  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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Commented: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Eugene Kuleshov (JIRA)" <ji...@codehaus.org>.
    [ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=comments#action_54994 ] 

Eugene Kuleshov commented on MNGECLIPSE-25:
-------------------------------------------

Let's take it one at a time. Please post a stack trace for ClassCastException and NPE in Maven2Builder.

For second issue about MavenEmbedder  please fill in separate issue.

Thanks

> 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

>
>
> 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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Closed: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Eugene Kuleshov (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=all ]
     
Eugene Kuleshov closed MNGECLIPSE-25:
-------------------------------------

     Resolution: Won't Fix
    Fix Version:     (was: 0.0.4)

> 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

>     Versions: 0.0.3
>  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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[jira] Updated: (MNGECLIPSE-25) Enable Maven in project causes ClassCastException

Posted by "Roland Klein (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/MNGECLIPSE-25?page=all ]

Roland Klein updated MNGECLIPSE-25:
-----------------------------------

    Attachment: pzFileReader.zip
                src.zip

> 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: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org