Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when using maven plugin to generate api for interface #73

Closed
wtpau opened this issue Jan 20, 2015 · 2 comments
Closed

NPE when using maven plugin to generate api for interface #73

wtpau opened this issue Jan 20, 2015 · 2 comments
Assignees
Labels
bug
Milestone

Comments

@wtpau
Copy link

@wtpau wtpau commented Jan 20, 2015

Hi,

I am using jsondoc 1.1.0 with maven plugin, but when I run the jsondoc:generate goal i got NPE. I found that it is cause by I have an Interface and Impl class and I have the jsondoc annotaction on the interface, but my intention is to annotate the interface as it was supported in the jsondoc 1.0.2 version.

Here is the exception message from maven:

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jsondoctesting 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- jsondoc-maven-plugin:1.1.0:generate (default-cli) @ test ---
log4j:WARN No appenders could be found for logger (org.jsondoc.core.util.JSONDocScanner).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[ERROR]
java.lang.NullPointerException
at org.jsondoc.core.pojo.ApiDoc.buildFromAnnotation(ApiDoc.java:20)
at org.jsondoc.core.util.AbstractJSONDocScanner.getApiDoc(AbstractJSONDocScanner.java:100)
at org.jsondoc.core.util.AbstractJSONDocScanner.getApiDocs(AbstractJSONDocScanner.java:87)
at org.jsondoc.core.util.AbstractJSONDocScanner.getApiDocsMap(AbstractJSONDocScanner.java:285)
at org.jsondoc.core.util.AbstractJSONDocScanner.getJSONDoc(AbstractJSONDocScanner.java:75)
at org.jsondoc.JSONDocMojo.execute(JSONDocMojo.java:82)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.374s
[INFO] Finished at: Tue Jan 20 11:19:39 CST 2015
[INFO] Final Memory: 10M/112M
[INFO] ------------------------------------------------------------------------

Here is my pom.xml

4.0.0 test test 0.0.1-SNAPSHOT jsondoctesting
    <dependencies>
        <dependency>
            <groupId>org.jsondoc</groupId>
            <artifactId>jsondoc-core</artifactId>
            <version>1.1.0</version>
        </dependency>
    </dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.jsondoc</groupId>
            <artifactId>jsondoc-maven-plugin</artifactId>
            <version>1.1.0</version>
            <configuration>
                <version>1.1</version>
                <basePath>http://127.0.0.1:8080/asset-management-ws</basePath>
                <packages>
                    <package>com.test</package>
                </packages>
                <outputFile>/tmp/jsondoc.json</outputFile>
            </configuration>
        </plugin>
    </plugins>
</build>
## Here is my interface class:

package com.test;

import org.jsondoc.core.annotation.Api;
import org.jsondoc.core.annotation.ApiAuthNone;
import org.jsondoc.core.annotation.ApiMethod;
import org.jsondoc.core.annotation.ApiQueryParam;
import org.jsondoc.core.annotation.ApiResponseObject;
import org.jsondoc.core.pojo.ApiVerb;

@Api(name = "test services", description = "Methods for querying location data")
@ApiAuthNone
public interface TestInterface {

@ApiMethod(path = "/api/rest/locations", verb = ApiVerb.GET, description = "search location")
@ApiResponseObject
Integer searchLocation(
        @ApiQueryParam(name = "site", description = "site", required = true) String site,
        @ApiQueryParam(name = "building", description = "building", required = true) String building,
        @ApiQueryParam(name = "floor", description = "floor", required = true) String floor,
        @ApiQueryParam(name = "room", description = "room", required = true) String room);

}

Here is my impl class

package com.test.impl;

import com.test.TestInterface;

public class TestImpl implements TestInterface {

public Integer searchLocation(String site, String building, String floor, String room) {
    // TODO Auto-generated method stub
    return null;
}

}

Thanks a lot
Wai Tak Pau

@Yangjierong
Copy link

@Yangjierong Yangjierong commented Jan 20, 2015

I have the same issue!

@fabiomaffioletti fabiomaffioletti added this to the 1.1.3 milestone Jan 20, 2015
@fabiomaffioletti fabiomaffioletti self-assigned this Jan 20, 2015
@fabiomaffioletti
Copy link
Owner

@fabiomaffioletti fabiomaffioletti commented Jan 21, 2015

Should be fine with the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.