[ 
http://jira.codehaus.org/browse/MECLIPSE-663?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

MÃ¥rten Gustafson updated MECLIPSE-663:
--------------------------------------

    Attachment: getConfig.patch

Patch against v2.8

> Overriding Packaging does not work correctly for WTP-Project
> ------------------------------------------------------------
>
>                 Key: MECLIPSE-663
>                 URL: http://jira.codehaus.org/browse/MECLIPSE-663
>             Project: Maven 2.x Eclipse Plugin
>          Issue Type: Bug
>          Components: WTP support
>    Affects Versions: 2.8
>         Environment: All
>            Reporter: Benjamin Gniza
>         Attachments: getConfig.patch
>
>
> I found out that overriding the packaging - type (MECLIPSE-331) does not work 
> correct if you want to have a wtp project:
> {code:xml}
> <project.....>
>       <modelVersion>4.0.0</modelVersion>
>       <groupId>com.mycompany.app</groupId>
>       <artifactId>my-webapp2</artifactId>
>       <packaging>jar</packaging>
> ....
> <build>
> <plugins>
> <plugin>
>       <groupId>org.apache.maven.plugins</groupId>
>       <artifactId>maven-eclipse-plugin</artifactId>
>       <configuration>
>               <packaging>war</packaging>
>               <source>${jdk.version}</source>
>               <target>${jdk.version}</target>
>               <wtpversion>1.5</wtpversion>
>       </configuration>
> </plugin>
> ....
> {code}
> This configuration leads to a Nullpointer Exception:
> {noformat}
> java.lang.NullPointerException
>         at 
> org.codehaus.plexus.util.xml.PrettyPrintXMLWriter.escapeXml(PrettyPrintXMLWriter.java:151)
>         at 
> org.codehaus.plexus.util.xml.PrettyPrintXMLWriter.escapeXmlAttribute(PrettyPrintXMLWriter.java:166)
>         at 
> org.codehaus.plexus.util.xml.PrettyPrintXMLWriter.addAttribute(PrettyPrintXMLWriter.java:190)
>         at 
> org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponent15Writer.writeContextRoot(EclipseWtpComponent15Writer.java:68)
>         at 
> org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponentWriter.writeModuleTypeComponent(EclipseWtpComponentWriter.java:149)
>         at 
> org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponentWriter.write(EclipseWtpComponentWriter.java:106)
>         at 
> org.apache.maven.plugin.eclipse.EclipsePlugin.writeConfiguration(EclipsePlugin.java:1110)
>         at 
> org.apache.maven.plugin.ide.AbstractIdeSupportMojo.execute(AbstractIdeSupportMojo.java:511)
>         at 
> org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:483)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:678)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:553)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:523)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:371)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:332)
>         at 
> org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:181)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:356)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:137)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
>         at 
> org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:41)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:592)
>         at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
>         at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
>         at 
> org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
>         at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
> {noformat}
> The cause for that NullpointerException is that _config.getContextName()_ in 
> *EclipseWtpComponent15Writer.java:68* is null.
> I found out that you are referring to *project.getPackaging()* or 
> *config.getProject().getPackaging()* instead of *config.getPackaging()* in 
> many places:
> * EclipseManifestWriter
> * EclipsePlugin (in this class the method 
> _collectWarContextRootsFromReactorEarConfiguration_ should set the missing 
> context name, but the method refers to *project.getPackaging()* which is 
> still *jar*
> ** here a _reactorProject.getPackaging()_ can also be fond, I don't know if 
> this is correct.
> * RadManifestWriter
> * MyEclipseMetadataWriter
> * MyEclipseStrutsDataWriter
> * EclipseWtpApplicationXMLWriter
> * MyEclipsePlugin
> * AbstractWtpResourceWriter
> After replacing all references to project.getPackaging() to 
> config.getPackaging() the NullpointerException has gone and the plugin works 
> as expected.
> I did only test the combination of project-packaging=jar and 
> eclipse-packaging=war for Eclipse. I did not test MyEclipse, RAD and so on..

-- 
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


Reply via email to