Re: [mdr-users] NullPointerException

Cheng yong <[email protected]> Fri, 15 Jul 2005 15:44:58 -0700 (PDT)
Newsgroups gmane.comp.java.netbeans.modules.mdr.user
Message-ID <[email protected]>
Hi, Martin, 
 
thanks. It works.................................................
 
It's great!!!!
 
Lucia

Martin Matula <[email protected]> wrote:
Please look at my earlier reply. Remove the mdr module jar from your 
classpath...
Martin

Cheng yong wrote:

> Hello, Leo,
> 
> thank you for your suggestion. Sorry that I must bother you again with 
> simple questions.
> 
> The code that you gave as an example doesn't solve the problem. I 
> still got the error. The eroor pointed to the line :
> 
> MDRepository repository = MDRManager.getDefault().getDefaultRepository();
> 
> I suppose the programm looking for the MDRepository folder. So I 
> copied the MDRepository folder from .netbeans to my source folder in 
> eclipse. But I got the same error.
> 
> Is there any settings I should do at first, if I use eclipse IDE?
> 
> regards
> 
> lucia
> 
> P.S: I did not find the package named Model, but a package with the 
> name "Model_Management". Is that what you mean? In Addition, I got 10 
> Packages after I import UML XMI file. Can I just instantiate the 
> Package "Activity_Graphs", if I just want to create activity diagramm? 
> Or is it required to instantiate all.
>
>
> */Leonardo Gresta Paulino Murta /* wrote:
>
> Hello,
>
> You need to load your metamodel first... Take a look on the following
> code (it uses SPEM metamodel, but the idea is almost the same for
> UML -
> In the case of UML you will need to search for a package named
> Model and
> instantiate it...):
>
> // Init Repository with SPEM metamodel (M2)
> ModelPackage modelPackage =
> (ModelPackage)repository.createExtent(METAMODEL_EXTENT);
> URL xmiSpemMetamodel = this.getClass().getResource(SPEM_METAMODEL);
> xmiReader.read(xmiSpemMetamodel.toString(), modelPackage);
>
> // Init the SPEM model extent (M1)
> Iterator iterator =
> modelPackage.getMofPackage().refAllOfClass().iterator();
> while (iterator.hasNext()) {
> MofPackage mofPackage = (MofPackage)iterator.next();
> if ("SPEM".equals(mofPackage.getName())) {
> spemPackage = (SpemPackage)repository.createExtent(MODEL_EXTENT,
> mofPackage);
> URL xmiSpemModel = this.getClass().getResource(SPEM_MODEL);
> xmiReader.read(xmiSpemModel.toString(), spemPackage);
> break;
> }
> }
>
> Leo
>
> Cheng yong wrote:
> > Hello, everyone,
> >
> > I'm now making my own example according to the online document
> and try
> > to figure out how the MDR works. Now I have got an
> NullPointerException
> > Error. Can anyone help me?
> >
> > What I did is as following:
> > 1. NetBeans IDE 3.5.1: imported Metadata UML 1.4
> (01-02-15_Diff.xml) and
> > generated the JMI Interfaces.
> > 2. Eclipse 3.1: created a new project, added all .jar files
> which I can
> > find in the installation folder, imported all generated files.
> > 3. Eclipse 3.1: created a new demo class,
> >
> > package demo;
> > import java.io.OutputStream;
> > import java.util.Iterator;
> > import org.netbeans.api.mdr.MDRManager;
> > import org.netbeans.api.mdr.MDRepository;
> > import org.netbeans.api.xmi.XMIWriterFactory;
> > import org.omg.uml.*;
> > import org.omg.uml.behavioralelements.activitygraphs.*;
> > public class Demo {
> >
> > public static void main(String[] args) {
> >
> > OutputStream out = null;
> >
> > MDRepository repository =
> > MDRManager.getDefault().getDefaultRepository();
> >
> > UmlPackage extent = (UmlPackage) repository.getExtent("Projects
> > metadata");
> > try{
> >
> >
> XMIWriterFactory.getDefault().createXMIWriter().write(out,extent,"1.2");
> > System.out.println(out.toString());
> > } catch(Exception e){
> > System.out.println("ERROR!");
> > }
> > }
> > }
> > 4. Eclipse 3.1: runed the demo, got the error:
> >
> > java.lang.NullPointerException
> > at
> >
> org.netbeans.modules.mdr.MDRManagerImpl.refreshChildren(MDRManagerImpl.java:61)
> > at
> org.netbeans.modules.mdr.MDRManagerImpl.init(MDRManagerImpl.java:84)
> > at
> >
> org.netbeans.modules.mdr.MDRManagerImpl.getRepository(MDRManagerImpl.java:94)
> > at
> >
> org.netbeans.modules.mdr.MDRManagerImpl.getDefaultRepository(MDRManagerImpl.java:105)
> > at demo.Demo.main(Demo.java:18)
> > Exception in thread "main"
> >
> > thanks
> >
> > Lucia
> >
> >
> ------------------------------------------------------------------------
> > Start your day with Yahoo! - make it your home page
> >
>
> ------------------------------------------------------------------------
> Start your day with Yahoo! - make it your home page 
> 



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com