&引用;AWT-EventQueue-0“;使用import net.jini.export.Exporter时java.lang.ExceptionInInitializeError错误;

&引用;AWT-EventQueue-0“;使用import net.jini.export.Exporter时java.lang.ExceptionInInitializeError错误;,java,swing,jini,Java,Swing,Jini,我正在尝试创建一个需要使用JavaSpace的聊天系统。在大多数情况下,这是有效的,除了当尝试让自动通知工作时,以便在添加条目时从空间向列表添加新条目时可以更新我的列表。当我得到java.lang.ExceptionInInitializeError时,这已经成为一个问题。完整的跟踪输出如下所示 Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError at com.sun.jini.thread.G

我正在尝试创建一个需要使用JavaSpace的聊天系统。在大多数情况下,这是有效的,除了当尝试让自动通知工作时,以便在添加条目时从空间向列表添加新条目时可以更新我的列表。当我得到java.lang.ExceptionInInitializeError时,这已经成为一个问题。完整的跟踪输出如下所示

Exception in thread "AWT-EventQueue-0" java.lang.ExceptionInInitializerError
at com.sun.jini.thread.GetThreadPoolAction.<clinit>(GetThreadPoolAction.java:52)
at net.jini.jeri.tcp.TcpServerEndpoint.<clinit>(TcpServerEndpoint.java:117)
at com.chat.client.gui.Topics.<init>(Topics.java:129)
at com.chat.client.gui.Main.actionPerformed(Main.java:114)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6382)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3275)
at java.awt.Component.processEvent(Component.java:6147)
at java.awt.Container.processEvent(Container.java:2083)
at java.awt.Component.dispatchEventImpl(Component.java:4744)
at java.awt.Container.dispatchEventImpl(Container.java:2141)
at java.awt.Component.dispatchEvent(Component.java:4572)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4619)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4280)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4210)
at java.awt.Container.dispatchEventImpl(Container.java:2127)
at java.awt.Window.dispatchEventImpl(Window.java:2489)
at java.awt.Component.dispatchEvent(Component.java:4572)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:704)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:663)
at java.awt.EventQueue$2.run(EventQueue.java:661)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$3.run(EventQueue.java:677)
at java.awt.EventQueue$3.run(EventQueue.java:675)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:674)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:549)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkAccess(SecurityManager.java:712)
at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:299)
at java.lang.ThreadGroup.getParent(ThreadGroup.java:150)
at com.sun.jini.thread.NewThreadAction$1.run(NewThreadAction.java:54)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.jini.thread.NewThreadAction.<clinit>(NewThreadAction.java:49)
... 40 more
线程“AWT-EventQueue-0”java.lang.ExceptionInInitializeError中的异常 位于com.sun.jini.thread.GetThreadPoolAction。(GetThreadPoolAction.java:52) 位于net.jini.jeri.tcp.TcpServerEndpoint。(TcpServerEndpoint.java:117) 位于com.chat.client.gui.Topics.(Topics.java:129) 在com.chat.client.gui.Main.actionPerformed上(Main.java:114) 在javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028) 位于javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351) 在javax.swing.DefaultButtonModel.fireActionPerformed上(DefaultButtonModel.java:387) 在javax.swing.DefaultButtonModel.setPressed中(DefaultButtonModel.java:242) 在javax.swing.plaf.basic.BasicButtonListener.mouseRelease(BasicButtonListener.java:236) 位于java.awt.Component.ProcessMouseeEvent(Component.java:6382) 位于javax.swing.JComponent.ProcessMouseeEvent(JComponent.java:3275) 位于java.awt.Component.processEvent(Component.java:6147) 位于java.awt.Container.processEvent(Container.java:2083) 位于java.awt.Component.dispatchEventImpl(Component.java:4744) 位于java.awt.Container.dispatchEventImpl(Container.java:2141) 位于java.awt.Component.dispatchEvent(Component.java:4572) 位于java.awt.LightweightDispatcher.RetargetMouseeEvent(Container.java:4619) 位于java.awt.LightweightDispatcher.ProcessMouseeEvent(Container.java:4280) 位于java.awt.LightweightDispatcher.dispatchEvent(Container.java:4210) 位于java.awt.Container.dispatchEventImpl(Container.java:2127) 位于java.awt.Window.dispatchEventImpl(Window.java:2489) 位于java.awt.Component.dispatchEvent(Component.java:4572) 位于java.awt.EventQueue.dispatchEventImpl(EventQueue.java:704) 在java.awt.EventQueue.access$400(EventQueue.java:82) 位于java.awt.EventQueue$2.run(EventQueue.java:663) 在java.awt.EventQueue$2.run(EventQueue.java:661) 位于java.security.AccessController.doPrivileged(本机方法) 位于java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) 位于java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98) 在java.awt.EventQueue$3.run(EventQueue.java:677) 在java.awt.EventQueue$3.run(EventQueue.java:675) 位于java.security.AccessController.doPrivileged(本机方法) 位于java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) 位于java.awt.EventQueue.dispatchEvent(EventQueue.java:674) 位于java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) 位于java.awt.EventDispatchThread.PumpeEventsforFilter(EventDispatchThread.java:211) 位于java.awt.EventDispatchThread.PumpeEventsforHierarchy(EventDispatchThread.java:201) 位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) 位于java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) 在java.awt.EventDispatchThread.run处(EventDispatchThread.java:122) 原因:java.security.AccessControlException:拒绝访问(java.lang.RuntimePermission modifyThreadGroup) 位于java.security.AccessControlContext.checkPermission(AccessControlContext.java:374) 在java.security.AccessController.checkPermission(AccessController.java:549) 位于java.lang.SecurityManager.checkPermission(SecurityManager.java:532) 位于java.lang.SecurityManager.checkAccess(SecurityManager.java:712) 位于java.lang.ThreadGroup.checkAccess(ThreadGroup.java:299) 位于java.lang.ThreadGroup.getParent(ThreadGroup.java:150) 在com.sun.jini.thread.NewThreadAction$1.run(NewThreadAction.java:54)上 位于java.security.AccessController.doPrivileged(本机方法) 位于com.sun.jini.thread.NewThreadAction。(NewThreadAction.java:49) ... 40多 下面是我正在使用的代码

package com.chat.client.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.rmi.RemoteException;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.ListModel;
import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;
import net.jini.core.entry.UnusableEntryException;
import net.jini.core.lease.Lease;
import net.jini.core.transaction.TransactionException;
import net.jini.space.JavaSpace;
import com.chat.client.backend.SpaceUtils;
import com.chat.client.backend.Topic;
import com.chat.client.backend.TopicList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import net.jini.core.event.RemoteEvent;
import net.jini.core.event.RemoteEventListener
import java.rmi.server.*;
import java.rmi.RemoteException;
import net.jini.core.event.*;
import net.jini.export.Exporter;
import net.jini.jeri.BasicILFactory;
import net.jini.jeri.BasicJeriExporter;
import net.jini.jeri.tcp.TcpServerEndpoint;
import java.rmi.RMISecurityManager;

public class Topics extends javax.swing.JFrame implements ActionListener,         RemoteEventListener {
private JList topicList;
private JScrollPane jScrollPane1;
private JButton exitButton;
private JButton closeButton;
private JButton joinTopic;
private JButton addButton;
private JLabel jLabel2;
private JLabel jLabel1;
private JTextField topicNameTextField;


/*
 * user added variables
 */
private static JavaSpace space;
private String ownersName;
private String[] theTopics;
    private boolean isFirstTimeStart = true;
    private TopicList theList = null;
    private TopicList template_list = null;
    private ArrayList<String> topics;
    private DefaultListModel topicListModel;
    private RemoteEventListener theStub;
/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) throws RemoteException{
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            Topics inst = new Topics();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
        }
    });
}

public Topics() {
    super();
            space = SpaceUtils.getSpace();
            if (space == null){
                    System.err.println("Failed to find the javaspace");
                    System.exit(1);
            }

           try{ 
            if (System.getSecurityManager() == null) {
                System.setSecurityManager(new RMISecurityManager());
            }
            Exporter myDefaultExporter = 
                new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
                    new BasicILFactory(), false, true);
           } catch(Exception ex) {

           }
    initGUI();
}

public Topics(String s) {
    super();
            space = SpaceUtils.getSpace();
            if (space == null){
                    System.err.println("Failed to find the javaspace");
                    System.exit(1);
            }

            try {
                if (System.getSecurityManager() == null) {
                    System.setSecurityManager(new RMISecurityManager());
                }
        /*****The issue seems to arise here when instantiating the Exporter **********/
                // create the exporter
                Exporter myDefaultExporter = 
                    new BasicJeriExporter(TcpServerEndpoint.getInstance(0),
                        new BasicILFactory(), false, true);

                // register this as a remote object 
                // and get a reference to the 'stub'
                theStub = (RemoteEventListener) myDefaultExporter.export(this);

                // add the listener
                space.notify(template_list, null, this.theStub, Lease.FOREVER, null);     

                ownersName = s; when using 
                topics = new ArrayList<String>();
                topicListModel = new DefaultListModel();
                template_list = null;
                template_list = new TopicList();


                System.out.println("trying to get the list from the space");
                theList = null;
                theList = (TopicList) space.take(template_list, null, Long.MAX_VALUE);
                System.out.println("Got the list");
                if(!theList.topics.isEmpty() && theList.topicListName.equals("GZSpace")) {
                    System.out.println("list is not empty");
                    for(int i = 0; i < theList.topics.size(); i++) {
                        topicListModel.addElement(theList.topics.get(i));
                    }
                    space.write(theList, null, Lease.FOREVER);
                } else {
                    space.write(theList, null, Lease.FOREVER);
                }
            } catch (UnusableEntryException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TransactionException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InterruptedException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (RemoteException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            }
            initGUI();
}

private void initGUI() {
    try {
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(230, 43, 142, 170);
            {
                                topicList = new JList(topicListModel);
                                jScrollPane1.setViewportView(topicList);
                                topicList.setModel(topicListModel);
                                topicList.setBounds(230, 43, 142, 170);
            }
        }
        {
            topicNameTextField = new JTextField();
            getContentPane().add(topicNameTextField);
            topicNameTextField.setBounds(80, 43, 145, 23);
        }
        {
            jLabel1 = new JLabel();
            getContentPane().add(jLabel1);
            jLabel1.setText("To create a topic, enter the name below and click add");
            jLabel1.setBounds(12, 15, 355, 16);
        }
        {
            jLabel2 = new JLabel();
            getContentPane().add(jLabel2);
            jLabel2.setText("Topic Name:");
            jLabel2.setBounds(12, 46, 68, 16);
        }
        {
            addButton = new JButton();
            getContentPane().add(addButton);
            addButton.setText("Add New " +
                    "Topic");
            addButton.setBounds(12, 88, 213, 23);
            addButton.addActionListener(this);
        }
        {
            joinTopic = new JButton();
            getContentPane().add(joinTopic);
            joinTopic.setText("Join Existing Topic");
            joinTopic.setBounds(12, 122, 213, 23);
            joinTopic.addActionListener(this);
        }
        {
            closeButton = new JButton();
            getContentPane().add(closeButton);
            closeButton.setText("Close ");
            closeButton.setBounds(12, 156, 213, 23);
            closeButton.addActionListener(this);
        }
        {
            exitButton = new JButton();
            getContentPane().add(exitButton);
            exitButton.setText("Exit Chat System");
            exitButton.setBounds(12, 190, 213, 23);
            exitButton.addActionListener(this);
        }
        pack();
        this.setSize(400, 269);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

@Override
public void actionPerformed(ActionEvent e) {
    if(e.getSource() == addButton) {
            try {
                theList = null;
                template_list = null;
                theList = (TopicList) space.take(template_list, null, Long.MAX_VALUE);
                if(!theList.topics.isEmpty() && theList.topicListName.equals("GZSpace")) {
                    theList.topics.add(topicNameTextField.getText());
                    topicListModel.addElement(topicNameTextField.getText());
                    topicNameTextField.setText("");
                    space.write(theList, null, Lease.FOREVER);
                } else {
                    space.write(theList, null, Lease.FOREVER);
                }

            } catch (UnusableEntryException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (TransactionException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InterruptedException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            } catch (RemoteException ex) {
                Logger.getLogger(Topics.class.getName()).log(Level.SEVERE, null, ex);
            }
    }

    if(e.getSource() == joinTopic) {

    }

    if(e.getSource() == closeButton) {
        Main main = new Main();
        main.setLocationRelativeTo(null);
        main.setVisible(true);
        dispose();
    }

    if(e.getSource() == exitButton) {
        dispose();
    }

}

    public void notify(RemoteEvent ev) {
        // this is the method called when we are notified
        // of an object of interest
        TopicList template = new TopicList();

        try {
            TopicList theList = (TopicList)space.take(template, null, Long.MAX_VALUE);
            for(int i = 0; i < theList.topics.size(); i++) {
                topicListModel.addElement(theList.topics.get(i));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        // that's all we need to do in this demo so we can quit...
        System.exit(0);
    }
}
package com.chat.client.gui;
导入java.awt.event.ActionEvent;
导入java.awt.event.ActionListener;
导入java.rmi.RemoteException;
导入java.util.ArrayList;
导入javax.swing.DefaultComboxModel;
导入javax.swing.JButton;
导入javax.swing.JLabel;
导入javax.swing.JList;
导入javax.swing.JScrollPane;
导入javax.swing.JTextField;
导入javax.swing.ListModel;
导入javax.swing.WindowConstants;
导入javax.swing.SwingUtilities;
导入net.jini.core.entry.UnusableEntryException;
导入net.jini.core.lease.lease;
导入net.jini.core.transaction.TransactionException;
导入net.jini.space.JavaSpace;
导入com.chat.client.backend.SpaceUtils;
导入com.chat.client.backend.Topic;
导入com.chat.client.backend.TopicList;
导入java.util.logging.Level;
导入java.util.logging.Logger;
导入javax.swing.DefaultListModel;
导入net.jini.core.event.RemoteEvent;
导入net.jini.core.event.RemoteEventListener
导入java.rmi.server.*;
导入java.rmi.RemoteException;
导入net.jini.core.event.*;
进口净额、出口额、出口商;
进口net.jini.jeri.BasicILFactory;
导入net.jini.jeri.BasicJeriExporter;
导入net.jini.jeri.tcp.TcpServerEndpoint;
导入java.rmi.RMISecurityManager;
公共类主题扩展了javax.swing.JFrame实现了ActionListener、RemoteEventListener{
私人JList主题列表;
私有JScrollPane jScrollPane1;
私有JButton exitButton;
私人按钮关闭按钮;
私有JButton主题;
私有JButton addButton;
私人JLabel jLabel2;
私人JLabel jLabel1;
私有JTextField主题名textfield;
/*
*用户添加的变量
*/
私有静态JavaSpace;
私有字符串所有者名称;
私有字符串[]主题;
私有布尔值isFirstTimeStart=true;
私有主题列表列表=null;
私有主题列表模板\u list=null;
私人ArrayList主题;
私有DefaultListModel topicListModel;
专用远程事件侦听器;
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThreadGroup)