mulesoft-labs / raml-for-jax-rs

This project is all about two way transformation of JAX-RS-annotated Java code to RAML API description and back.
Other
295 stars 181 forks source link

NullPointerException generating XML schema in eclipse plugin #109

Closed n4zukker closed 9 years ago

n4zukker commented 9 years ago

I get a null pointer exception when I try to generate RAML for my jax-rs code. This exception prevents any schema files (XML, JSON) from being created. I narrowed it down to this a very simple case. It happens when I try to generate RAML for this trivial app with Fee.java and Foo.java. With the XmlElement annotation commented out, a schema gets generated. Otherwise a null pointer exception shows up in the stdout of the eclipse process.

I'm trying this on Eclipse 4.3.2. RAML plugin is v1.3.4.201506151740.

A bug fix or work around to this would be appreciated.

Thanks.

... import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces;

@Path("/") public class Fee { @GET @Produces({"application/xml"}) public Foo getZ() { return null; } } ...

... import java.util.List;

import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement() @XmlAccessorType(XmlAccessType.NONE) public class Foo { @XmlElement <----- commenting this line makes things work. protected List orgs; } ...

... java.lang.NullPointerException at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:37) at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85) at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54) at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.buildSchemaModel(SchemaModelBuilder.java:29) at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1111) at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98) at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:42) at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:328) at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234) at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:323) at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitUnit(GenerateRAML.java:349) at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackage(GenerateRAML.java:356) at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackageFragmentRoot(GenerateRAML.java:366) at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitProject(GenerateRAML.java:376) at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.run(GenerateRAML.java:271) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3742) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3363) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) at java.lang.reflect.Method.invoke(Method.java:619) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) at org.eclipse.equinox.launcher.Main.run(Main.java:1450) at org.eclipse.equinox.launcher.Main.main(Main.java:1426) ...

KonstantinSviridov commented 9 years ago

Hi, @n4zukker

We can not reproduce your problem. Could you try the latest version which is 1.3.4-20150624.142417-62, please?

I can not test the version you use as Sonatype already does not contain it.

Regards, Konstantin

n4zukker commented 9 years ago

Done. Line number changed a tiny bit in ResourceVisitor.

java.lang.NullPointerException
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:37)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.buildSchemaModel(SchemaModelBuilder.java:29)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1114)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:42)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:328)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:323)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitUnit(GenerateRAML.java:349)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackage(GenerateRAML.java:356)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackageFragmentRoot(GenerateRAML.java:366)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitProject(GenerateRAML.java:376)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.run(GenerateRAML.java:271)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3742)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3363)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:619)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
KonstantinSviridov commented 9 years ago

How would the plugin react if you change field type to List<String>, List<Object>, Object, String?

n4zukker commented 9 years ago

Were you able to try this for yourself? Here's what I get:

String[] --> NPE List --> NPE List --> NPE ArrayList --> NPE Object --> NPE MyCustomList implements List --> schema generated

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement()
public class Foo {
    @XmlElement
    private MyList o;//ArrayList<String> o;
    private static class MyList extends AbstractList<String> {

        @Override
        public String get(int index) {
            // TODO Auto-generated method stub
            return null;
        }

        @Override
        public int size() {
            // TODO Auto-generated method stub
            return 0;
        }

    }
}
KonstantinSviridov commented 9 years ago

Yes, my build works fine with all the above types.

The NPE is thrown because a model object of the fields type is not available. It looks like that in your case code model is available only for those types which are passed as sources.

What happens if you set

protected Integer orgs;

and

protected String orgs;

?

n4zukker commented 9 years ago

NPE for both of those. Is this an issue with the classpath or JRE settings? in my real eclipse project I have a web deployment assembly (Properties -> Deployment Assembly) including other projects, one of which defines JAXB classes that my JAX-RS REST app uses.

KonstantinSviridov commented 9 years ago

Oh, I've just realized that you are talking about Eclipse plugin, not Maven. Sorry. With Eclipse plugin I can see the problem.

n4zukker commented 9 years ago

That's great news! So you can debug it and things on your side. Glad to hear that.

n4zukker commented 9 years ago

Any ideas?

KonstantinSviridov commented 9 years ago

I've fixed it. Now I'm testing.

KonstantinSviridov commented 9 years ago

Now it should be fine.

n4zukker commented 9 years ago

Thank you very much. Your fix works on the trivial code I posted and also helps me generate XSD for my models in the real code. The NullPointerException now has moved. I think I have a full set of XML schemas now but I only have one JSON schema and one pair of example (XML and JSON) files. I'm also getting a series of null pointer exceptions with the same stack trace in the eclipse stdout.

It would appear that this exception happens in a loop, prevents json schema from being created and also prevents xml and json example files.

Here's the stack trace. Please tell me if you need me to make a test case for this one.

java.lang.NullPointerException
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.getType(SchemaModelBuilder.java:101)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:90)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.buildSchemaModel(SchemaModelBuilder.java:29)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1114)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:328)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:338)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:323)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitUnit(GenerateRAML.java:349)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackage(GenerateRAML.java:356)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackageFragmentRoot(GenerateRAML.java:366)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitProject(GenerateRAML.java:376)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.run(GenerateRAML.java:271)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3742)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3363)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:94)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:619)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
KonstantinSviridov commented 9 years ago

Yesterday I observed it wotking fine on some sufficient example. So, I would appreciate your example.

n4zukker commented 9 years ago
import java.util.Collection;

import javax.ws.rs.core.Link;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement()
public class Foo {
    @XmlJavaTypeAdapter(Link.JaxbAdapter.class)
    @XmlElement(name="link")
    public Collection<Link> links;

    public Foo() {
    }

    public Foo(Collection<Link> links) {
        this.links = links;
    }

    public String toString() {
        return links.toString();
    }
}
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

@Path("/")
public class Fee {
    @GET
    @Produces({"application/xml"})
    public Foo getZ() {
        return null;
    }
}
ava.lang.NullPointerException
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.getType(SchemaModelBuilder.java:101)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:90)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.buildSchemaModel(SchemaModelBuilder.java:29)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1114)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:328)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:323)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitUnit(GenerateRAML.java:349)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackage(GenerateRAML.java:356)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackageFragmentRoot(GenerateRAML.java:366)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitProject(GenerateRAML.java:376)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.run(GenerateRAML.java:271)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3742)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3363)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:613)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
n4zukker commented 9 years ago

That creates schemas/foo-xml-schema.xsd but does not create an examples directory. My real code produces application/json as well as xml but that's not needed to get this exception.

KonstantinSviridov commented 9 years ago

I see it. Let me check what's happening.

n4zukker commented 9 years ago

Thanks.

KonstantinSviridov commented 9 years ago

Ok, done.

Note that we do not support @XmlJavaTypeAdapter yet. I'll create an issue about it.

n4zukker commented 9 years ago

Thanks. I'm now getting an error dialog box in my real code. Running "Generate RAML from classes" works for a few seconds, gives more xml and json files than before, and then pops up a dialog containing just a red circle with white line through it and an Ok button. Unfortunately the dialog does not have any text and isn't resizable so I can't report more.

n4zukker commented 9 years ago

Ok. I managed to get a stack trace. Not sure if this is the same problem I experienced above but it's some bug. Eclipse pops up with an "Unhandled Loop Exception" dialog box and lets me look at the "workspace log". I see this:

java.lang.StackOverflowError
    at com.mulesoft.jaxrs.raml.jaxb.JAXBRegistry.getJAXBModel(JAXBRegistry.java:30)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBProperty.getType(JAXBProperty.java:61)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:166)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:168)
        ...
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:168)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:168)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:168)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:168)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:168)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.gatherNamespaces(JAXBType.java:157)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:48)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.buildSchemaModel(SchemaModelBuilder.java:29)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1114)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:328)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:323)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitUnit(GenerateRAML.java:349)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackage(GenerateRAML.java:356)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitPackageFragmentRoot(GenerateRAML.java:366)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitProject(GenerateRAML.java:376)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.run(GenerateRAML.java:271)
    at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:251)
    at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
    at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
    at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1392)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3742)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3363)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:88)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55)
    at java.lang.reflect.Method.invoke(Method.java:613)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

Code:


import java.util.Collection;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement()
public class Abc {
    @XmlElement(name="link")
    public Collection<String> links;

    public Abc() {
    }
}
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

@Path("/v0.1/")
public class Def {
    @Context
    private HttpServletRequest request;

    @Path("zzz")
    public Abc xxx() {
        return null;
    }
}

stdout from eclipse (where the previous stack traces showed up) is empty -- no messages there.

KonstantinSviridov commented 9 years ago

Must be fine now.

n4zukker commented 9 years ago

Thank you. The simple example works however my real code has this popup:

Message: An internal error occurred during: "Generate RAML from JAX RS classes". Exception Stack Trace:

org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:4397)
    at org.eclipse.swt.SWT.error(SWT.java:4312)
    at org.eclipse.swt.SWT.error(SWT.java:4283)
    at org.eclipse.swt.widgets.Widget.error(Widget.java:481)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:263)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:359)
    at org.eclipse.jface.window.Window.createShell(Window.java:488)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1104)
    at org.eclipse.jface.window.Window.open(Window.java:791)
    at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:334)
    at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:364)
    at org.eclipse.jface.dialogs.MessageDialog.openError(MessageDialog.java:427)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.processException(GenerateRAML.java:271)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:36)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

and this appear in stdout:

java.lang.NullPointerException
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:175)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.gatherNamespaces(JAXBType.java:162)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:48)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.buildSchemaModel(SchemaModelBuilder.java:29)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1116)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:330)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:360)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.access$2(GenerateRAML.java:350)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.visitType(GenerateRAML.java:266)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitUnit(SourceVisitor.java:48)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackage(SourceVisitor.java:55)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackageFragmentRoot(SourceVisitor.java:65)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitProject(SourceVisitor.java:75)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:28)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

I'll try to reduce things to a simple example for you.

n4zukker commented 9 years ago

This case gives the error dialog box but I lost the null stack trace in stdout while I was weeding the code. So could be that we have two bugs here.

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

@Path("/")
public class Root {
    @Context
    private HttpServletRequest request;

    @Path("aaa")
    public Aaa getAAa() throws IOException {
        return null;
    }
}
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement()
@XmlAccessorType(XmlAccessType.FIELD)
public class Aaa {
    public CustomMap m;
}
import java.util.AbstractMap;
import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;

@XmlAccessorType(XmlAccessType.NONE)
public class CustomMap extends AbstractMap<String, String> 
{
    @Override
    public Set<java.util.Map.Entry<String, String>> entrySet() {
        return null;
    }
}
org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:4397)
    at org.eclipse.swt.SWT.error(SWT.java:4312)
    at org.eclipse.swt.SWT.error(SWT.java:4283)
    at org.eclipse.swt.widgets.Widget.error(Widget.java:481)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:263)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:359)
    at org.eclipse.jface.window.Window.createShell(Window.java:488)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1104)
    at org.eclipse.jface.window.Window.open(Window.java:791)
    at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:334)
    at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:364)
    at org.eclipse.jface.dialogs.MessageDialog.openError(MessageDialog.java:427)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.processException(GenerateRAML.java:271)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:36)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
n4zukker commented 9 years ago

Here's a third bug case. This one doesn't pop up any boxes but the stack trace appears in stdout.

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

@Path("/")
public class MyRoot {
    @Context
    private HttpServletRequest request;

    @Path("aaa")
    public MyMap getAAa() throws IOException {
        return null;
    }
}
import java.util.AbstractMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement( name="m" )
@XmlAccessorType(XmlAccessType.NONE)
public class MyMap extends AbstractMap<String, String> {
    @XmlJavaTypeAdapter(MyMap.JaxbMapAdapter.class)
    @XmlElement(name="notes")
    Map<String, String> c = new HashMap<String, String>();

    public static class JaxbMapAdapter extends XmlAdapter<String[], Map<String, String>> {
        @Override
        public Map<String, String> unmarshal(String[] v) throws Exception {
            return null;
        }

        @Override
        public String[] marshal(Map<String, String> v) throws Exception {
            return null;
        }
    }

    @Override
    public Set<java.util.Map.Entry<String, String>> entrySet() {
        return null;
    }
}
java.lang.NullPointerException
    at org.raml.schema.model.serializer.StructuredModelSerializer.process(StructuredModelSerializer.java:39)
    at org.raml.schema.model.serializer.StructuredModelSerializer.serialize(StructuredModelSerializer.java:22)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1127)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:330)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:360)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.access$2(GenerateRAML.java:350)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.visitType(GenerateRAML.java:266)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitUnit(SourceVisitor.java:48)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackage(SourceVisitor.java:55)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackageFragmentRoot(SourceVisitor.java:65)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitProject(SourceVisitor.java:75)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:28)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at org.raml.schema.model.serializer.StructuredModelSerializer.process(StructuredModelSerializer.java:39)
    at org.raml.schema.model.serializer.StructuredModelSerializer.serialize(StructuredModelSerializer.java:22)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1136)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:330)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:360)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.access$2(GenerateRAML.java:350)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.visitType(GenerateRAML.java:266)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitUnit(SourceVisitor.java:48)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackage(SourceVisitor.java:55)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackageFragmentRoot(SourceVisitor.java:65)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitProject(SourceVisitor.java:75)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:28)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
java.lang.NullPointerException
    at org.raml.schema.model.serializer.StructuredModelSerializer.process(StructuredModelSerializer.java:39)
    at org.raml.schema.model.serializer.StructuredModelSerializer.serialize(StructuredModelSerializer.java:22)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1144)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:330)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:360)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.access$2(GenerateRAML.java:350)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.visitType(GenerateRAML.java:266)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitUnit(SourceVisitor.java:48)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackage(SourceVisitor.java:55)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackageFragmentRoot(SourceVisitor.java:65)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitProject(SourceVisitor.java:75)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:28)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
n4zukker commented 9 years ago

Last case for now:

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

@Path("/v0.1/")
public class Test1 {
    @Context
    private HttpServletRequest request;

    @Path("aaa")
    public Bbb getAaa() throws IOException {
        return null;
    }
}
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
public class Bbb {
    @XmlElement
    protected ArrayList<Ccc> c = new ArrayList<Ccc>();
}
import java.util.Collection;

import javax.ws.rs.core.Link;

public class Ccc {
    private Collection<Link> links;

    public Collection<Link> getLinks() {
        return links;
    }
}

Results in this exception being written to stdout. No error pop-up.

java.lang.NullPointerException
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.fillNamespaceMap(JAXBType.java:175)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.gatherNamespaces(JAXBType.java:162)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:48)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.writeProperty(SchemaModelBuilder.java:85)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.generateType(SchemaModelBuilder.java:54)
    at com.mulesoft.jaxrs.raml.jaxb.SchemaModelBuilder.buildSchemaModel(SchemaModelBuilder.java:29)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1116)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:330)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:360)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.access$2(GenerateRAML.java:350)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.visitType(GenerateRAML.java:266)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitUnit(SourceVisitor.java:48)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackage(SourceVisitor.java:55)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackageFragmentRoot(SourceVisitor.java:65)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitProject(SourceVisitor.java:75)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:28)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
KonstantinSviridov commented 9 years ago

Ok, fixed theese. Your code appears to be a valuable source of test cases.

n4zukker commented 9 years ago

I'm glad to assist you, especially since you have a good turnaround time for bug fixes.

I still see this in my real code. From the trace it looks like your code is trying to say something processException(GenerateRAML.java:271) but unfortunately I can't see what. Nothing in stdout.

org.eclipse.swt.SWTException: Invalid thread access
    at org.eclipse.swt.SWT.error(SWT.java:4397)
    at org.eclipse.swt.SWT.error(SWT.java:4312)
    at org.eclipse.swt.SWT.error(SWT.java:4283)
    at org.eclipse.swt.widgets.Widget.error(Widget.java:481)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:263)
    at org.eclipse.swt.widgets.Shell.<init>(Shell.java:359)
    at org.eclipse.jface.window.Window.createShell(Window.java:488)
    at org.eclipse.jface.window.Window.create(Window.java:431)
    at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1104)
    at org.eclipse.jface.window.Window.open(Window.java:791)
    at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:334)
    at org.eclipse.jface.dialogs.MessageDialog.open(MessageDialog.java:364)
    at org.eclipse.jface.dialogs.MessageDialog.openError(MessageDialog.java:427)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.processException(GenerateRAML.java:271)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:36)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:313)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
KonstantinSviridov commented 9 years ago

I've implemented exposing exceptions in a custom dialog.

KonstantinSviridov commented 9 years ago

The problem was due to trying opening error dialog from non UI thread.

n4zukker commented 9 years ago

Thank you. The code now has nothing to say, no dialog pops pop up and no error messages are written. Only the sample, schema and RAML. :-)

Closing.

n4zukker commented 9 years ago

I suspected this would happen :-)

I'll try to recreate with some publishable code.

java.lang.NullPointerException
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.resolveType(JDTAnnotatable.java:237)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.implementsInterface(JDTAnnotatable.java:310)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.isCollection(JDTAnnotatable.java:349)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.isCollection(JDTAnnotatable.java:372)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTField.isCollection(JDTField.java:87)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBProperty.<init>(JAXBProperty.java:38)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBElementProperty.<init>(JAXBElementProperty.java:32)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.createProperty(JAXBType.java:132)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.<init>(JAXBType.java:67)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBRegistry.getJAXBModel(JAXBRegistry.java:33)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1109)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:330)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:340)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:365)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.access$2(GenerateRAML.java:355)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.visitType(GenerateRAML.java:272)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitUnit(SourceVisitor.java:48)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackage(SourceVisitor.java:55)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackageFragmentRoot(SourceVisitor.java:65)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitProject(SourceVisitor.java:75)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:28)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:319)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
KonstantinSviridov commented 9 years ago

Hi, @n4zukker

I have inserted NPE handling in the code which threw your exception. Now you should obtain a message like Type {someType} cannot be resolved. It may help you to build an example.

n4zukker commented 9 years ago

Here's what I get from the latest build. I'm still catching up on other work so won't be able to spend a few hours pruning to get good test cases.

ava.lang.NullPointerException
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTType.getSuperClass(JDTType.java:108)
    at com.mulesoft.jaxrs.raml.annotation.model.ClassHierarchyVisitor.visit(ClassHierarchyVisitor.java:12)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.extractmethods(ResourceVisitor.java:268)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:234)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.visitType(GenerateRAML.java:365)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML.access$2(GenerateRAML.java:355)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$1.visitType(GenerateRAML.java:272)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitUnit(SourceVisitor.java:48)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackage(SourceVisitor.java:55)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitPackageFragmentRoot(SourceVisitor.java:65)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitProject(SourceVisitor.java:75)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.SourceVisitor.visitObject(SourceVisitor.java:28)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.GenerateRAML$3.run(GenerateRAML.java:319)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
``
KonstantinSviridov commented 9 years ago

That's a new one. Fixed it.

n4zukker commented 9 years ago

Looks like we are making progress. In this case, I happen to have my own class called CloseableIterable. I'm not sure why the code would be looking for java.util.CloseableIterable. My code compiles cleanly and runs fine.

package xxxxxx;

import java.io.Closeable;

public interface CloseableIterable<T> extends Closeable, Iterable<T> {
}
Type java.util.CloseableIterable cannot be resolved, maybe because of the compilation errors

com.mulesoft.jaxrs.raml.generator.popup.actions.GenerationException
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.resolveType(JDTAnnotatable.java:238)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.implementsInterface(JDTAnnotatable.java:314)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.isCollection(JDTAnnotatable.java:353)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTAnnotatable.isCollection(JDTAnnotatable.java:376)
    at com.mulesoft.jaxrs.raml.annotation.model.jdt.JDTField.isCollection(JDTField.java:87)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBProperty.<init>(JAXBProperty.java:38)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBElementProperty.<init>(JAXBElementProperty.java:32)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.createProperty(JAXBType.java:133)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBType.<init>(JAXBType.java:68)
    at com.mulesoft.jaxrs.raml.jaxb.JAXBRegistry.getJAXBModel(JAXBRegistry.java:33)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.afterSchemaGen(ResourceVisitor.java:1142)
    at com.mulesoft.jaxrs.raml.annotation.model.reflection.RuntimeResourceVisitor.generateXMLSchema(RuntimeResourceVisitor.java:98)
    at com.mulesoft.jaxrs.raml.generator.popup.actions.JDTResourceVisitor.generateXMLSchema(JDTResourceVisitor.java:43)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:363)
    at com.mulesoft.jaxrs.raml.annotation.model.ResourceVisitor.visit(ResourceVisitor.java:236)
KonstantinSviridov commented 9 years ago

Ok, it should be fine now.

Note that JAXB XSD generator understands only those collections that inherit java.util.Collection, and we behave the same way when generating JSON chemes and both types of examples.

n4zukker commented 9 years ago

I think that did it. I now see a new raml directory with lots of examples and schemas. Closing issue.

KonstantinSviridov commented 9 years ago

Thanks again for collaboration.

Please, post new bug reports once they occur.