2

Javaクラス:

    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "user", propOrder = {
            "id",
            "name"  })
    public class User {
        @XmlAttribute(required=true)
        private long id;
        @XmlAttribute(required=true)
            private String name;
        public long getId() {
        return id;
    }
    public void setId(long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Override
    public String toString() {
        return "User [id=" + id + ", name=" + name + "]";
    }
 }
  • JDKバージョン:1.6.0_31
  • 例外スタックトレースschemagenUser.java

    C:\anirban\work_eclipse_juno\RestfulWSDemo\src\com\domain>schemagen User.java
    An exception has occurred in apt (1.6.0_31). Please file a bug at the Java Devel
    oper Connection (http://java.sun.com/webapps/bugreport)  after checking the Bug
    Parade for duplicates. Include your program and the following diagnostic in your
     report.  Thank you.
    java.lang.NullPointerException
            at com.sun.tools.apt.main.CommandLine.parse(CommandLine.java:42)
            at com.sun.tools.apt.main.Main.compile(Main.java:775)
            at com.sun.tools.apt.Main.processing(Main.java:95)
            at com.sun.tools.apt.Main.process(Main.java:85)
            at com.sun.tools.apt.Main.process(Main.java:67)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at com.sun.tools.internal.jxc.SchemaGenerator$Runner.main(SchemaGenerato
    r.java:215)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
    java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
    sorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at com.sun.tools.internal.jxc.SchemaGenerator.run(SchemaGenerator.java:1
    53)
            at com.sun.tools.internal.jxc.SchemaGenerator.run(SchemaGenerator.java:6
    3)
            at com.sun.tools.internal.jxc.SchemaGenerator.main(SchemaGenerator.java:
    55)
    

    誰かがここで私を助けてくれますか?

4

1 に答える 1

2

クラスパスを追加してみてください。schemagen -cp "%java_home%\lib\tools.jar" User.java

于 2013-10-01T13:34:35.163 に答える