Help! problem with TabWidget plugin that calls Algernon

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Help! problem with TabWidget plugin that calls Algernon

Mauro Jansen

(posting again):

I'll be really pleasured with any help. It's part of my master degree work.

Im developing a TabWidget plugin that will serves as a interface that will
encapsulate some Algernon scripts to query and edit the KB (it is a Domain
Engineering tool to automatically derivate a DSL vocabulary based on a ontology-
based domain model that is in the KB). Thus, it will need Algernon to run this
scripts, but the plugin doesn't run and Proege log shows the message below:

WARNING: java.lang.NoClassDefFoundError: org/algernon/kb/AlgernonKB -- PluginUti
lities.isLoadableClass()

- There is no compilation errors
- I tried put the dependency in the plugin.properties file but it doesn't solved
- Why this message occurs only with the AlgernonKB but not with the Algernon
class? Is it because the AlgernonKB is an interface?
- I note the if I remove the AlgernonKB instantiation code (f_kb variable), the
plugin runs, but without access Algernon;
- The code is based on the Algernon Example Java Program:
 http://algernon-j.sourceforge.net/doc/simple-java-example.html.
- I created a java program (not a Protege plugin) based on the Algernon Example
Java to access the KB with Algernon directly from java command line and it runs
- here is the code:
------------------------
package GENMADE_plugin;

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import edu.stanford.smi.protege.model.*;
import edu.stanford.smi.protege.widget.*;
import edu.stanford.smi.protege.resource.*;

//import org.algernon.*;

//
import org.algernon.Algernon;
import org.algernon.aam.Tracer;
import org.algernon.exception.AlgernonException;
import org.algernon.util.ErrorSet;
import org.algernon.util.gui.UneditableJTable;
import org.algernon.datatype.Result;
import org.algernon.datatype.BindingList;
import org.algernon.kb.okbc.protege.AlgernonProtegeKB;
import org.algernon.kb.okbc.protege.plugins.action.*;
import org.algernon.kb.okbc.protege.plugins.gui.LoadRulesDialog;
import org.algernon.kb.api.java.JavaAPIKB;
import org.algernon.kb.AlgernonKB;
import org.algernon.kb.*;
import org.jatha.dynatype.LispValue;
import org.jatha.read.LispParser;
import org.jatha.Jatha;

public class GENMADE extends AbstractTabWidget {
        private JTextField field;

        protected Algernon f_algy=null;
       
        // the error isn't in this line:
  private AlgernonKB f_kb=null; // AlgernonKB is an inteface
        // startup code
        public void initialize() {

                // initialize the tab label
                setLabel("GENMADE");
                setIcon(Icons.getInstanceIcon());

                // --- gets project path and name
                Project projeto = getProject();
                String varqprj = projeto.getProjectFilePath()
+"\\"+projeto.getProjectName()+".pprj";
                JLabel lbProjeto = new JLabel(varqprj);
                add(lbProjeto);

                // --- Prepare Algernon instance]
                try {
                        f_algy = new Algernon();
                        if (f_algy !=null) {
                                // aqui ocorre o erro do plugin com Algernon
                                f_kb = new AlgernonProtegeKB(f_algy,varqprj);
                                if (f_kb!=null)
                                        f_algy.addKB(f_kb);
                        }
                }
                catch (Exception e) {
                        System.err.println(e+"\nErro ao abrir o
arquivo '"+varqprj);
// errors.add(e+"\nErro ao abrir o arquivo '"+varqprj);
                        if (f_kb != null)
                                f_kb.close();
                }

                JLabel lbModelo = new JLabel("Modelo de Domínio:");
                add(lbModelo);
                JComboBox cbModelo = new JComboBox();

                // --- inicia (metodo start do exemplo)
                try {
                        ErrorSet erros=new ErrorSet();
              String   query  = "((:instance \"Domain Model\" ?Domain_Model)
(name ?Domain_Model ?name))";
                        Result result=(Result)f_algy.ask(query,erros);
                        if (result==null) {
                                System.err.println("Erro durante ask
de '"+query+"'.");
                                System.err.println(erros.toString());
                        }
                        else
                        {
                                for (Iterator iterator=result.iterator
();iterator.hasNext();)
                                {
                                        BindingList bl=(BindingList)
iterator.next();
                                        Object name=f_algy.getBinding("?
name",bl);
                                        cbModelo.addItem(name);
                                }
                        }
                } catch (Exception e) {
                        System.err.println("Erro rodando o Algernon: "+e);
                } finally {
                        if (f_kb != null)
                                f_kb.close();
                }

        // --- combo dos modelos do dominio
                add(cbModelo);

                // botao de gerar a LED
                JButton button = new JButton("Update Frame Counter");
                button.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent event) {
                                // update text field
                                int count = getKnowledgeBase().getFrameCount();
                                field.setText(String.valueOf(count));
                        }
                });

                // create the output text field
                field = new JTextField(10);
                field.setEnabled(false);
                field.setHorizontalAlignment(SwingConstants.RIGHT);

                // add the components to the tab widget
                setLayout(new FlowLayout());
                add(button);
                add(field);
  }

        // this method is useful for debugging
        public static void main(String[] args) {
                edu.stanford.smi.protege.Application.main(args);
        }
}
------------------
The compilation batch:
-----------------------
rem @echo off

setlocal
set PROTEGEHOME=c:\Arquiv~1\Protege_3.1

set CLASSPATH=.\;%PROTEGEHOME%\plugins\org.algernon\algernon.jar;%PROTEGEHOME%
\protege.jar;%PROTEGEHOME%\looks.jar;%PROTEGEHOME%\unicode_panel.jar

jre -Dprotege.dir=%PROTEGEHOME%

javac -classpath %CLASSPATH% -d %PROTEGEHOME%\plugins ./GENMADE.java

jar cvf GENMADE.jar manifest.mf GENMADE.class

rem copy GENMADE.jar %PROTEGEHOME%\plugins\GENMADE_plugin



-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Help! problem with TabWidget plugin that calls Algernon

Mauro Jansen
I put the plugin to work running Protege with the run_protege.bat batch file
with the algernon.jar (with full path) added to the JARS variable (in other
words Protege will be started with the algernon.jar in the java classpath).
It proves that the problem was that jre was not finding the path to
algernon.jar.

But, how to set this to work with the normal starting of Protege with
protege.exe?

"Mauro Jansen" <[hidden email]> escreveu na mensagem
news:[hidden email]...

(posting again):

I'll be really pleasured with any help. It's part of my master degree work.

Im developing a TabWidget plugin that will serves as a interface that will
encapsulate some Algernon scripts to query and edit the KB (it is a Domain
Engineering tool to automatically derivate a DSL vocabulary based on a
ontology-
based domain model that is in the KB). Thus, it will need Algernon to run
this
scripts, but the plugin doesn't run and Proege log shows the message below:

WARNING: java.lang.NoClassDefFoundError: org/algernon/kb/AlgernonKB --
PluginUti
lities.isLoadableClass()

- There is no compilation errors
- I tried put the dependency in the plugin.properties file but it doesn't
solved
- Why this message occurs only with the AlgernonKB but not with the Algernon
class? Is it because the AlgernonKB is an interface?
- I note the if I remove the AlgernonKB instantiation code (f_kb variable),
the
plugin runs, but without access Algernon;
- The code is based on the Algernon Example Java Program:
 http://algernon-j.sourceforge.net/doc/simple-java-example.html.
- I created a java program (not a Protege plugin) based on the Algernon
Example
Java to access the KB with Algernon directly from java command line and it
runs
- here is the code:
(...)




-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Help! problem with TabWidget plugin that calls Algernon

Mauro Jansen
In reply to this post by Mauro Jansen
I put the plugin to work running Protege with the run_protege.bat batch file
with the algernon.jar (with full path) added to the JARS variable (in other
words Protege will be started with the algernon.jar in the java classpath).
It proves that the problem was that jre was not finding the path to
algernon.jar.

But, how to set this to work with the normal starting of Protege with
protege.exe?

"Mauro Jansen" <[hidden email]> escreveu na mensagem
news:[hidden email]...

(posting again):

I'll be really pleasured with any help. It's part of my master degree work.

Im developing a TabWidget plugin that will serves as a interface that will
encapsulate some Algernon scripts to query and edit the KB (it is a Domain
Engineering tool to automatically derivate a DSL vocabulary based on a
ontology-
based domain model that is in the KB). Thus, it will need Algernon to run
this
scripts, but the plugin doesn't run and Proege log shows the message below:

WARNING: java.lang.NoClassDefFoundError: org/algernon/kb/AlgernonKB --
PluginUti
lities.isLoadableClass()

- There is no compilation errors
- I tried put the dependency in the plugin.properties file but it doesn't
solved
- Why this message occurs only with the AlgernonKB but not with the Algernon
class? Is it because the AlgernonKB is an interface?
- I note the if I remove the AlgernonKB instantiation code (f_kb variable),
the
plugin runs, but without access Algernon;
- The code is based on the Algernon Example Java Program:
 http://algernon-j.sourceforge.net/doc/simple-java-example.html.
- I created a java program (not a Protege plugin) based on the Algernon
Example
Java to access the KB with Algernon directly from java command line and it
runs
- here is the code:
(...)




-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Help! problem with TabWidget plugin that calls Algernon

Mauro Jansen
In reply to this post by Mauro Jansen

Mauro Jansen <maurojansen <at> yahoo.com.br> writes:

>
>
> (posting again):
>
> I'll be really pleasured with any help. It's part of my master degree work.
>
> Im developing a TabWidget plugin that will serves as a interface that will
> encapsulate some Algernon scripts to query and edit the KB (it is a Domain
> Engineering tool to automatically derivate a DSL vocabulary based on a
ontology-
> based domain model that is in the KB). Thus, it will need Algernon to run
this
> scripts, but the plugin doesn't run and Proege log shows the message below:
>
> WARNING: java.lang.NoClassDefFoundError: org/algernon/kb/AlgernonKB --
PluginUti
> lities.isLoadableClass()
>
> - There is no compilation errors
> - I tried put the dependency in the plugin.properties file but it doesn't
solved
> - Why this message occurs only with the AlgernonKB but not with the Algernon
> class? Is it because the AlgernonKB is an interface?
> - I note the if I remove the AlgernonKB instantiation code (f_kb variable),
the
> plugin runs, but without access Algernon;
> - The code is based on the Algernon Example Java Program:
>  http://algernon-j.sourceforge.net/doc/simple-java-example.html.
> - I created a java program (not a Protege plugin) based on the Algernon
Example
> Java to access the KB with Algernon directly from java command line and it
runs

Hi,

I put the plugin to work running Protege with the run_protege.bat batch file
with the algernon.jar (with full path) added to the JARS variable (in other
words Protege will be started with the algernon.jar in the java classpath).
It proves that the problem was that jre was not finding the path to
algernon.jar.

But, how to set this to work with the normal starting of Protege with
protege.exe?

Mauro



-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Help! problem with TabWidget plugin that calls Algernon

Tania Tudorache

Try editing the protege.lax file and add the algernon.jar to the
"lax.class.path".  Maybe that will solve your problem.

Tania

 

Mauro Jansen wrote:

>Mauro Jansen <maurojansen <at> yahoo.com.br> writes:
>
>  
>
>>(posting again):
>>
>>I'll be really pleasured with any help. It's part of my master degree work.
>>
>>Im developing a TabWidget plugin that will serves as a interface that will
>>encapsulate some Algernon scripts to query and edit the KB (it is a Domain
>>Engineering tool to automatically derivate a DSL vocabulary based on a
>>    
>>
>ontology-
>  
>
>>based domain model that is in the KB). Thus, it will need Algernon to run
>>    
>>
>this
>  
>
>>scripts, but the plugin doesn't run and Proege log shows the message below:
>>
>>WARNING: java.lang.NoClassDefFoundError: org/algernon/kb/AlgernonKB --
>>    
>>
>PluginUti
>  
>
>>lities.isLoadableClass()
>>
>>- There is no compilation errors
>>- I tried put the dependency in the plugin.properties file but it doesn't
>>    
>>
>solved
>  
>
>>- Why this message occurs only with the AlgernonKB but not with the Algernon
>>class? Is it because the AlgernonKB is an interface?
>>- I note the if I remove the AlgernonKB instantiation code (f_kb variable),
>>    
>>
>the
>  
>
>>plugin runs, but without access Algernon;
>>- The code is based on the Algernon Example Java Program:
>> http://algernon-j.sourceforge.net/doc/simple-java-example.html.
>>- I created a java program (not a Protege plugin) based on the Algernon
>>    
>>
>Example
>  
>
>>Java to access the KB with Algernon directly from java command line and it
>>    
>>
>runs
>
>Hi,
>
>I put the plugin to work running Protege with the run_protege.bat batch file
>with the algernon.jar (with full path) added to the JARS variable (in other
>words Protege will be started with the algernon.jar in the java classpath).
>It proves that the problem was that jre was not finding the path to
>algernon.jar.
>
>But, how to set this to work with the normal starting of Protege with
>protege.exe?
>
>Mauro
>
>
>
>-------------------------------------------------------------------------
>To unsubscribe go to http://protege.stanford.edu/community/subscribe.html
>
>
>  
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Help! problem with TabWidget plugin that calls Algernon

R H-2
In reply to this post by Mauro Jansen
Add the jar name to the lax.class.path line in the Protege.lax file that would make protege.exe load it.

Mauro Jansen <[hidden email]> wrote: I put the plugin to work running Protege with the run_protege.bat batch file
with the algernon.jar (with full path) added to the JARS variable (in other
words Protege will be started with the algernon.jar in the java classpath).
It proves that the problem was that jre was not finding the path to
algernon.jar.

But, how to set this to work with the normal starting of Protege with
protege.exe?

"Mauro Jansen"  escreveu na mensagem
news:[hidden email]...

(posting again):

I'll be really pleasured with any help. It's part of my master degree work.

Im developing a TabWidget plugin that will serves as a interface that will
encapsulate some Algernon scripts to query and edit the KB (it is a Domain
Engineering tool to automatically derivate a DSL vocabulary based on a
ontology-
based domain model that is in the KB). Thus, it will need Algernon to run
this
scripts, but the plugin doesn't run and Proege log shows the message below:

WARNING: java.lang.NoClassDefFoundError: org/algernon/kb/AlgernonKB --
PluginUti
lities.isLoadableClass()

- There is no compilation errors
- I tried put the dependency in the plugin.properties file but it doesn't
solved
- Why this message occurs only with the AlgernonKB but not with the Algernon
class? Is it because the AlgernonKB is an interface?
- I note the if I remove the AlgernonKB instantiation code (f_kb variable),
the
plugin runs, but without access Algernon;
- The code is based on the Algernon Example Java Program:
 http://algernon-j.sourceforge.net/doc/simple-java-example.html.
- I created a java program (not a Protege plugin) based on the Algernon
Example
Java to access the KB with Algernon directly from java command line and it
runs
- here is the code:
(...)




-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html



                       
---------------------------------
 Yahoo! Mail - Helps protect you from nasty viruses.

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Help! problem with TabWidget plugin that calls Algernon

Mauro Jansen
In reply to this post by Tania Tudorache
Thanks, It solved the problem.

Now my plugin can acces the KB to read values, but scripts with the
ADD-INSTANCE or DELETE-INSTANCE like a simple
((:add-instance
  (?Optional_Goal "Optional Goal" )
  (name ?Optional_Goal "Algernon Test")
))
are not working. Algernon generates no errors, but no instance is added or
deleted.If I run the same script in Algernon tab it works and the instance
added appear in the instances tab. Where is the problem? It is necessary any
additional java command to post or commit the "add or update" and refresh
the instances tab view to show it?

Thanks,
Mauro

"Tania Tudorache" <[hidden email]> escreveu na mensagem
news:[hidden email]...

>
> Try editing the protege.lax file and add the algernon.jar to the
> "lax.class.path".  Maybe that will solve your problem.
>
> Tania
>
>
>
> Mauro Jansen wrote:
>
> >Mauro Jansen <maurojansen <at> yahoo.com.br> writes:
> >
> >
> >
> >>(posting again):
> >>
> >>I'll be really pleasured with any help. It's part of my master degree
work.
> >>
> >>Im developing a TabWidget plugin that will serves as a interface that
will
> >>encapsulate some Algernon scripts to query and edit the KB (it is a
Domain
> >>Engineering tool to automatically derivate a DSL vocabulary based on a
> >>
> >>
> >ontology-
> >
> >
> >>based domain model that is in the KB). Thus, it will need Algernon to
run
> >>
> >>
> >this
> >
> >
> >>scripts, but the plugin doesn't run and Proege log shows the message
below:

> >>
> >>WARNING: java.lang.NoClassDefFoundError: org/algernon/kb/AlgernonKB --
> >>
> >>
> >PluginUti
> >
> >
> >>lities.isLoadableClass()
> >>
> >>- There is no compilation errors
> >>- I tried put the dependency in the plugin.properties file but it
doesn't
> >>
> >>
> >solved
> >
> >
> >>- Why this message occurs only with the AlgernonKB but not with the
Algernon
> >>class? Is it because the AlgernonKB is an interface?
> >>- I note the if I remove the AlgernonKB instantiation code (f_kb
variable),

> >>
> >>
> >the
> >
> >
> >>plugin runs, but without access Algernon;
> >>- The code is based on the Algernon Example Java Program:
> >> http://algernon-j.sourceforge.net/doc/simple-java-example.html.
> >>- I created a java program (not a Protege plugin) based on the Algernon
> >>
> >>
> >Example
> >
> >
> >>Java to access the KB with Algernon directly from java command line and
it
> >>
> >>
> >runs
> >
> >Hi,
> >
> >I put the plugin to work running Protege with the run_protege.bat batch
file
> >with the algernon.jar (with full path) added to the JARS variable (in
other
> >words Protege will be started with the algernon.jar in the java
classpath).

> >It proves that the problem was that jre was not finding the path to
> >algernon.jar.
> >
> >But, how to set this to work with the normal starting of Protege with
> >protege.exe?
> >
> >Mauro
> >
> >
> >
> >-------------------------------------------------------------------------
> >To unsubscribe go to http://protege.stanford.edu/community/subscribe.html
> >
> >
> >
> >
>
> -------------------------------------------------------------------------
> To unsubscribe go to http://protege.stanford.edu/community/subscribe.html
>
>



-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Re: Help! problem with TabWidget plugin that calls Algernon

Mauro Jansen
In reply to this post by Tania Tudorache

Tania Tudorache <tudorache <at> stanford.edu> writes:

>
>
> Try editing the protege.lax file and add the algernon.jar to the
> "lax.class.path".  Maybe that will solve your problem.
>
> Tania

Thanks, It solved the problem.

Now my plugin can access the KB to read values, but scripts with the
ADD-INSTANCE or DELETE-INSTANCE like a simple
((:add-instance
  (?Optional_Goal "Optional Goal" )
  (name ?Optional_Goal "Algernon Test")
))
are not working. Algernon generates no errors, but no instance is added or
deleted. If I run the same script in Algernon tab it works and the instance
added appear in the instances tab. Where is the problem? It is necessary any
additional java command to post or commit the "add or update" and refresh
the instances tab view to show it? I tried run the command, save the project,
close and reload, but the instance was really not added.

Thanks,
Mauro

> >
> >Hi,
> >
> >I put the plugin to work running Protege with the run_protege.bat batch file
> >with the algernon.jar (with full path) added to the JARS variable (in other
> >words Protege will be started with the algernon.jar in the java classpath).
> >It proves that the problem was that jre was not finding the path to
> >algernon.jar.
> >
> >But, how to set this to work with the normal starting of Protege with
> >protege.exe?
> >
> >Mauro


-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

Protégé to manage thesaurus ?

Christian Fauré-2
In reply to this post by Mauro Jansen

Hello,
Did anyone uses Protégé to manage and to federate different thesaurus ?
Is that possible ?

Regards,
Christian.
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html