0 Replies Latest reply on Nov 23, 2005 12:43 PM by Achim Breunig

    Using Swing within EJB

    Achim Breunig Newbie

      I know it sounds a little bit strange, but I want to use Swing within a EJB-Session bean.
      I try the following:

      @Stateless
      public class HelloWorldBean implements HelloWorldLocal, HelloWorldRemote{
       public void sayHello(String name) {
       try {
       JOptionPane.showMessageDialog(null, "Hello " + name + "!");
       } catch (Exception e) {
       e.printStackTrace();
       }
       }
      }



      When I call the sayHello Method from a client, I get the following exception in

      17:38:42,705 INFO [STDOUT] java.lang.NullPointerException
      17:38:42,705 INFO [STDOUT] at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1170)
      17:38:42,705 INFO [STDOUT] at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:147)
      17:38:42,705 INFO [STDOUT] at sun.awt.FontConfiguration.<init>(FontConfiguration.java:72)
      17:38:42,705 INFO [STDOUT] at sun.awt.windows.WFontConfiguration.<init>(WFontConfiguration.java:24)
      17:38:42,705 INFO [STDOUT] at sun.awt.Win32GraphicsEnvironment.createFontConfiguration(Win32GraphicsEnvironment.java:291)
      17:38:42,721 INFO [STDOUT] at sun.java2d.SunGraphicsEnvironment$1.run(SunGraphicsEnvironment.java:186)
      17:38:42,721 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method)
      17:38:42,721 INFO [STDOUT] at sun.java2d.SunGraphicsEnvironment.<init>(SunGraphicsEnvironment.java:94)
      17:38:42,721 INFO [STDOUT] at sun.awt.Win32GraphicsEnvironment.<init>(Win32GraphicsEnvironment.java:73)
      17:38:42,752 INFO [STDOUT] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      17:38:42,768 INFO [STDOUT] at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      17:38:42,768 INFO [STDOUT] at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      17:38:42,768 INFO [STDOUT] at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      17:38:42,768 INFO [STDOUT] at java.lang.Class.newInstance0(Class.java:350)
      17:38:42,768 INFO [STDOUT] at java.lang.Class.newInstance(Class.java:303)
      17:38:42,768 INFO [STDOUT] at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:68)
      17:38:42,768 INFO [STDOUT] at sun.font.FontDesignMetrics.createDefaultFrc(FontDesignMetrics.java:127)
      17:38:42,768 INFO [STDOUT] at sun.font.FontDesignMetrics.<init>(FontDesignMetrics.java:145)
      17:38:42,768 INFO [STDOUT] at sun.awt.SunToolkit.getFontMetrics(SunToolkit.java:562)
      17:38:42,768 INFO [STDOUT] at sun.awt.windows.WToolkit.getFontMetrics(WToolkit.java:537)
      17:38:42,768 INFO [STDOUT] at java.awt.Component.getFontMetrics(Component.java:2524)
      17:38:42,768 INFO [STDOUT] at javax.swing.JComponent.getFontMetrics(JComponent.java:1580)
      17:38:42,768 INFO [STDOUT] at javax.swing.plaf.basic.BasicGraphicsUtils.getPreferredButtonSize(BasicGraphicsUtils.java:256)
      17:38:42,768 INFO [STDOUT] at javax.swing.plaf.basic.BasicButtonUI.getPreferredSize(BasicButtonUI.java:352)
      17:38:42,768 INFO [STDOUT] at javax.swing.plaf.basic.BasicButtonUI.getMinimumSize(BasicButtonUI.java:342)
      17:38:42,768 INFO [STDOUT] at javax.swing.JComponent.getMinimumSize(JComponent.java:1695)
      17:38:42,768 INFO [STDOUT] at javax.swing.plaf.basic.BasicOptionPaneUI.addButtonComponents(BasicOptionPaneUI.java:675)
      17:38:42,768 INFO [STDOUT] at javax.swing.plaf.basic.BasicOptionPaneUI.createButtonArea(BasicOptionPaneUI.java:613)
      17:38:42,768 INFO [STDOUT] at javax.swing.plaf.basic.BasicOptionPaneUI.installComponents(BasicOptionPaneUI.java:161)
      17:38:42,768 INFO [STDOUT] at javax.swing.plaf.basic.BasicOptionPaneUI.installUI(BasicOptionPaneUI.java:124)
      17:38:42,768 INFO [STDOUT] at javax.swing.JComponent.setUI(JComponent.java:652)
      17:38:42,768 INFO [STDOUT] at javax.swing.JOptionPane.setUI(JOptionPane.java:1788)
      17:38:42,768 INFO [STDOUT] at javax.swing.JOptionPane.updateUI(JOptionPane.java:1810)
      17:38:42,768 INFO [STDOUT] at javax.swing.JOptionPane.<init>(JOptionPane.java:1773)
      17:38:42,768 INFO [STDOUT] at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:831)
      17:38:42,768 INFO [STDOUT] at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:645)
      17:38:42,768 INFO [STDOUT] at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:616)
      17:38:42,768 INFO [STDOUT] at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:587)
      17:38:42,768 INFO [STDOUT] at test.HelloWorldBean.sayHello(HelloWorldBean.java:11)
      17:38:42,768 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      17:38:42,768 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      17:38:42,768 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      17:38:42,768 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:109)
      17:38:42,768 INFO [STDOUT] at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:32)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      17:38:42,768 INFO [STDOUT] at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:66)
      17:38:42,768 INFO [STDOUT] at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      17:38:42,768 INFO [STDOUT] at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      17:38:42,768 INFO [STDOUT] at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:39)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      17:38:42,768 INFO [STDOUT] at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      17:38:42,768 INFO [STDOUT] at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      17:38:42,768 INFO [STDOUT] at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
      17:38:42,768 INFO [STDOUT] at org.jboss.ejb3.stateless.StatelessContainer.dynamicInvoke(StatelessContainer.java:189)
      17:38:42,768 INFO [STDOUT] at org.jboss.aop.Dispatcher.invoke(Dispatcher.java:107)
      17:38:42,768 INFO [STDOUT] at org.jboss.aspects.remoting.AOPRemotingInvocationHandler.invoke(AOPRemotingInvocationHandler.java:69)
      17:38:42,768 INFO [STDOUT] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:566)
      17:38:42,768 INFO [STDOUT] at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:436)
      17:38:42,768 INFO [STDOUT] at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:247)
      17:38:42,768 INFO [STDOUT] at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:285)
      17:38:42,768 INFO [STDOUT] at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:169)
      

      The same happens, if I try this with the Local-Interface in a Web-Application.

      Thanks in advance.