Most VM Threads hang at Class.forName0 and ZipFile.getEntry calls

I have production Java (1.4) system which runs on Linux (hyperthreading ON, Linux 2.4.21-27.ELsmp #1 SMP). The "top" command consistently shows "VM Thread" to be the highest CPU user. There is no load on the system and the system used to run just fine in past. The dumps consistently show "VM Thread" to be one of the runnable threads. In almost all dumps we have around 50 runnable threads of the 300 odd threads. Most of them are stuck inside native calls to Class.forName0 or ZipFile.getEntry() waiting on a condition (internal VM condition, I presume)
I think GC is running too often, but I am unable to understand why should it suddenly behave so? Whenever the issue surfaces the dumps are almost replica of one another. Is there anyone who has faced/ solved such an issue with entire dumps almost full of native Class.forName0() calls and ZipFile.getEntry() calls?
Please help. Any help appreicated.

Seems to be this Sun Java6 issue
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500212
(and duplicates) in conjunction with Hibernate's DeserializationHelper.
Opened Hibernate Bug:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2990
Cheers, Tom.

Similar Messages

  • How to load a class dynamically and then a call a method?

    Hi
    I want to call a method from a class,which class is loaded dynamically.
    Consider a classA and ClassB..
    ClassB contains a method showvalue() which returns a String value.
    I want to load a ClassB dynamically in ClassA,and call the method showvalue() and print the returned value of that method (showvalue).
    How to do this?
    Thanks

    Since you found your way to Reflections and Reference Objects, I can only assume you know that reflection is the answer. Since the reflection tutorial on this site, and indeed, the many others on the web, can explain this a whole lot better and more consisely than can be done in a forum, I'll point you in that direction instead. As a starting point, and to show I'm not just fobbing you off, you're interested in the classes java.lang.Class, java.lang.reflect.Method, and the method Class.getMethod(String, Class[])

  • Variants class 200 and 300

    what are the differences between the variant classes 200 and 300.
    where we have to select 200 class and where we have to select 300 class in variant configuration.
    thanking you
    srinivas pai

    Thanks for marking thread useful.
    Class 300 and 200 are both defined for the materials.class 300 is mainly used for a variant material used for variant configurartion.We can also classify materials under class 200 which do not have to be configurable materials.But allows to use the defined characteristics and restrict the usage for a specific purpose..
    Please check below threads
    http://scn.sap.com/thread/631073
    https://scn.sap.com/thread/576848
    Yes you can copy class and create your new class .
    can you please share your business requirement, what kind of solution your are budiling with this?
    Thanks
    Ritesh

  • Difference between class 200 and 300

    Experts,
    Can i use class 200 for varient configuration?
    I want to know difference between class 200 and 300 , are this same?
    Appriciate help.
    Tom

    Thanks for marking thread useful.
    Class 300 and 200 are both defined for the materials.class 300 is mainly used for a variant material used for variant configurartion.We can also classify materials under class 200 which do not have to be configurable materials.But allows to use the defined characteristics and restrict the usage for a specific purpose..
    Please check below threads
    http://scn.sap.com/thread/631073
    https://scn.sap.com/thread/576848
    Yes you can copy class and create your new class .
    can you please share your business requirement, what kind of solution your are budiling with this?
    Thanks
    Ritesh

  • Assertion failed: poll() is a blocking call and cannot be called on the Service thread

    Hi
    We are getting a strange issue, the application successfully joins the cluster but after start failing with following exception.
    The cluster have three nodes storage disabled web-logic and two standalone coherence JVM's, we are using distributed cache with Local scheme
    <Error> (thread=DistributedCache, member=4): Assertion failed: poll() is a blocking call and cannot be called on the Service thread
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:5)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:11)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$BinaryMap.get(PartitionedCache.CDB:26)
    at com.tangosol.util.ConverterCollections$ConverterMap.get(ConverterCollections.java:1655)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.get(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1)
    at com.thehartford.pi.core.referencedata.dao.cachedaoimpl.ReferenceCacheDAOImpl.getReferenceData(Unknown Source)
    at com.thehartford.pi.core.caching.cachestore.ReferenceCacheStore.load(Unknown Source)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheLoaderCacheStore.load(ReadWriteBackingMap.java:6132)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheStoreWrapper.loadInternal(ReadWriteBackingMap.java:5616)
    at com.tangosol.net.cache.ReadWriteBackingMap$StoreWrapper.load(ReadWriteBackingMap.java:4698)
    at com.tangosol.net.cache.ReadWriteBackingMap.get(ReadWriteBackingMap.java:717)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.get(PartitionedCache.CDB:10)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onGetRequest(PartitionedCache.CDB:23)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$GetRequest.run(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.net.message.requestMessage.DistributedCacheKeyRequest.onReceived(DistributedCacheKeyRequest.CDB:12)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:34)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:33)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onNotify(PartitionedService.CDB:3)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
    at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)
    at java.lang.Thread.run(Thread.java:722)
    ERROR 2013-09-20 09:06:42,515    :  [2013-09-20 09:06:42.515/8740.228 Oracle Coherence GE 3.7.1.0 <Error> (thread=DistributedCache, member=4): Assertion failed: poll() is a blocking call and cannot be called on the Service thread
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:5)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.poll(Grid.CDB:11)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$BinaryMap.get(PartitionedCache.CDB:26)
    at com.tangosol.util.ConverterCollections$ConverterMap.get(ConverterCollections.java:1655)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$ViewMap.get(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.util.SafeNamedCache.get(SafeNamedCache.CDB:1)
    at com.thehartford.pi.core.referencedata.dao.cachedaoimpl.ReferenceCacheDAOImpl.getReferenceData(Unknown Source)
    at com.thehartford.pi.core.caching.cachestore.ReferenceCacheStore.load(Unknown Source)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheLoaderCacheStore.load(ReadWriteBackingMap.java:6132)
    at com.tangosol.net.cache.ReadWriteBackingMap$CacheStoreWrapper.loadInternal(ReadWriteBackingMap.java:5616)
    at com.tangosol.net.cache.ReadWriteBackingMap$StoreWrapper.load(ReadWriteBackingMap.java:4698)
    at com.tangosol.net.cache.ReadWriteBackingMap.get(ReadWriteBackingMap.java:717)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$Storage.get(PartitionedCache.CDB:10)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onGetRequest(PartitionedCache.CDB:23)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache$GetRequest.run(PartitionedCache.CDB:1)
    at com.tangosol.coherence.component.net.message.requestMessage.DistributedCacheKeyRequest.onReceived(DistributedCacheKeyRequest.CDB:12)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onMessage(Grid.CDB:34)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.Grid.onNotify(Grid.CDB:33)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.PartitionedService.onNotify(PartitionedService.CDB:3)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.partitionedService.PartitionedCache.onNotify(PartitionedCache.CDB:3)
              at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:42)

    Hi
    The problem is that you are making a re-entrant call back into a cache service from the service thread or worker thread of a cache service. This is a bad thing to do as you risk deadlocking your cluster by consuming all of the threads in the service. From the stack trace it looks like you are doing a get on a cache which is calling through to a cache store which is then doing a get on another cache.
    For example, you have done a "get" on a cache, that has now consumed a worker thread (call it Thread-1), that thread is calling the cache store which is doing a get on another cache in the same cache service so will now consume another thread (call it Thread-2) so you now have two threads in use, Thread-1 will not return until Thread-2 completes. Now say you had 2 worker threads on your cache service and two "get" calls came in at the same time, Get-1 and Get-2. Both worker threads are now in use so when Get-1 calls the cache store to do a get on the other cache then it has to wait for a worker thread to become free to process the get. The same applies to Get-2, it is calling the cache store and waiting for a thread to become free. The problem is no threads will become free as they are all waiting. Hopefully that is a clear enough explanation of why you get the warning.
    Read this Constraints on Re-entrant Calls - 12c (12.1.2) This is for 12.1.2 but the same applies for any Coherence version.
    JK

  • What's the difference between defining a Thread within a class and....

    Guys,
    I am really confused when it comes to thread.
    What's the difference between defining a Thread within a class and implementing a Thread in a class?
    I just want to know about this. What is the difference between the two code classes?
    public class A
    public A()
    public Start()
    Thread th = new Thread():
    th.start(this);
    public class A extends Thread
    public A()
    *{*{code}*}*  
    *public Start()*
    *run();*

    My Googling show that the E/A may be a little newer but it appears that the E/A was not originally sold in the USA. The E/A appears to be sold in a Spanish speaking country.

  • Event Dispatch Thread Hangs, what is wrong?

    The Event Dispatch Thread Hangs when showing a modal dialog while running a
    SwingWorker Thread.
    I have included my code at the bottom of the page. There are three classes. I have posted a bug report to red hat. But I want to make sure my code is correct.
    My test case just puts the SwingWorker to sleep
    but the problem occurs if I do something real, like connect to a database, etc.
    Also I have tried little different variations of the logic calling
    setVisible(true)/(false) in different places and the same problem occurs.
    It seems to work with Sun JDK, note I am using IcedTea with Fedora Core 8.
    Version-Release number of selected component (if applicable):
    [szakrews@tuxtel ~]$ java -version
    java version "1.7.0"
    IcedTea Runtime Environment (build 1.7.0-b21)
    IcedTea Client VM (build 1.7.0-b21, mixed mode)How reproducible:
    Every couple times.
    javac TestClass2
    java TestClass2eventually it will hang. If it doesn't try again.
    You don't have to wait for the program to finish either.
    The program runs the Dialog 10 times but it never works or fails in the middle, it will either work or fail from the first dialog displayed.
    I have included a thread dump. That is about the most informative information I can get. Neither tracing nor writing a custom ThreadQueue or Drawing Manager to trace events produces any helpful information.
    Actual results:
    The JProccessBar won't move, and the SwingWorker finishes but the done() method is never run. The PROGRAM is not hung however because if I close the dialog then it will continue.
    Expected results:
    The JProccessBar should always move and the SwingWorker should always run the done() method.
    Additional info:
    java thread dump after freeze, taken with kill -s SIGQUIT <pid>
    2008-06-25 12:25:50
    Full thread dump IcedTea Client VM (1.7.0-b21 mixed mode):
    "DestroyJavaVM" prio=10 tid=0x938afc00 nid=0x1419 waiting on condition
    [0x00000000..0x0018a074]
       java.lang.Thread.State: RUNNABLE
    "AWT-EventQueue-0" prio=10 tid=0x938ae400 nid=0x1429 in Object.wait()
    [0x07f96000..0x07f96f04]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x96748f80> (a java.awt.EventQueue)
            at java.lang.Object.wait(Object.java:503)
            at java.awt.EventQueue.getNextEvent(EventQueue.java:485)
            - locked <0x96748f80> (a java.awt.EventQueue)
            at
    java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:248)
            at
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201)
            at
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:195)
            at java.awt.Dialog$1.run(Dialog.java:1073)
            at java.awt.Dialog$3.run(Dialog.java:1127)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.awt.Dialog.show(Dialog.java:1125)
            at java.awt.Component.show(Component.java:1456)
            at java.awt.Component.setVisible(Component.java:1408)
            at java.awt.Window.setVisible(Window.java:871)
            at java.awt.Dialog.setVisible(Dialog.java:1012)
            at net.xtel.production.WaitDialog.showWaitDialog(WaitDialog.java:72)
            at net.xtel.production.WaitDialog.showWaitDialog(WaitDialog.java:102)
            at TestClass2.showWait(TestClass2.java:79)
            at TestClass2.createAndShowGUI(TestClass2.java:126)
            at TestClass2.access$0(TestClass2.java:114)
            at TestClass2$3.run(TestClass2.java:138)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:227)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:603)
            at
    java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:276)
            at
    java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:201)
            at
    java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:191)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:186)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:139)
    "AWT-Shutdown" prio=10 tid=0x938ad000 nid=0x1428 in Object.wait()
    [0x03ea7000..0x03ea7f84]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x96749268> (a java.lang.Object)
            at java.lang.Object.wait(Object.java:503)
            at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:281)
            - locked <0x96749268> (a java.lang.Object)
            at java.lang.Thread.run(Thread.java:675)
    "AWT-XAWT" daemon prio=10 tid=0x938a8400 nid=0x1423 runnable
    [0x02ccc000..0x02ccd104]
       java.lang.Thread.State: RUNNABLE
            at sun.awt.X11.XToolkit.waitForEvents(Native Method)
            at sun.awt.X11.XToolkit.run(XToolkit.java:550)
            at sun.awt.X11.XToolkit.run(XToolkit.java:525)
            at java.lang.Thread.run(Thread.java:675)
    "Java2D Disposer" daemon prio=10 tid=0x93854000 nid=0x1421 in Object.wait()
    [0x07aea000..0x07aead84]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x966e7010> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
            - locked <0x966e7010> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:150)
            at sun.java2d.Disposer.run(Disposer.java:143)
            at java.lang.Thread.run(Thread.java:675)
    "Low Memory Detector" daemon prio=10 tid=0x93c15000 nid=0x141f runnable
    [0x00000000..0x00000000]
       java.lang.Thread.State: RUNNABLE
    "CompilerThread0" daemon prio=10 tid=0x93c13400 nid=0x141e waiting on condition
    [0x00000000..0x03a8a954]
       java.lang.Thread.State: RUNNABLE
    "Signal Dispatcher" daemon prio=10 tid=0x93c11c00 nid=0x141d waiting on
    condition [0x00000000..0x00000000]
       java.lang.Thread.State: RUNNABLE
    "Finalizer" daemon prio=10 tid=0x095e7000 nid=0x141c in Object.wait()
    [0x005d2000..0x005d3004]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x966e71d8> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:134)
            - locked <0x966e71d8> (a java.lang.ref.ReferenceQueue$Lock)
            at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:150)
            at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)
    "Reference Handler" daemon prio=10 tid=0x095e2400 nid=0x141b in Object.wait()
    [0x00581000..0x00582084]
       java.lang.Thread.State: WAITING (on object monitor)
            at java.lang.Object.wait(Native Method)
            - waiting on <0x966e7260> (a java.lang.ref.Reference$Lock)
            at java.lang.Object.wait(Object.java:503)
            at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:134)
            - locked <0x966e7260> (a java.lang.ref.Reference$Lock)
    "VM Thread" prio=10 tid=0x095dec00 nid=0x141a runnable
    "VM Periodic Task Thread" prio=10 tid=0x93c17400 nid=0x1420 waiting on condition
    JNI global references: 836
    Heap
    def new generation   total 960K, used 152K [0x93f40000, 0x94040000, 0x966a0000)
      eden space 896K,   9% used [0x93f40000, 0x93f56148, 0x94020000)
      from space 64K, 100% used [0x94020000, 0x94030000, 0x94030000)
      to   space 64K,   0% used [0x94030000, 0x94030000, 0x94040000)
    tenured generation   total 4096K, used 1088K [0x966a0000, 0x96aa0000, 0xb3f40000)
       the space 4096K,  26% used [0x966a0000, 0x967b01b0, 0x967b0200, 0x96aa0000)
    compacting perm gen  total 12288K, used 9169K [0xb3f40000, 0xb4b40000, 0xb7f40000)
       the space 12288K,  74% used [0xb3f40000, 0xb4834740, 0xb4834800, 0xb4b40000)
    No shared spaces configured.CLASS1:
    import java.awt.Dimension;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.sql.SQLException;
    import java.util.concurrent.ExecutionException;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.RepaintManager;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.UnsupportedLookAndFeelException;
    public class TestClass2 extends JFrame implements ActionListener {
            /** Action Command for <code>searchbtn</code> */
            public static final String SEARCH_BTN_ACTION = "search_btn_action";
             * Constructor.
            public TestClass2() {
                    setSize(650, 350);
                    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
                    setLocation(screenSize.width / 2 - getSize().width / 2,
                                    screenSize.height / 2 - getSize().height / 2);
                    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                    addWindowListener(new WindowAdapter() {
                            @Override
                            public void windowClosing(WindowEvent e) {
                                    exit();
                    JPanel panel = new JPanel();
                    add(panel);
                    setVisible(true);
            @Override
            public void actionPerformed(ActionEvent e) {
                    if (e.getActionCommand().equals(SEARCH_BTN_ACTION)) {
                            JOptionPane.showMessageDialog(this, "Button Pressed");
            public void showWait() {
                    try {
                            WaitDialog.showWaitDialog(this, "Testing...", new SwingWorkerInterface(){
                                    @Override
                                    public Object workToDo() throws Throwable {
                                            Thread.currentThread().sleep(3000);
                                            return null;
                    } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                    } catch (ExecutionException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
             * Exits the program.
            public void exit(){
                    System.exit(0);
             * Create the GUI and show it. For thread safety, this method should be
             * invoked from the event-dispatching thread.
             * @throws UnsupportedLookAndFeelException
             * @throws IllegalAccessException
             * @throws InstantiationException
             * @throws ClassNotFoundException
             * @throws NullInstanceVariableException
             * @throws SQLException
            private static void createAndShowGUI() {
                    // set look and feel
                    try{
                            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                            // Create instance of the ProductCatalog
                            TestClass2 root = new TestClass2();
                            for(int i = 0; i < 10; i++){
                                    root.showWait();
                    }catch(Exception e){
                            e.printStackTrace();
             * @param args
             *            this program does not use arguments
            public static void main(String[] args) {
                    SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                    createAndShowGUI();
    }CLASS 2:
    import java.awt.Component;
    import java.awt.Frame;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.util.concurrent.ExecutionException;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JProgressBar;
    import javax.swing.SwingWorker;
    public class WaitDialog extends JDialog {
            private boolean disposed = false;
            private boolean displayed = false;
            private WorkerThread worker = null;
            WaitDialog(Frame parent, String text, SwingWorkerInterface in){
                    super(parent, true);
                    worker = new WorkerThread(in);
                    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
                    addWindowListener(new WindowAdapter() {
                            @Override
                            public void windowOpened(WindowEvent e) {
                                    worker.execute();
                            @Override
                            public void windowClosing(WindowEvent e) {
                                    disposeWaitDialog();
                    this.setResizable(false);
                    JLabel message = new JLabel();
                    message.setText(text);
                    JProgressBar pb = new JProgressBar();
                    pb.setIndeterminate(true);
                    // set size and location
                    setSize(200, 100);
                    setLocationRelativeTo(parent);
                    JPanel panel = new JPanel();
                    panel.add(message);
                    panel.add(pb);
                    add(panel);
            public void showWaitDialog(){
                    if(displayed == true){
                            return;
                    if(disposed == true){
                            disposed = false;
                            return;
                    disposed = false;
                    displayed = true;
                    setVisible(true);
            public void disposeWaitDialog(){
                    if(disposed == true){
                            return;
                    if(displayed == true){
                            displayed = false;
                            setVisible(false);
                            return;
                    disposed = true;
                    displayed = false;
            public static Object showWaitDialog(Component parent, String text, SwingWorkerInterface in) throws InterruptedException, ExecutionException {
                    WaitDialog waitDialog = null;
                    if (parent == null) {
                            waitDialog = new WaitDialog(JOptionPane.getRootFrame(), text, in);
                    } else {
                            waitDialog = new WaitDialog(JOptionPane.getFrameForComponent(parent), text, in);
                    while(!waitDialog.worker.isDone()){
                            System.out.println("about to show");
                            waitDialog.showWaitDialog();
                            System.out.println("done showing");
                    waitDialog.dispose();
                    return waitDialog.worker.get();
            class WorkerThread extends SwingWorker<Throwable, Void> {
                    private SwingWorkerInterface in = null;
                    WorkerThread(SwingWorkerInterface in){
                            this.in = in;
                    public Throwable doInBackground(){
                                    try {
                                            System.out.println("about to do work");
                                            in.workToDo();
                                            System.out.println("done work no exception");
                                    } catch (Throwable e) {
                                            System.out.println("done work with exception");
                                            return e;
                                    return null;
                    public void done(){
                                    System.out.println("about to dispose");
                                    disposeWaitDialog();
                                    System.out.println("disposed");
    }CLASS 3:
    public interface SwingWorkerInterface {
            public Object workToDo() throws Throwable;
    }

    There's nothing directly wrong with it, but it will
    prevent other threads acquiring the class lock - but
    that may be what you want.True. Although the typical case for code that looks like this would be to use wait--usually the various threads in question require the same lock, so you have to use wait in order for the waiting thread to give it up and allow the other thread to do its work. Hard to say for sure though what he's doing.
    Also, if loading is all that the other thread does, and you're waiting for that thread to die, use join. But then, if that's the case, and you're only waiting for a single other thread, then you might as well just put it all in one thread, as already indicated.

  • Dinamyc class loading and jar files

    I'm new to java. I would like to load some plugins in my application (it's going to be packaged as a jar at the end). I managed to find some dinamyc class loading examples but they search for the classes to load in a directory.
    This is the code:
        public static void main(String[] args) {
            File pluginDirectory = new File("src/pluginsreloaded/plugins");
            if (!pluginDirectory.exists()) {            // the plugin directory does not exist
                System.out.println("The plugins directory does not exist!");           
                return;
            FilenameFilter filter = new FilenameFilter() {
                public boolean accept(File dir, String name) {
                    return name.endsWith(".class");
            String[] pluginFiles = pluginDirectory.list(filter);
            for (int i = 0; i < pluginFiles.length; i++) {
                if (pluginFiles.indexOf("$") == -1) {
    System.out.println("Loading: " + pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    IPlugin plugin = pm.loadPlugin(pluginFiles[i].substring(0, pluginFiles[i].length() - 6));
    System.out.println(plugin.description());
    protected static IPlugin loadPlugin(String name) {
            // Query the plugin list for the plugin
            PluginFactory _plugin = (PluginFactory) pluginList.get(name);
            if (_plugin == null) {          // the plugin is not loaded
                try {
                    Class.forName("pluginsReloaded.plugins." + name);
                    // The plugin makes an entry in the plugin list
                    // when loaded
                    _plugin = (PluginFactory) pluginList.get(name);
                    if (_plugin == null) {
                        return null;
                } catch (ClassNotFoundException e) {
                    System.out.println("Plugin " + name + " not found!");
            return _plugin.create();
        }IPlugin is an interface. I am using netbeans 5.0. The error I get is this:
    Exception in thread "main" java.lang.NoClassDefFoundError: pluginsReloaded/plugins/plugin1 (wrong name: pluginsreloaded/plugins/plugin1)
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Class.java:164)
            at pluginsreloaded.PluginManager.loadPlugin(PluginManager.java:30)
            at pluginsreloaded.Main.main(Main.java:44)
    Java Result: 1As far as I can see it can't find the class. My question is how can I load the class/where can I find it?
    Thanks.

    You can use the java.util.jar.JarFile class to enumerate the contents of a jar. It's not good practice to search for plugins in this way though. A plugin may well involve serveral classes, which don't all have to be internal. Furthermore its wise to avoid any comitment about the mechaism by which class files are to be fetched. You might want to do it remotely, some time, or load them from a database.
    What seesms to be the standard approach is to put a list of plugin classes into the jar as a text file.
    Plugins for a given purpose usually implement some specified interface, or extend some abstract class to which their objects can be cast once loaded (without this they aren't really much use).
    Say your plugins implment org.myorg.WidgetFactory then you put a list of them, one fully qualified name to a line, in a file or jar entry called META-INF/services/org.myorg.WidgetFactory. You framework picks up all such files from the classpath using ClassLoader.getResources() and loads all the classes whose names if finds, hence you can add new sets of plugins just by adding a new jar or class directory to the class path.

  • Oracle 8.1.7 OCI question: Some threads hang in OCIServerAttach indefinetly after rem

    Configuration: MS Win2k SP2, MS Visual C++ 6.0 SP6, Oracle 8.1.7 via OCI
    I have 128 threads doing the following:
    1) Create environment (OCI_THREADED, OCI_ENV_NO_MUTEX), setup handles, try to connect to remote database 2) If connect fails, log the error message and try again after 2 seconds 3) Execute simple stored procedure 4) Disconnect from remote database ( + cleanup of all handles including environment ) 5) ... repeat from 1)
    When I go to the remote database and perform shutdown of the whole operating system (by choosing shutdown in Windows), something peculiar happens. First I get: ORA-12500 and ORA-12541 error messages. Then most of the channels go to ORA-12535 error message and they loop in that message until I exit the application. However, some of the threads remain hanging in OCIServerAttach function and do not allow my application to exit.
    Needless to say, OCIBreak function doesn't help here (I've tried).
    When I attach the debugger to the hanging process, I get the attached stack trace. It looks like some sockets remain hanging - a terrible thing to happen.
    In the attachment are also Oracle error descriptions that I mentioned.
    I would be thankful for any suggestions here...
    -- Tomislav.
    "Real sharpness comes without effort,
    No growth without assistance,
    No action without reaction,
    Now give yourself up and find yourself again."
    "Crouching tiger, hidden dragon"
    NTDLL! 77f827e8()
    MSAFD! 74fd8e33()
    WS2_32! 75031275()
    ORANTCP8! 6470565f()
    ORANTCP8! 64703536()
    ORAN8! 60b78f5a()
    ORAN8! 60b7c8a8()
    ORAN8! 60b44d24()
    ORAN8! 60b3fd0a()
    ORAN8! 60b3f474()
    ORAN8! 60b157a0()
    ORAN8! 60b61c7c()
    ORACLIENT8! 60429b1e()
    ORACLIENT8! 604b4695()
    ORACLIENT8! 604b9ece()
    ORACLIENT8! 604823a3()
    ORACLIENT8! 60429f64()
    ORACLIENT8! 60401340()
    OCI! 015059ab()
    CLibOCI::OCIServerAttach(OCIServer * 0x0dff13e0, OCIError * 0x0dff15d4,
    unsigned char * 0x0de9b810, int 21, unsigned int 0) line 282 + 28 bytes
    FCALLDLL! 014d2c03()
    MSVCRT! 7800a3c0()
    KERNEL32! 77e8758a()
    "TNS-12500 TNS:listener failed to start a dedicated server process
    Cause: The process of starting up a dedicated server process failed. The executable could not be found or the environment may be set up incorrectly.
    Action: Turn on tracing at the ADMIN level and re-execute the operation. Verify that the Oracle Server executable is present and has execute permissions enabled. Ensure that the Oracle environment is specified correctly in LISTENER.ORA. The Oracle Protocol Adapter that is being called may not be installed on the local hard drive. Check that the correct Protocol Adapter are successfully linked. If the error persists, contact Oracle Customer Support.
    TNS-12541 TNS:no listener
    Cause: The connection request could not be completed because the listener is not running.
    Action: Ensure that the supplied destination address matches one of the addresses used by the listener. Compare the TNSNAMES.ORA entry with the appropriate LISTENER.ORA file (or TNSNAV.ORA if the connection is to go by way of an Interchange). Start the listener on the remote machine.
    TNS-12535 TNS:operation timed out
    Cause: The requested connection could not be completed within the timeout period specified by the CONNECT_TIMEOUT parameter in LISTENER.ORA. This error arises from the TNSLSNR.
    Action: Either reconfigure CONNECT_TIMEOUT to be 0, which means wait indefinitely, or reconfigure CONNECT_TIMEOUT to be some higher value. Or, if the timeout is unacceptably long, turn on tracing for further information."

    Hi,
    What is going on in your case is :
    1. Oracle library (OCI) is failing to identify a Dead Connection properly all the time.
    2. According to the errors you have received, all of them seems to be appropriate to what you have described in your message.
    a. TNS failed to start a dedicated server process. This error is returned when the number of server processes are excessive or memory is low etc - I am not sure why this is returned to you
    b. TNS listener is not available - May be the listener has already shutdown, since the system is being shutdown.
    c. TNS operation timed out. This will be returned by your local TNS client library, which says CONNECT(socket operation) failed, since the other end has already SHUTDOWN.
    Getting an error is good for you, since you can always sleep 2 seconds and reconnect.
    The hanging thread is due to a problem that Oracle folks call as DCD(Dead COnnection Detection) logic. The DCD can be turned on by setting sqlnet.expire timeout to be some number of minutes in the sqlnet.ora file. Please check on the Metalink on the DCD issue.
    What I have personally seen is that DCD does not always work, even if turned ON.

  • Thread pool with AT MOST one thread at a time

    Hi,
    I want to create a pool that creates at most one thread when it is needed. I want the pool to terminate the thread when it is idle for some time. Executors.newSingleThreadExecutor() creates a thread pool with one thread, but this thread doesn't die if idle...
    The code below also doesn't work - no thread is ever created:
    new ThreadPoolExecutor(0, 1, 30, TimeUnit.SECONDS,
                              new LinkedBlockingQueue<Runnable>());Thanks in advance

    Use Future.get().
    package net.jcip.examples;
    import java.util.concurrent.*;
    import static java.util.concurrent.TimeUnit.NANOSECONDS;
    * RenderWithTimeBudget
    * Fetching an advertisement with a time budget
    * @author Brian Goetz and Tim Peierls
    public class RenderWithTimeBudget {
        private static final Ad DEFAULT_AD = new Ad();
        private static final long TIME_BUDGET = 1000;
        private static final ExecutorService exec = Executors.newCachedThreadPool();
        Page renderPageWithAd() throws InterruptedException {
            long endNanos = System.nanoTime() + TIME_BUDGET;
            Future<Ad> f = exec.submit(new FetchAdTask());
            // Render the page while waiting for the ad
            Page page = renderPageBody();
            Ad ad;
            try {
                // Only wait for the remaining time budget
                long timeLeft = endNanos - System.nanoTime();
                ad = f.get(timeLeft, NANOSECONDS);
            } catch (ExecutionException e) {
                ad = DEFAULT_AD;
            } catch (TimeoutException e) {
                ad = DEFAULT_AD;
                f.cancel(true);
            page.setAd(ad);
            return page;
        Page renderPageBody() { return new Page(); }
        static class Ad {
        static class Page {
            public void setAd(Ad ad) { }
        static class FetchAdTask implements Callable<Ad> {
            public Ad call() {
                return new Ad();
    }

  • Thread hangs trying to use MoveChildComponentChange to implement drag-n-dro

    System: JDeveloper 11.1.1.3 Browser: FF 3.6.6
    So I'm trying to implement a drop-n-drop between two components, allowing the user to drag elements between on parent component and another parent component:
    I never make it past the commonComponentParent = moveChildComponentChange.add(..) line as the thread hangs (during debugging i dont get an exception it just hangs!!), but the reason that I'm getting this, i think, is because the system is giving a null ChangeManager (cm). Why is the RequestContext giving me a null cm when I so nicely asked it for a valid one?
    <af:panelGroupLayout id="pgl1" styleClass="appdock appMenu" layout="horizontal" inlineStyle="margin-left: 0px;">
    <af:dropTarget dropListener="#{menuComponent.handleExternalContainerDrag}" actions="MOVE">
    <af:dataFlavor flavorClass="javax.faces.component.UIComponent" />
    </af:dropTarget>
    <tr:outputText value="drop here" />
    </af:panelGroupLayout>
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import oracle.adf.view.rich.context.AdfFacesContext;
    import oracle.adf.view.rich.datatransfer.DataFlavor;
    import oracle.adf.view.rich.datatransfer.Transferable;
    import oracle.adf.view.rich.dnd.DnDAction;
    import oracle.adf.view.rich.event.DropEvent;
    import org.apache.myfaces.trinidad.change.ChangeManager;
    import org.apache.myfaces.trinidad.change.MoveChildComponentChange;
    import org.apache.myfaces.trinidad.context.RequestContext;
    public class MenuComponent {
    public DnDAction handleExternalContainerDrag(DropEvent dropEvent){
    ChangeManager cm = null;
    cm = RequestContext.getCurrentInstance().getChangeManager();
    UIComponent commonComponentParent = null;
    try {
    commonComponentParent = moveChildComponentChange.add(fctx, cm);
    moveChildComponentChange.changeComponent(commonComponentParent);
    AdfFacesContext adfFacesCtx = AdfFacesContext.getCurrentInstance();
    adfFacesCtx.addPartialTarget(commonComponentParent);
    } catch (Exception e){
    e.printStackTrace();
    -Rob

    Hi,
    did you enable change persistence in the ViewLayer project ? The book you have the sample code from mentions this on page 447 "Enabling Change Persistence in ADF Faces RC Projects". To enable this, just double click the view layer project and then select "ADF View". The check the checkbox to "Enable User Customization"
    Frank

  • Exception in thread "main" related to CLASSPATH and unable to load driver??

    Hi,
    I am a JAVA beginner, I have met some problems cannot solve, can somebody help?
    My OS is Windows2000
    Java SDK in C:\j2sdk-1_4_2_04 and Java JRE in C:\Program Files\Java\j2re1.4.2_04 [Installation: j2sdk-1_4_2_04-windows-i586-p.exe]
    MySQL in C:\mysql [Installation: mysql-4.0.18-win.zip]
    MyODBC in C:\Download\MYODBC [Installation: MyODBC-3.51.06.exe]
    MyJDBC in C:\mysql-connector-java-3.0.11-stable [Installation: mysql-connector-java-3.0.11-stable.zip]
    Enviornment Variables Settings
    PATH = C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem;C:\j2sdk1.4.2_04\bin;C:\mysql\bin
    JAVA_HOME = C:\j2sdk1.4.2_04
    (CASE ONE) - While I didn't set a new Enviornment Variable for CLASSPATH
    HelloWorld.class can work properly and LoadDriver.class cannot work due to Unable to load Driver (As below)
    C:\JavaTry>javac HelloWorld.java
    C:\JavaTry>java HelloWorld
    Hello World!
    C:\JavaTry>javac LoadDriver.java
    C:\JavaTry>java LoadDriver
    Unable to load driver.
    java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at LoadDriver.main(LoadDriver.java:7)
    (CASE TWO) - While I set a new Enviornment Variable for CLASSPATH (No matter which settings as below)
    CLASSPATH = C:\mysql-connector-java-3.0.11-stable\mysql-connector-java-3.0.11-stable-bin.jar
    CLASSPATH = C:\mysql-connector-java-3.0.11-stable
    CLASSPATH = C:\mysql-connector-java-3.0.11-stable\com;C:\mysql-connector-java-3.0.11-stable\org
    Both the HelloWorld.class and LoadDriver cannot work properly due to Exception in thread "main" java.lang.NoClassDefFoundError (As below)
    C:\JavaTry>javac HelloWorld.java
    C:\JavaTry>java HelloWorld
    Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorld
    C:\JavaTry>javac LoadDriver.java
    C:\JavaTry>java LoadDriver
    Exception in thread "main" java.lang.NoClassDefFoundError: LoadDriver
    Below are the JAVA scripts which I used
    -> HelloWorld.java
    public class HelloWorld {
    public static void main(String[] args) {
    System.out.println("Hello World!");
    -> LoadDriver.java
    import java.sql.*;
    public class LoadDriver {
    public static void main(String[] Args) {
    try {
    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
    /* Class.forName("com.mysql.jdbc.Driver").newInstance(); <- either one try the same */
    } catch (Exception E) {
    System.err.println("Unable to load driver.");
    E.printStackTrace();
    Moreover, I saw some information only standalone application need to set CLASSPATH, right??

    My problem "unable to load driver" have solved.
    I set the CLASSPATH = C:\mysql-connector-java-3.0.11-stable\mysql-connector-java-3.0.11-stable-bin.jar
    and try
    java -cp ".";%CLASSPATH% LoadDriver
    Thanks masnare again :> and who provided the link http://www.kevinboone.com/classpath.html in the forums others similar topics, actually I forgot which topic and who, so... :P no matter whom thanks very much :)

  • How to convert a String variable as class name and method name?

    i have two classes
    class Student
    public String insertStudent(String sname)
    { return("Student has been inserted ");     }
    class Teacher
    public String execute(String methodName, String className)
    {  //return statement of the method 'insertStudent' in the class 'Student'; }
    }Now, i have a class with the main method. Here, i would like to call the method *'insertStudent'* of class *'Student'*
    using the method *'execute'* of class *'Teacher',* passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Can anyone please help me out. Thanks
    regards,
    chinglai

    You should have just added that as a comment on your [initial posting|http://forums.sun.com/thread.jspa?threadID=5334953] instead of starting a new thread.
    Now, i have a class with the main method. Here, i would like to call the method 'insertStudent' of class 'Student'using the method 'execute' of class 'Teacher', passing the method-name and the class-name (viz. insertStudent, Student) as the
    String parameter.
    Why oh why? What do you want to achieve?
    Let me tell you: there is a way to do what you try to do, but it's not recommended and should be used only very sparingly. Especially not in anything like your code, that resembles normal business logic (as opposed to an application framework such as Spring, for example).
    Can you explain what exactly you want to do with that? Why should a Teacher be able to call any random method ony any other class. And what good would that do?

  • Whats the difference between a class method and a instance method.

    I have a quiz pretty soon and one of the questions will be: "How does an instance method differ from a class method." I've tried looking this up but they gave me really complicated explanations. I know what a instance method is but not really sure what a class one is. Can someone post an example of a class method and try to explain what makes it so special?
    Edited by: tetris on Jan 30, 2008 10:45 PM

    Just have a look:
    http://forum.java.sun.com/thread.jspa?threadID=603042&messageID=3246191

  • Creation of developement class,package and access key

    COULD ANYBODY EXPLAIN about
    creation of developement class,package and access key
    and who will create them?

    Working With Development Objects
    Any component of an application program that is stored as a separate unit in the R/3 Repository is called a development object or a Repository Object. In the SAP System, all development objects that logically belong together are assigned to the same development class.
    Object Lists
    In the Object Navigator, development objects are displayed in object lists, which contain all of the elements in a development class, a program, global class, or function group.
    Object lists show not only a hierarchical overview of the development objects in a category, but also tell you how the objects are related to each other. The Object Navigator displays object lists as a tree.
    The topmost node of an object list is the development class. From here, you can navigate right down to the lowest hierarchical level of objects. If you select an object from the tree structure that itself describes an object list, the system displays just the new object list.
    For example:
    Selecting an Object List in the Object Navigator
    To select development objects, you use a selection list in the Object Navigator. This contains the following categories:
    Category
    Meaning
    Application hierarchy
    A list of all of the development classes in the SAP System. This list is arranged hierarchically by application components, component codes, and the development classes belonging to them
    Development class
    A list of all of the objects in the development class
    Program
    A list of all of the components in an ABAP program
    Function group
    A list of all of the function modules and their components that are defined within a function group
    Class
    A list of all of the components of a global class. It also lists the superclasses of the class, and all of the inherited and redefined methods of the current class.
    Internet service
    A list of all of the componentse of an Internet service:
    Service description, themes, language resources, HTML templates and MIME objects.
    When you choose an Internet service from the tree display, the Web Application Builder is started.
    See also Integrating Internet Services.
    Local objects
    A list of all of the local private objects of a user.
    Objects in this list belong to development class $TMP and are not transported. You can display both your own local private objects and those of other users. Local objects are used mostly for testing. If you want to transport a local object, you must assign it to another development class. For further information, refer to Changing Development Classes
    http://help.sap.com/saphelp_46c/helpdata/en/d1/80194b454211d189710000e8322d00/content.htm
    Creating the Main Package
    Use
    The main package is primarily a container for development objects that belong together, in that they share the same system, transport layer, and customer delivery status. However, you must store development objects in sub-packages, not in the main package itself.
    Several main packages can be grouped together to form a structure package.
    Prerequisites
    You have the authorization for the activity L0 (All Functions) using the S_DEVELOP authorization object.
    Procedure
    You create each normal package in a similar procedure to the one described below. It can then be included as a sub-package in a main package.
    To create a main package:
    1.       Open the Package Builder initial screen (SE21 or SPACKAGE).
    2.       In the Package field, enter a name for the package that complies with the tool’s Naming Conventions
    Within SAP itself, the name must begin with a letter from A to S, or from U to X.
    3.       Choose Create.
    The system displays the Create Package dialog box.
    4.       Enter the following package attributes:
    Short Text
    Application Component
    From the component hierarchy of the SAP system, choose the abbreviation for the application component to which you want to assign the new package.
    Software component
    Select an entry. The software component describes a set of development objects that can only be delivered in a single unit. You should assign all the sub-packages of the main package to this software component.
    Exception: Sub-packages that will not be delivered to customers must be assigned to the HOMEsoftware component.
    Main Package
    This checkbox appears only if you have the appropriate authorization (see Prerequisites).
    To indicate that the package is a main package, check this box.
    5.       Choose  Save.
    6.       In the dialog box that appears, assign a transport request.
    Result
    The Change package screen displays the attributes of the new package. To display the object list for the package in the Object Navigator as well, choose  from the button bar.
    You have created your main package and can now define a structure within it. Generally, you will continue by adding sub-packages to the main package. They themselves will contain the package elements you have assigned.
    See also
    Adding Sub-Packages to the Main Package
    http://help.sap.com/saphelp_nw04/helpdata/en/ea/c05d8cf01011d3964000a0c94260a5/content.htm
    access key used for change standard program.
    www.sap.service.com

Maybe you are looking for