peter created JRUBY-6514:
----------------------------
Summary: java.lang.NullPointerException when using
ScriptingCotainer from an Appletjava.lang.NullPointerException
Key: JRUBY-6514
URL: https://jira.codehaus.org/browse/JRUBY-6514
Project: JRuby
Issue Type: Bug
Affects Versions: JRuby 1.6.7
Environment: Win7 64 bit
Netbeans 7.1
jdk-7u3
Reporter: peter
Assignee: Thomas E Enebo
Priority: Critical
Call Rubyscript results in NullPonterException when called from a JApplet:
Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException
at
org.jruby.util.OSEnvironment.addRubyKeyValuePair(OSEnvironment.java:101)
at
org.jruby.util.OSEnvironment.getAsMapOfRubyStrings(OSEnvironment.java:85)
at
org.jruby.util.OSEnvironment.getEnvironmentVariableMap(OSEnvironment.java:51)
at org.jruby.RubyGlobal.defineGlobalEnvConstants(RubyGlobal.java:411)
at org.jruby.RubyGlobal.createGlobals(RubyGlobal.java:363)
at org.jruby.Ruby.init(Ruby.java:1094)
at org.jruby.Ruby.newInstance(Ruby.java:184)
at
org.jruby.embed.internal.LocalContext.getThreadSafeRuntime(LocalContext.java:69)
at
org.jruby.embed.internal.ThreadSafeLocalContextProvider.getRuntime(ThreadSafeLocalContextProvider.java:61)
at
org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.runParser(EmbedRubyRuntimeAdapterImpl.java:166)
at
org.jruby.embed.internal.EmbedRubyRuntimeAdapterImpl.parse(EmbedRubyRuntimeAdapterImpl.java:93)
at
org.jruby.embed.ScriptingContainer.parse(ScriptingContainer.java:1195)
at
org.jruby.embed.ScriptingContainer.runScriptlet(ScriptingContainer.java:1255)
at
javaappletnruby.NewJApplet.jButton1ActionPerformed(NewJApplet.java:102)
at javaappletnruby.NewJApplet.access$200(NewJApplet.java:14)
at javaappletnruby.NewJApplet$2.actionPerformed(NewJApplet.java:79)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown
Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
Source)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.awt.EventQueue$4.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown
Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
plugin2manager.parentwindowDispose
Code:
import org.jruby.embed.LocalContextScope;
import org.jruby.embed.ScriptingContainer;
/**
*
* @author z0032mnt
*/
public class NewJApplet extends javax.swing.JApplet {
private ScriptingContainer c;
/**
* Initializes the applet NewJApplet
*/
@Override
public void init() {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting
code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and feel. For details see
*
http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info :
javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJApplet.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
}
//</editor-fold>
/*
* Create and display the applet
*/
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
c = new ScriptingContainer(LocalContextScope.THREADSAFE);
c.runScriptlet("puts 'wooopwoop'");
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* This method is called from within the init() method to initialize the
* form. WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton1.setText("jButton1");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(139, 139, 139)
.addComponent(jButton1)
.addContainerGap(188, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addComponent(jButton1)
.addContainerGap(206, Short.MAX_VALUE))
);
}// </editor-fold>
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
c.runScriptlet("puts 'wooopwoop'");
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
// End of variables declaration
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email