单击按钮时无法从applet调用EmbeddedNeo4j

时间:2014-02-23 18:50:25

标签: java applet neo4j japplet

我正在尝试通过单击提交按钮从我的Java Applet form.class中调用EmbeddedNeo4j程序来创建节点。 我面临以下问题 1.MY程序在达到以下代码行后停止工作

     GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);

我开始知道这一点,因为我在applet中使用了JOptionPane。

我在form.java中的actionPerformed方法中调用的函数中创建了EmbeddedNeo4j的对象

public void actionPerformed(ActionEvent ae)
    {
         callFunction();
    }



    public void callFunction()
    {
         String test;
         EmbeddedNeo4j hello = new EmbeddedNeo4j();
         test=hello.createDb();
         JOptionPane.showMessageDialog( frame,test);

     }

我的EmbeddedNeo4j的一部分就是这个

  public class EmbeddedNeo4j
 {
   private static final String DB_PATH = "C://neo4j-community-1.9.6//data//graph.db";
   public String greeting;
   GraphDatabaseService graphDb;
   Node firstNode;
   Node secondNode;
   Relationship relationship;

private static enum RelTypes implements RelationshipType
{
    KNOWS
}

 String createDb()
{

    graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);
    Transaction tx=null;
    try
    {
         tx= graphDb.beginTx();
         firstNode = graphDb.createNode();
        firstNode.setProperty( "message", "Hello, " );
        secondNode = graphDb.createNode();
        secondNode.setProperty( "message", "World!" );

        relationship = firstNode.createRelationshipTo( secondNode, RelTypes.KNOWS );
        relationship.setProperty( "message", "brave Neo4j " );

        System.out.print( firstNode.getProperty( "message" ) );
        System.out.print( relationship.getProperty( "message" ) );
        System.out.print( secondNode.getProperty( "message" ) );
        // END SNIPPET: readData

        greeting = ( (String) firstNode.getProperty( "message" ) )
                   + ( (String) relationship.getProperty( "message" ) )
                   + ( (String) secondNode.getProperty( "message" ) );


        tx.success();
    }
    catch(Exception e)
    {
        tx.failure();
    }
    finally
    {

        tx.finish();
        return greeting;

    }
        }}  During trial and error I found that if I change the value of greeting before                       GraphDatabaseService graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(DB_PATH);               It will open a dialog box.Any idea what is causing this problem?

我的问题的stackTrace是这个

                        [java.lang.Thread.getStackTrace(Thread.java:1588), EmbeddedNeo4j.start(EmbeddedNeo4j.java:48), 
            form.callFunction(form.java:170), form.actionPerformed(form.java:151), 
            javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018), 
            javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341), 
            javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402), 
            javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259), 
            javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252), 
            java.awt.Component.processMouseEvent(Component.java:6505), 
            javax.swing.JComponent.processMouseEvent(JComponent.java:3320), 
            java.awt.Component.processEvent(Component.java:6270), 
            java.awt.Container.processEvent(Container.java:2229), 
            java.awt.Component.dispatchEventImpl(Component.java:4861), 
            java.awt.Container.dispatchEventImpl(Container.java:2287),
             java.awt.Component.dispatchEvent(Component.java:4687), 
             java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832), 
             java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492),
             java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422),
             java.awt.Container.dispatchEventImpl(Container.java:2273), 
             java.awt.Component.dispatchEvent(Component.java:4687), 
             java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735), 
             java.awt.EventQueue.access$200(EventQueue.java:103), 
             java.awt.EventQueue$3.run(EventQueue.java:694),
             java.awt.EventQueue$3.run(EventQueue.java:692), 
             java.security.AccessController.doPrivileged(Native Method),
             java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76),
             java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87), 
             java.awt.EventQueue$4.run(EventQueue.java:708), 
             java.awt.EventQueue$4.run(EventQueue.java:706),
             java.security.AccessController.doPrivileged(Native Method),
             java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76), 
             java.awt.EventQueue.dispatchEvent(EventQueue.java:705), 
             java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242), 
             java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161), 
             java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150), 
             java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146), 
             java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138),
             java.awt.EventDispatchThread.run(EventDispatchThread.java:91)]

0 个答案:

没有答案