Skip to main content

About running osgi in action's paint sample on glassfish

No replies
codeprince
Offline
Joined: 2007-05-10
Points: 0

Hi sahoo, gf's users

Whether remembering osgi in action's paint sample or not?

Today, I tried to deploy and run the sample in glassfish v4(my current
snapshot) and found some interesting thing and want to share it with you.

If not modifying anything related glassfish config, after starting
domain and deploying org.foo.paint bundle using "asadmin deploy
--type=osgi ..." , you will see the following exception on cmd shell(my
env is windows xp) and paint frame can not be displayed,

...|java.lang.reflect.InvocationTargetException
at java.awt.EventQueue.invokeAndWait(EventQueue.java:1055)
at
javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1326)
at org.foo.paint.Activator.start(Activator.java:56)
at
org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:641)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1977)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1895)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:944)
at
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1175)
at
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:1153)
at
org.apache.felix.fileinstall.internal.DirectoryWatcher.processAllBundles(DirectoryWatcher.java:1146)
at
org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:456)
at
org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:263)
Caused by: java.awt.HeadlessException
at
java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:159)
at java.awt.Window.(Window.java:433)
at java.awt.Frame.(Frame.java:403)
at javax.swing.JFrame.(JFrame.java:202)
at org.foo.paint.PaintFrame.(PaintFrame.java:50)
at org.foo.paint.Activator.run(Activator.java:80)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
at java.awt.EventQueue.access$000(EventQueue.java:84)
at java.awt.EventQueue$1.run(EventQueue.java:607)
at java.awt.EventQueue$1.run(EventQueue.java:605)
at java.security.AccessController.doPrivileged(Native Method)
at
java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:616)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
|#]

Then, I ever discussed with sahoo and sahoo said that "asadmin
start-domain" will make glassfish to be background running mode, you can
use "java -jar modules/glassfish.jar" or "asadmin start-domain -v".

Then, I start to try to do, however, the same error still happened.

By investigating , I found that on domain.xml, the following JVM option
has been set,

-Djava.awt.headless=true

Once setting the option, glassfish will turn off Graphic related
resource, So, I edited the domain.xml and set -Djava.awt.headless=false.

Then, after re-starting glassfish domain whether using "asadmin
start-domain" or "java -jar modules/glassfish.jar" all ran the paint
bundle successfully.

Note: "java -jar modules/glassfish.jar" also reads options in domain.xml.

Thanks.
--Tang