maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Hobson (JIRA)" <j...@codehaus.org>
Subject [jira] Commented: (MSHARED-80) NullPointer in DefaultDependencyTreeBuilder.java:93, no logger
Date Wed, 05 Nov 2008 09:54:51 GMT

    [ http://jira.codehaus.org/browse/MSHARED-80?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=153102#action_153102
] 

Mark Hobson commented on MSHARED-80:
------------------------------------

Firstly, it looks like your plexus annotations are wrong:

{noformat}/**
 * Dependency tree builder component.
 *
 * @component expression="org.apache.maven.shared.dependency.tree.DependencyTreeBuilder"
 * @required
 * @readonly
 */
private DependencyTreeBuilder dependencyTreeBuilder;{noformat}

@component takes a 'role' attribute, not an 'expression'.  So it should be:

{noformat}/**
 * Dependency tree builder component.
 *
 * @component role="org.apache.maven.shared.dependency.tree.DependencyTreeBuilder"
 * @required
 * @readonly
 */
private DependencyTreeBuilder dependencyTreeBuilder;{noformat}

Of course, DependencyTreeBuilder will only be injected here if this class is instantiated
by plexus, which all maven plugins are.

Secondly, the NPE is due to DependencyTreeBuilder having no Logger injected into it.  Again,
this would only happen if it were constructed outside of maven/plexus, and not if you've got
your plexus annotations set up as described above.

Hope this helps.

> NullPointer in DefaultDependencyTreeBuilder.java:93, no logger 
> ---------------------------------------------------------------
>
>                 Key: MSHARED-80
>                 URL: http://jira.codehaus.org/browse/MSHARED-80
>             Project: Maven Shared Components
>          Issue Type: Bug
>          Components: maven-dependency-tree
>    Affects Versions: maven-dependency-tree 1.2
>         Environment: Windows XP 64 JDK 1.6
>            Reporter: MTStorm
>            Priority: Critical
>
> I have a report and a mojo that seeks transversal dependencies. It shows a nullpointer
in the DefaultDependencyTreeBuilder. 
> I can not figure it out what is wrong sice the implementation off DependencyTreeBuilder
is assigned by Maven and I have no controll on the logger. 
> Here is the code snippet
> //members
> 	/**
> 	 * Used to look up Artifacts in the remote repository.
> 	 * 
> 	 * @parameter expression=
> 	 *            "${component.org.apache.maven.artifact.factory.ArtifactFactory}"
> 	 * @required
> 	 * @readonly
> 	 */
> 	protected org.apache.maven.artifact.factory.ArtifactFactory artifactFactory;
> 	/**
> 	 * Used to look up Artifacts in the remote repository.
> 	 * 
> 	 * @parameter expression=
> 	 *            "${component.org.apache.maven.artifact.resolver.ArtifactResolver}"
> 	 * @required
> 	 * @readonly
> 	 */
> 	protected org.apache.maven.artifact.resolver.ArtifactResolver resolver;
> 	/**
> 	 * Artifact collector, needed to resolve dependencies.
> 	 * 
> 	 * @component role="org.apache.maven.artifact.resolver.ArtifactCollector"
> 	 * @required
> 	 * @readonly
> 	 */
> 	protected ArtifactCollector artifactCollector;
> 	/**
> 	 * @component 
> 	 *            role="org.apache.maven.artifact.metadata.ArtifactMetadataSource"
> 	 *            hint="maven"
> 	 * @required
> 	 * @readonly
> 	 */
> 	protected ArtifactMetadataSource artifactMetadataSource;
> 	/**
> 	 * Dependency tree builder component.
> 	 * 
> 	 * @component expression=
> 	 *            "org.apache.maven.shared.dependency.tree.DependencyTreeBuilder"
> 	 * @required
> 	 * @readonly
> 	 */
> 	private DependencyTreeBuilder dependencyTreeBuilder;
> //sample snippet to use in report and mojo
> 		ArtifactFilter artifactFilter = new ScopeArtifactFilter(
> 				Artifact.SCOPE_COMPILE);
> 		DependencyNode dn;
> 		getLog().info("Start");
> 		try {
> 			dn = dependencyTreeBuilder.buildDependencyTree(
> 					project, localRepository, artifactFactory, artifactMetadataSource,
> 					artifactFilter, artifactCollector);
> 			
> 		} catch (DependencyTreeBuilderException e) {
> 			e.printStackTrace();
> 			getLog().error("oeps",e);
> 		}
> 		getLog().info("Done");

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

        

Mime
View raw message