Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Fail to instantiating org.eclipse.sapphire.samples.ezbug.IFileBugReportOp
Fail to instantiating org.eclipse.sapphire.samples.ezbug.IFileBugReportOp [message #747253] Mon, 24 October 2011 01:27 Go to next message
St Clair Clarke is currently offline St Clair ClarkeFriend
Messages: 118
Registered: March 2010
Senior Member
Hello,

I am attempting to instantiate org.eclipse.sapphire.samples.ezbug.IFileBugReportOp in Sapphier's v0.3.2 examples using the main method below:




package org.eclipse.sapphire.samples.ezbug;


import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.sapphire.ui.swt.SapphireDialog;
import org.eclipse.swt.widgets.Display;

public class DialogMain
{
    
    /**
     * @param args
     */
    public static void main( String[] args )
    {
        IFileBugReportOp op = IFileBugReportOp.TYPE.instantiate();
        IBugReport report = op.getBugReport();
        
        SapphireDialog dialog = new SapphireDialog( Display.getCurrent().getActiveShell(), report, "org.eclipse.sapphire.samples/org/eclipse/sapphire/samples/ezbug/EzBug.sdef!dialog1" );
        
        if( dialog.open() == Dialog.OK )
        {
            // Do something. User input is found in the bug report model.
        }
        
    }
    
}


However, the following exception is thrown in the console:

Exception in thread "main" java.lang.RuntimeException: IFileBugReportOp : Could not instantiate implementation class.
	at org.eclipse.sapphire.modeling.ModelElementType.instantiate(ModelElementType.java:284)
	at org.eclipse.sapphire.modeling.ModelElementType.instantiate(ModelElementType.java:298)
	at org.eclipse.sapphire.samples.ezbug.DialogMain.main(DialogMain.java:18)


The referenced line 18 above is :

IFileBugReportOp op = IFileBugReportOp.TYPE.instantiate();


What am I doing wrong.

Also please check if the pseudo-url is collect to instantiate the element with id=dialog1 in EzBug.sdf


Thanks


Re: Fail to instantiating org.eclipse.sapphire.samples.ezbug.IFileBugReportOp [message #747268 is a reply to message #747253] Mon, 24 October 2011 01:39 Go to previous messageGo to next message
Greg Amerson is currently offline Greg AmersonFriend
Messages: 119
Registered: March 2010
Senior Member
I assume you have enabled annotation processing for your project that uses sapphire. When you do this anytime you have @GenerateImpl annotation you should see a folder in your project called, .apt_generated (hidden in package explorer), this should contain all of the generated .java code that Sapphire needs to operate at runtime.

The problem is the JDT Annotation processor is very buggy. What happens many times on new projects or even existing projects where a full clean-rebuild has happened is that the JDT APT tool fails to regenerate the impl classes so you get that failure at runtime. Unfortunately the only way that I have been able to fix this problem 100% of the time is a very weird workaround. First you move all of the .java classes in your source that you have the @GenerateImpl to a temp folder somewhere. THen refresh eclipse and it will rebuild the project without those interfaces (lots of compilation errors likely). Then move those files back from the temp folder into Eclipse source folder and refresh. 99% of the time this fixes the problem for me, now if I look in .apt_generated/ i will see all of my model impl classes and things work as expected at runtime.

Hope this helps.
Re: Fail to instantiating org.eclipse.sapphire.samples.ezbug.IFileBugReportOp [message #747322 is a reply to message #747268] Mon, 24 October 2011 02:28 Go to previous messageGo to next message
St Clair Clarke is currently offline St Clair ClarkeFriend
Messages: 118
Registered: March 2010
Senior Member
Hello,
Annotation processing was NOT enable. It is now.

However, I receive the following now:

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.sapphire.samples.ezbug.DialogMain.main(DialogMain.java:21)


Line 21 is:

SapphireDialog dialog = new SapphireDialog( Display.getCurrent().getActiveShell(), report, "org.eclipse.sapphire.samples/org/eclipse/sapphire/samples/ezbug/EzBug.sdef!dialog1" );


I have not changed anything in the example - I simply import the project into my workspace.

I am wondering if the pseudo-uri is incorrect. From the documentation, it seems correct.

Thanks
Re: Fail to instantiating org.eclipse.sapphire.samples.ezbug.IFileBugReportOp [message #748252 is a reply to message #747322] Mon, 24 October 2011 15:34 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
I am at a loss to explain what you are seeing. The samples are correct. The annotation processing is enabled in the samples project when you import it (Project Properties -> Java Compiler -> Annotation Processing).

Is it possible that you've loaded samples from the wrong version of Sapphire? Do you have any other projects besides Sapphire samples in your workspace?

Here is what I did to verify proper behavior of the EzBug sample in 0.3.2 release:

1. Started with fresh Indigo SR1 IDE for Java EE Developers.
2. Installed Sapphire from Eclipse Marketplace, leaving all of the proposed components selected.
3. Created a new workspace.
4. Downloaded samples from the corresponding release page (http://www.eclipse.org/sapphire/releases/0.3.2/).
5. Imported the Samples project from archive.

At this point, the samples project was in compiled state and when running I was able to exercise the EzBug sample.

- Konstantin
Re: Fail to instantiating org.eclipse.sapphire.samples.ezbug.IFileBugReportOp [message #748527 is a reply to message #748252] Mon, 24 October 2011 18:43 Go to previous messageGo to next message
St Clair Clarke is currently offline St Clair ClarkeFriend
Messages: 118
Registered: March 2010
Senior Member
Hello Konstantin,
I have followed your instructions but the same NPE result as previous post.

Could you send me a simple example of how you successfully exercise the EzBug.sdef model.

Thanks a million.
Re: Fail to instantiating org.eclipse.sapphire.samples.ezbug.IFileBugReportOp [message #748644 is a reply to message #748527] Mon, 24 October 2011 20:22 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
The samples project is the set of available examples. If you are getting exceptions launching samples, there is likely something wrong in your setup. It is hard to tell what that might be though.

Are you positive that you are using Eclipse IDE for Java EE Developers package? Are you positive that you have nothing in the workspace besides the samples project? Anything in the error log?

- Konstantin
Previous Topic:Validation decorators in Sapphire
Next Topic:Pseudo-uri
Goto Forum:
  


Current Time: Fri Mar 29 05:29:17 GMT 2024

Powered by FUDForum. Page generated in 0.04827 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top