Java Bean Thread Safety

I've been using JavaBeans for years now, and have read at least 30 different texts and online resources about using Java beans in JSPs. But in every single one of them, they are ambiguous and non-committal about how to properly use them to avoid Thread-Safety problems in a multithreaded (web server) environment. Are there any true Java gurus out there who know how to do so in JSPs?
Specifically, when you use the <jsp:useBean> tag, that tag automatically binds an instance of your bean to the PageContext object. Since the PageContext object is shared by many threads, wouldn't this automatically make all of the Java Bean's properties vulnerable for thread problems? Since the pageContext is shared between threads, wouldnt one have to declare every one of the bean's setters and getters as "synchronized", to prevent one thread overwriting another's values?
I ask because in many texts, they make a vague suggestion "be sure to write your beans thread-safe"--but provide no concrete answer as to how (the level at which to declare 'synchronized'). But in all their code examples, I have never once, in all these years, seen the word "synchronized".
How is this possible? Wouldn't the bean, as bound to the thread-shared pageContext object, be completely exposed to thread corruption, with multiple threads simultaneously calling its methods?
Can someone supply some code snippets showing the thread-safe way to use JavaBeans (i.e., where to synchronize)

PageContext is shared by many threads?
Not at one time, I'm pretty certain of that.
From the API: A PageContext instance is obtained by a JSP implementation class by calling the JspFactory.getPageContext() method, and is released by calling JspFactory.releasePageContext().
The to me suggests the contract that a PageContext can only be in use by on one JSP page at a time. As far as I am concerned, pageContext can be treated like a "local variable" to a jsp page.
The contents of the pageContext object are maybe a different story, but we'll get to that.
The things to worry about with thread safety are the same as they are for servlets.
1 - Class attributes are not threadsafe. ie variables declared within <%! %> signs
2 - Session attributes are potentially not threadsafe if the user makes two quick requests in a row (handling two requests for the same session)
3 - Application attributes are never threadsafe as any currently running request can access them. Most Application level attributes I treat as read only (kinda like Singleton access)
I don't see the need to go overboard declaring everything "synchronized". In fact I think it would be hugely detrimental.

Similar Messages

  • Vector Replacement in Java 1.4 - Is Thread Safety Needed In This Scenario?

    I have a Java 1.4 application that queries Database # 1, and builds custom strings used to create records that are inserted into Database # 2.
    Right now Vectors are used as a container to temporarily hold query output from Database # 1 while building records going into Database # 2, but I want to convert away from this legacy collection type.
    This application does this with a single "worker" thread that is started and monitored by the application main thread. If the main thread detects any exceptions, i.e. a network or any database problem, the application main thread will stop the single worker thread and restart a new single worker thread.
    There are several instances of this application running simultaneously on the same server but accessing different test databases. When put into the production environment this application will run on a separate server and there will be only 1 instance of the application running.
    I have reviewed numerous forums here and Google results and have not found much specific info that would closely apply to my exact design situation. I did not post any code since this is more of a design question than issue with a specific code snippet.
    My question is: In the scenario I described, does thread safety need to be a factor in choosing a new collection type (to replace Vectors) and in building code that accesses this new collection type?

    The several instances of the application are all independent JVMs and can't interact with each other directly at all. So there's no thread safety issue there and there never was. So what does that leave you? You've got a single worker thread using the Vector? There's no thread safety issue there either. The only time you have to think about thread safety is when two threads are trying to use the same object.

  • How to call a .jar file from a java bean?

    any body knows how to call a .jar file from a java bean?

    Crosspost!
    http://forum.java.sun.com/thread.jspa?messageID=4349619

  • What are the thread safety requirements for container implementation?

    I rarely see in the TopLink documentation reference to thread safety requirements and it’s not different for container implementation.
    The default TopLink implementation for:
    - List is Vector
    - Set is HashSet
    - Collection is Vector
    - Map is HashMap
    Half of them are thread safe implementations List/Collection and the other half is not thread safe Set/Map.
    So if I choose my own implementation do I need a thread safe implementation for?
    - List ?
    - Set ?
    - Collection ?
    - Map ?
    Our application is always reading and writing via UOW. So if TopLink synchronize update on client session objects we should be safe with not thread safe implementation for any type; does TopLink synchronize update on client session objects?
    The only thing we are certain is that it is not thread safe to read client session object or read read-only UOW object if they are ever expired or ever refreshed.
    We got stack dump below in an application always reading and writing objects from UOW, so we believe that TopLink doesn’t synchronize correctly when it’s updating the client session objects.
    java.util.ConcurrentModificationException
    at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:449)
    at java.util.AbstractList$Itr.next(AbstractList.java:420)
    at oracle.toplink.internal.queryframework.InterfaceContainerPolicy.next(InterfaceContainerPolicy.java:149)
    at oracle.toplink.internal.queryframework.ContainerPolicy.next(ContainerPolicy.java:460)
    at oracle.toplink.internal.helper.WriteLockManager.traverseRelatedLocks(WriteLockManager.java:140)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLockAndRelatedLocks(WriteLockManager.java:116)
    at oracle.toplink.internal.helper.WriteLockManager.checkAndLockObject(WriteLockManager.java:349)
    at oracle.toplink.internal.helper.WriteLockManager.traverseRelatedLocks(WriteLockManager.java:144)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLockAndRelatedLocks(WriteLockManager.java:116)
    at oracle.toplink.internal.helper.WriteLockManager.checkAndLockObject(WriteLockManager.java:349)
    at oracle.toplink.internal.helper.WriteLockManager.traverseRelatedLocks(WriteLockManager.java:144)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLockAndRelatedLocks(WriteLockManager.java:116)
    at oracle.toplink.internal.helper.WriteLockManager.acquireLocksForClone(WriteLockManager.java:56)
    at oracle.toplink.publicinterface.UnitOfWork.cloneAndRegisterObject(UnitOfWork.java:756)
    at oracle.toplink.publicinterface.UnitOfWork.cloneAndRegisterObject(UnitOfWork.java:714)
    at oracle.toplink.internal.sessions.UnitOfWorkIdentityMapAccessor.getAndCloneCacheKeyFromParent(UnitOfWorkIdentityMapAccessor.java:153)
    at oracle.toplink.internal.sessions.UnitOfWorkIdentityMapAccessor.getFromIdentityMap(UnitOfWorkIdentityMapAccessor.java:99)
    at oracle.toplink.internal.sessions.IdentityMapAccessor.getFromIdentityMap(IdentityMapAccessor.java:265)
    at oracle.toplink.publicinterface.UnitOfWork.registerExistingObject(UnitOfWork.java:3543)
    at oracle.toplink.publicinterface.UnitOfWork.registerExistingObject(UnitOfWork.java:3503)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.registerIndividualResult(ObjectLevelReadQuery.java:1812)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally(ObjectBuilder.java:455)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork(ObjectBuilder.java:419)
    at oracle.toplink.internal.descriptors.ObjectBuilder.buildObject(ObjectBuilder.java:379)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.buildObject(ObjectLevelReadQuery.java:455)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.conformIndividualResult(ObjectLevelReadQuery.java:622)
    at oracle.toplink.queryframework.ReadObjectQuery.conformResult(ReadObjectQuery.java:339)
    at oracle.toplink.queryframework.ReadObjectQuery.registerResultInUnitOfWork(ReadObjectQuery.java:604)
    at oracle.toplink.queryframework.ReadObjectQuery.executeObjectLevelReadQuery(ReadObjectQuery.java:421)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:811)
    at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:620)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:779)
    at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:388)
    at oracle.toplink.queryframework.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:836)
    at oracle.toplink.publicinterface.UnitOfWork.internalExecuteQuery(UnitOfWork.java:2604)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
    at oracle.toplink.publicinterface.Session.executeQuery(Session.java:950)

    Hi Lionel,
    As a general rule of thumb, the ATI Rage 128 Pro will not support a 20" LCD. That being said, there are reports of it doing just that (possibly the edition that went into the cube).
    I'm not that familiar with the ins and outs of the Cube, so I can't give you authoritative information on it.
    A good place to start looking for answers is:
    http://cubeowner.com/kbase_2/
    Cheers!
    Karl

  • Java Bean Not Working

    i am installing 10.1.2 on redhat3 update 7
    When i run my OCIConnectionPool bean or any bean following error occurs
    [oracle@appserver beansource]$ java OCIConnectionPool
    libgcj-java-placeholder.sh
    This script is a placeholder for the /usr/bin/java
    master link required by jpackage.org conventions. libgcj's
    rmiregistry, rmic and jar tools are now slave symlinks to these
    masters, and are managed by the alternatives(8) system.
    This change was necessary because the rmiregistry, rmic and jar tools
    installed by previous versions of libgcj conflicted with symlinks
    installed by jpackage.org JVM packages.
    This script was designed to be overridden by the supported RHEL3 JRE
    packages, java-1.4.2-bea and java-1.4.2-ibm. It is installed as an
    alternative symlink as /usr/bin/java. It will override a third-party
    (non-RHEL3) JRE's java command if the JRE's bin directory is listed
    after /usr/bin in PATH. In that case, it is recommended that the
    third-party JRE's bin directory be listed first in PATH instead.
    Exception in thread "main" java.lang.UnsatisfiedLinkError: ocijdbc9: file not found
    at 0x00bb6ca3: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x00ba9b1e: java.lang.Error.Error(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x00bab546: java.lang.LinkageError.LinkageError(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x00bb6f76: java.lang.UnsatisfiedLinkError.UnsatisfiedLinkError(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x00b99b97: java.lang.Runtime._load(java.lang.String, boolean) (/usr/lib/./libgcj.so.3)
    at 0x00bad329: java.lang.Runtime.loadLibrary(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x00bb46f6: java.lang.System.loadLibrary(java.lang.String) (/usr/lib/./libgcj.so.3)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c4fa: JvInterpMethod.run_synch_object(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c474: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c474: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c474: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c474: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00c4aad8: java.sql.DriverManager.getConnection(java.lang.String, java.util.Properties) (/usr/lib/./libgcj.so.3)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c474: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c474: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00cd1007: ffi_call_SYSV (/usr/lib/./libgcj.so.3)
    at 0x00cd0fc7: ffi_raw_call (/usr/lib/./libgcj.so.3)
    at 0x00b7e658: JvInterpMethod.continue1(_Jv_InterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7ef64: JvInterpMethod.run(ffi_cif, void, ffi_raw, JvInterpMethodInvocation) (/usr/lib/./libgcj.so.3)
    at 0x00b7c474: JvInterpMethod.run_normal(ffi_cif, void, ffi_raw, void) (/usr/lib/./libgcj.so.3)
    at 0x00cd0e7c: ?? (??:0)
    at 0x00b90d68: gnu.gcj.runtime.FirstThread.call_main() (/usr/lib/./libgcj.so.3)
    at 0x00bfae99: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
    at 0x00b9daec: JvThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
    at 0x00b6a82c: JvRunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/./libgcj.so.3)
    at 0x08048930: ?? (??:0)
    at 0x006a979a: __libc_start_main (/lib/tls/libc.so.6)
    at 0x080486e1: ?? (??:0)
    Chetan

    One way is to change the "break;" line to "return true;" and remove the current "return true;" line. Then move the "return false;" line outside the catch section. It seems whatever you are doing is not throwing an exception, so whatever else it does, it always falls thru to the return true line.

  • Search in form by using java bean or PJC.

    hi all
    i am confused because i do not know java bean to much,is it possible to create a search button with one text item in java bean to display all records
    example:
    if i enter dept 10 then it display all records related to dept 10?
    is it possible?
    if yes please cany anyone send me a demo?
    here is my email add.
    [email protected]
    sarah

    hi
    Francois thanks for the link and its very useful and i am studying the codes and also i downloaded demos and run them its working fine and its very very nice.
    i like java and trying to learn and its very useful.
    why i want to use java bean because one of my friend her name is sheela she wants me to do it but i am failed i did not do it in java bean
    so i thought lets try on the forum may be someone help u.
    so i posted a thread over here.
    thanks Francois.
    u r appreciated.once again thanks.
    sarah

  • Need ideas for new PJC/Java Beans

    Hello everybody,
    I am always looking for new ideas about the Java Bean and PJC stuff. Sometimes I have good ideas about this, but sometimes it is quite a pain to find something new and innovative.
    If you have ideas or needs about this, let me know in this thread.
    (Sorry Oracle staff if I am going beyond my rights by using the Forum for that purpose)
    Francois

    Francois ,
    I think that we all need to thank you for all your hard work promoting Oracle Forms.
    Your input and constant support on this forum is greatly appreciated.
    But I personally think that all this needs to be addressed by Oracle.
    Your wrote
    Sometimes I have good ideas about this, but sometimes it is quite a pain to find something new and innovative.
    And I agree with you.
    You can go as far as the Forms let you go...
    Thanks,
    Michael

  • Urgent question about Thread-safety

    Hi all,
    the new tiger release provides an "isReachable()" method for the "InetAddress" object.
    I've found, this method is not thread-safe (see the source and output below).
    It returns true for all threads, when multiple threads using this method with different adresses are running at a time and one of the addresses is reachable. This happens only on WinXp. Running on Linux, the output is like expected.
    I've tried to report this as a bug. But the gurus answered, taking care of thread safety would be a "programmers task".
    My question is, what can I do, to be thread-safe in my case?
    W.U.
    import java.util.*;
    import java.net.*;
    public class IsReachableTest_1 extends Thread{
        static volatile int inst=1;
        static final String NET_ADDR="192.168.111.";
        int instance=inst++;
        public void run(){
            for(int i=19;i<23;i++){
                try{
                    long start=System.nanoTime();
                    if(InetAddress.getByName(NET_ADDR+i).isReachable(1000))
                        System.out.println(""+instance+"--host found at:"+NET_ADDR+i+"--time:"+(System.nanoTime()-start)/1000000);
                    else
                        System.out.println(""+instance+"--no host at:"+NET_ADDR+i);
                }catch(Exception e){System.out.println(""+instance+"--ERROR "+e.toString());}
            System.out.println(""+instance+"--done.");
        public static void main(String[] args) {
            System.out.println(
                System.getProperty("java.vendor")+" "+
                System.getProperty("java.version")+" running on "+
                System.getProperty("os.name")+" "+
                System.getProperty("os.version"));
            Vector v=new Vector();
            System.out.println("\nTest 1: One after another:");
            for(int i=0;i<10;i++){
                IsReachableTest_1 t;
                t=new IsReachableTest_1();
                t.start();
                try{
                    t.join();
                }catch(Exception e){System.out.println("MAIN1: "+e.toString());}
            System.out.println("\nTest 2: All together:");
            inst=1;
            for(int i=0;i<10;i++){
                IsReachableTest_1 t;
                t=new IsReachableTest_1();
                t.start();
                v.addElement(t);
            for(Iterator i=v.iterator();i.hasNext();)
                try{
                    ((IsReachableTest_1)i.next()).join();
                }catch(Exception e){System.out.println("MAIN2: "+e.toString());}
                System.out.println("\nALL DONE");
    And here is the output, when running on WinXp:
    Sun Microsystems Inc. 1.5.0-beta running on Windows XP 5.1
    Test 1: One after another:
    1--no host at:192.168.111.19
    1--no host at:192.168.111.20
    1--host found at:192.168.111.21--time:2
    1--no host at:192.168.111.22
    1--done.
    2--no host at:192.168.111.19
    2--no host at:192.168.111.20
    2--host found at:192.168.111.21--time:4
    2--no host at:192.168.111.22
    2--done.
    3--no host at:192.168.111.19
    3--no host at:192.168.111.20
    3--host found at:192.168.111.21--time:1
    3--no host at:192.168.111.22
    3--done.
    4--no host at:192.168.111.19
    4--no host at:192.168.111.20
    4--host found at:192.168.111.21--time:1
    4--no host at:192.168.111.22
    4--done.
    5--no host at:192.168.111.19
    5--no host at:192.168.111.20
    5--host found at:192.168.111.21--time:3
    5--no host at:192.168.111.22
    5--done.
    6--no host at:192.168.111.19
    6--no host at:192.168.111.20
    6--host found at:192.168.111.21--time:1
    6--no host at:192.168.111.22
    6--done.
    7--no host at:192.168.111.19
    7--no host at:192.168.111.20
    7--host found at:192.168.111.21--time:1
    7--no host at:192.168.111.22
    7--done.
    8--no host at:192.168.111.19
    8--no host at:192.168.111.20
    8--host found at:192.168.111.21--time:1
    8--no host at:192.168.111.22
    8--done.
    9--no host at:192.168.111.19
    9--no host at:192.168.111.20
    9--host found at:192.168.111.21--time:1
    9--no host at:192.168.111.22
    9--done.
    10--no host at:192.168.111.19
    10--no host at:192.168.111.20
    10--host found at:192.168.111.21--time:1
    10--no host at:192.168.111.22
    10--done.
    Test 2: All together:
    1--no host at:192.168.111.19
    2--no host at:192.168.111.19
    3--no host at:192.168.111.19
    4--no host at:192.168.111.19
    5--no host at:192.168.111.19
    6--no host at:192.168.111.19
    7--no host at:192.168.111.19
    8--no host at:192.168.111.19
    9--no host at:192.168.111.19
    10--no host at:192.168.111.19
    2--no host at:192.168.111.20
    3--no host at:192.168.111.20
    6--host found at:192.168.111.20--time:924 <----- this host does not exist!!
    5--host found at:192.168.111.20--time:961 <----- this host does not exist!!
    10--host found at:192.168.111.20--time:778 <----- this host does not exist!!
    9--host found at:192.168.111.20--time:815 <----- this host does not exist!!
    2--host found at:192.168.111.21--time:37
    7--host found at:192.168.111.20--time:888 <----- this host does not exist!!
    8--host found at:192.168.111.20--time:852 <----- this host does not exist!!
    4--host found at:192.168.111.20--time:997 <----- this host does not exist!!
    1--host found at:192.168.111.20--time:1107 <----- this host does not exist!!
    3--host found at:192.168.111.21--time:38
    6--host found at:192.168.111.21--time:1
    5--host found at:192.168.111.21--time:1
    10--host found at:192.168.111.21--time:2
    2--host found at:192.168.111.22--time:3 <----- this host does not exist!!
    9--host found at:192.168.111.21--time:2
    7--host found at:192.168.111.21--time:1
    4--host found at:192.168.111.21--time:3
    1--host found at:192.168.111.21--time:39
    2--done.
    1--host found at:192.168.111.22--time:5 <----- this host does not exist!!
    1--done.
    10--host found at:192.168.111.22--time:40 <----- this host does not exist!!
    3--host found at:192.168.111.22--time:192 <----- this host does not exist!!
    6--host found at:192.168.111.22--time:75 <----- this host does not exist!!
    8--host found at:192.168.111.21--time:230
    5--host found at:192.168.111.22--time:155 <----- this host does not exist!!
    4--host found at:192.168.111.22--time:78 <----- this host does not exist!!
    9--host found at:192.168.111.22--time:77 <----- this host does not exist!!
    7--host found at:192.168.111.22--time:76 <----- this host does not exist!!
    10--done.
    6--done.
    4--done.
    5--done.
    3--done.
    7--done.
    9--done.
    8--no host at:192.168.111.22
    8--done.
    ALL DONE

    I created this test (it's basically the same as your class):
    import java.util.*;
    import java.net.*;
    public class IsReachableTest_2 implements Runnable {
        private final String[] addresses = new String[] {
             "www.sun.com",
             "129.42.16.99" // www.ibm.com which is not reachable
        public void run(){
            try {
                for (int i = 0; i < addresses.length; i++) {
                    final long start = System.nanoTime();
                    final String address = addresses;
         if (InetAddress.getByName(address).isReachable(5000)) {
         System.out.println(Thread.currentThread().getName() + ": Host found at: " + address +
              " --time: " + (System.nanoTime() - start) / 1000);
         } else System.out.println("no host at: " + address);
    } catch(Exception e){
    e.printStackTrace();
    System.out.println("Thread " + Thread.currentThread().getName() + " DONE");
    public static void main(String[] args) {
    System.out.println(
         System.getProperty("java.vendor") +
         " " +
         System.getProperty("java.version") +
         " running on " +
         System.getProperty("os.name") +
         " " +
         System.getProperty("os.version")
    for (int i = 0; i < 10; i++) {
         final Thread t = new Thread(new IsReachableTest_2(), "THREAD " + (i+1));
         t.start();
    And I get:
    Sun Microsystems Inc. 1.5.0-beta running on Windows 2000 5.0
    THREAD 1: Host found at: www.sun.com --time: 217653
    THREAD 3: Host found at: www.sun.com --time: 214404
    THREAD 6: Host found at: www.sun.com --time: 214900
    THREAD 4: Host found at: www.sun.com --time: 215901
    THREAD 5: Host found at: www.sun.com --time: 216666
    THREAD 10: Host found at: www.sun.com --time: 216620
    THREAD 9: Host found at: www.sun.com --time: 217405
    THREAD 2: Host found at: www.sun.com --time: 220705
    THREAD 7: Host found at: www.sun.com --time: 220845
    THREAD 8: Host found at: www.sun.com --time: 221384
    no host at: 129.42.16.99
    Thread THREAD 4 DONE
    no host at: 129.42.16.99
    Thread THREAD 6 DONE
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    Thread THREAD 5 DONE
    Thread THREAD 10 DONE
    Thread THREAD 9 DONE
    Thread THREAD 7 DONE
    Thread THREAD 3 DONE
    Thread THREAD 1 DONE
    Thread THREAD 2 DONE
    Thread THREAD 8 DONE
    HOWEVER: I was getting some strange results every so often. Results like:
    Sun Microsystems Inc. 1.5.0-beta running on Windows 2000 5.0
    THREAD 3: Host found at: www.sun.com --time: 261132
    THREAD 9: Host found at: www.sun.com --time: 264183
    THREAD 2: Host found at: www.sun.com --time: 266447
    THREAD 6: Host found at: www.sun.com --time: 266596
    THREAD 8: Host found at: www.sun.com --time: 267192
    THREAD 5: Host found at: www.sun.com --time: 268610
    THREAD 4: Host found at: www.sun.com --time: 269849
    THREAD 1: Host found at: www.sun.com --time: 280978
    THREAD 7: Host found at: www.sun.com --time: 272589
    THREAD 10: Host found at: www.sun.com --time: 273162
    THREAD 3: Host found at: 129.42.16.99 --time: 13657
    Thread THREAD 3 DONE
    THREAD 4: Host found at: 129.42.16.99 --time: 4123
    THREAD 2: Host found at: 129.42.16.99 --time: 9439
    THREAD 5: Host found at: 129.42.16.99 --time: 6681
    THREAD 8: Host found at: 129.42.16.99 --time: 7655
    THREAD 6: Host found at: 129.42.16.99 --time: 8627
    THREAD 9: Host found at: 129.42.16.99 --time: 10586
    Thread THREAD 4 DONE
    Thread THREAD 2 DONE
    Thread THREAD 5 DONE
    Thread THREAD 8 DONE
    Thread THREAD 6 DONE
    Thread THREAD 9 DONE
    no host at: 129.42.16.99
    Thread THREAD 7 DONE
    no host at: 129.42.16.99
    no host at: 129.42.16.99
    Thread THREAD 10 DONE
    Thread THREAD 1 DONE
    Usually the first run after I had compiled the class (!?) This isn't a thread safety problem.

  • Cannot compile java beans in my jsp page

    Hi all
    I have created jsp pages which contains java beans. Now its working fine on my machine(XP OS) but when i put it on windows 2000 server it gives the following error:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: -1 in the jsp file: null
    Generated servlet error:
    [javac] Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
         at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
         at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
         at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:473)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:190)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Unknown Source)
    please help

    Ok, jsp pages to not contain java beans, java beans are separate classes which you access from a jsp.
    Is this what you have done, i.e. created classes under classes/yourPackage ?
    If so, you do not need to recompile the class when you move it, you can move the pre-compiled class file.
    In terms of your error, I have no idea, but it looks interesting!!
    The most likely cause is a difference in the JDK versions you are running on the different machines. If the JDK on windows 2000 is older, you may need to upgrade it.

  • Reflection objects and thread safety

    Hi,
    I believe that I saw that Field and Method objects are thread-safe (i.e., can safely have methods called against a single object instance concurrently from multiple threads), but am having trouble finding such a description in the JDK javadocs static that fact.
    I'm assuming that all thread-specific 'state' would be managed by the Object target passed to methods like invoke()/get()/set() and not on the actual Field and Method objects themselves. Ideally, i'd like to only have to look up fields and methods only once reflectively, and thereafter just use the same reflection object instances to access their target objects at runtime as a performance optimizations - possibly in different threads and at the same time - without having to pay the cost of looking it up again. I should be able to do that providing Method.invoke() is thread safe. Otherwise, i'd probably be forced to call Class.getMethod() to get a new Method object to use against each object instance, which would be more costly both from a memory standpoint (more Method objects) and a lookup-cost perspective.
    Given that lots of existing performance-critical enterprise infrastructure code, such as OR database APIs, IoC frameworks and J2EE containers use reflection to decouple the generic code from any app specific code (from a compile time perspective) as an alternative to code generation, it's surprising that there's no obvious statement about thread safety in these classes. If I look at the source code for Method, it appears to be thread safe, but I can only get so far with this analysis, as the critical code in Method appears to be implemented using a class named 'sun.reflect.MethodAccessor', whose source I don't have access to.
    I know it's possible to invoke a method against multiple objects by calling Method.invoke() against each of the target objects in question. However, there's no mention as to whether it's safe to use a single Method object instance to invoke a method against multiple target object instances at the same time (i.e., from different threads running in parallel). This would fail, for instance, if the Method object had data members that were used to communicate information between internal calls without any synchronization, as the values might be used by one thread while another was changing them.
    Just to clarify (as i've seen some confusion in other forum discussions on this topic):
    I completely understand that the thread safety of a target object's method (read, small 'm') is entirely dependent upon it's implementation and not the mechanism by which it's invoked - i.e., whether a method is invoked by an explicit compiled-in call against an instance of the target object in some Java source file, or indirectly via Method object-based reflection, is immaterial the the method's thread safety.
    What i'm asking about is the thread safety of the Method.invoke() call itself (read, big 'M'). Same question wrt Field.get()/.set() as well. These calls should be thread-safe if they're stateless wrt the Method and Field object instances that they are invoked against.

    In general, if a Java API is silent about multi-threading, it is intended to be thread-safe. See the javadoc for HashMap for an example of an explicit warning.
    It is true that Java code can have bugs that show up only on unusual implementations of the Java memory model, such as relaxed memory model machines. Most (if not all) implementations of the JDK have been deployed principally on platforms with strong memory models. (Perhaps not coincidentally, those are also the machines that have market share.) There are even bugs found occasionally in the JDK core, so draw your own conclusions about the bug-tail of our software stack on systems with relaxed memory models!
    One of the more likely bugs to run into on highly optimized systems is failure of timely initialization of non-final fields in objects which are shared in an unsynchronized manner. See http://www.cs.umd.edu/~pugh/java/memoryModel/jsr-133-faq.html#finalRight and related pages. JDK core programmers (at Sun, to my personal knowledge) take care not to write code with such bugs, but application programmers might.
    And, yes, caching your own Method objects is a good idea, if only because their lookup is generally cumbersome and slow. If you are very performance sensitive, you'll end up generating bytecode "shim" between your callers and the desired target methods. I expect that the http://openjdk.java.net/projects/mlvm/ (an openjdk project we are just starting) will provide some relief for this; stay tuned.
    Finally, since Method objects have no state to speak of (except their "accessible" bit, which is an ahead-of-time configuration), it would be really, really surprising if they could create a race condition of some sort. If you expect race conditions in formally stateless data structures, you are certifiably paranoid. (A normal state on some platforms, hopefully not on Java.)
    For more information about method calls, including reflective methods, see my blog post: http://blogs.sun.com/jrose/entry/anatomy_of_a_call_site
    Best wishes...

  • Creating java bean

    Hi all,
    I am stuck with my first java bean, can anyone please help!? I've serahed the net and this forum, but the closest one to my problem that I can find is this one, http://forum.java.sun.com/thread.jspa?threadID=571292&messageID=2850205. However, it does not help me much. The following are the steps that I took.
    Thanks,
    Welles
    1. Create a class
    package testBeans;
    public class TestClass
         public static void main(String[] args)
              System.out.println("Hello World!");
         public void runTest(){
    2. Complie the java file to the testBeans folder under the current folder
    c:\work>javac -d . TestClass.java
    3. Create the jar file
    c:\work>jar cvf testBeans.jar testBeans/*.*
    added manifest
    adding: testBeans/TestClass.class(in = 483) (out= 315)(deflated 34%)
    4. Put the testBeans.jar in C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext
    5. Create a driver class
    import testBeans.*;
    public class BeanDriver
         public static void main(String[] args)
              TestClass.runTest();
    6. Complie the BeanDriver.java file, but I get the following error message :(
    ---------- javac ----------
    C:\test\BeanDriver.java:7: cannot access TestClass
    bad class file: .\TestClass.java
    file does not contain class TestClass
    Please remove or make sure it appears in the correct subdirectory of the classpath.
              TestClass.runTest();
    ^
    1 error
    Output completed (0 sec consumed) - Normal Termination

    Crossposted, so don't anyone waste their time answering it here. Answer over here instead:
    http://forum.java.sun.com/thread.jspa?threadID=624016
    @OP: Crossposting is rude.

  • Java.lang.StackOverflowError due to java.beans.XMLEncoder class

    Hello,
    I am using the XMLEncoder class as follows :
    private byte[] serialize(Map decodedBlob) {
    ByteArrayOutputStream bObjOut = new ByteArrayOutputStream();
    if (decodedBlob == null) {
    return null;
    } else {
    try {
    XMLEncoder encode = new XMLEncoder(new GZIPOutputStream(bObjOut));
    encode.writeObject(decodedBlob);
    encode.flush();
    encode.close();
    } catch (Exception e) {
    e.printStackTrace();
    return bObjOut.toByteArray();
    } The object decodedBlob is of type HashMap and further contains other HashMaps and ArrayLists as its values. Including values in all the childs there are more than a 200 variables conatined in this HashMap. I need to call the above serialize method for some 2000 such decodedBlob objects .However when i do run my program it gives me the following error after processing some 168 objects only:
    Exception in thread "main" java.lang.StackOverflowError
    at java.util.Collections$SynchronizedMap.containsKey(Collections.java:1988)
    at java.lang.reflect.Proxy.isProxyClass(Proxy.java:630)
    at java.beans.MetaData.getPersistenceDelegate(MetaData.java:890)
    at java.beans.Encoder.getPersistenceDelegate(Encoder.java:144)
    at java.beans.Encoder.writeObject(Encoder.java:68)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
    at java.beans.Encoder.writeObject(Encoder.java:69)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
    at java.beans.Encoder.writeObject(Encoder.java:69)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)
    at java.beans.Encoder.writeObject(Encoder.java:69)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)As can be seen the following lines keep repeating in the error:
    at java.beans.Encoder.writeObject(Encoder.java:68)
    at java.beans.XMLEncoder.writeObject(XMLEncoder.java:269)
    at java.beans.Encoder.writeObject1(Encoder.java:201)
    at java.beans.Encoder.cloneStatement(Encoder.java:209)
    at java.beans.Encoder.writeExpression(Encoder.java:273)
    at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:384)
    at java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:112)I have seen the other posts regarding the same on the forum but even overriding the mutatesTo as described there doesnt help.
    I have also tried increasing the heap size but that also doesnt seem to solve the problem.
    Please please help me sort this problem out. Thanks in advance

    hey ... i just found a way out .... when i upgraded to version 6 the error simply vanished ... seems there was a bug in d previous version for the XMLEncoder class. Thanks anyway.
    So for all the others who are facing similar problem try running the code with jre 1.6 too and see if it solves your problem

  • Java bean on html

    I am trying to load a bean on an html and it is throwing the given below exception[I am using java plugiin]
    load: class TestBean.jar not found.
    java.lang.ClassNotFoundException: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.beans.Beans.instantiate(Unknown Source)
         at java.beans.Beans.instantiate(Unknown Source)
         at sun.plugin.BeansViewer.createJavaBeanComponent(Unknown Source)
         at sun.plugin.navig.win32.BeansPluginPanel.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    java.lang.ClassNotFoundException: java.io.IOException: open HTTP connection failed.
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at sun.plugin.security.PluginClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.beans.Beans.instantiate(Unknown Source)
         at java.beans.Beans.instantiate(Unknown Source)
         at sun.plugin.BeansViewer.createJavaBeanComponent(Unknown Source)
         at sun.plugin.navig.win32.BeansPluginPanel.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Any idea on this.
    Or Can any one give a sample code for loading a bean on an html using java plugins

    I'm seeing a very similar problem when someone outside of our network try's to load one of our applets. The error message we are getting is exactly the same except substitute "TestBean.jar" with our class name "com.byers.app.starter.AppletStarter".
    For people on our local network it works fine... and for most people outside our network it works fine. We are suspecting it has something to do with proxy configuration. Have you figured out what your problem was? Thanks.

  • How to call precedure in impl into java bean

    Dear all,
    i'm tried to call procedure at impl.java into java bean.
    but, there is error which is it cannot find the root of this.getDBTranstation
    any idea.
    TQ

    Hi
    Please tell me
    How to call ethod in AppModuleImpl from other bean?
    I have created method in AppModuleImpl
    public String callFuncWithArgs(String p_company, String p_division, String p_user, String p_wrkord_type,
    String p_service_type, String p_HOLD_CODE_TYPE) {
    return (String)callStoredFunction(VARCHAR2, "WS_tran.Margin_TO_USER(?,?,?,?,?,?)",
    new Object[] { p_company, p_division, p_user, p_wrkord_type, p_service_type,
    p_HOLD_CODE_TYPE });
    This method is working after run APPModule. But I want to call this method from SparesTEOImpl class and
    public boolean validateUnitPrice(int unitprice) {
    //want to call here AppModuleImpl
    callFuncWithArgs(String p_company, String p_division, String p_user, String p_wrkord_type,
                                       String p_service_type, String p_HOLD_CODE_TYPE) here
    Please tell me how to call , I wrote in following ways but I got error...
    public boolean validateUnitPrice(int unitprice) {
    String margin=appImpl.callFuncWithArgs("00004","SDWSG", "S1","CSH", "SP","M");
    System.out.println("Output"+margin);
    return margin;
    After that I got the following error.
    Exception in thread "main" oracle.jbo.InvalidOwnerException: JBO-25301: Application module AppModuleImpl_0 is not a root app module but has no parent
        at oracle.jbo.server.ComponentObjectImpl.getRootApplicationModule(ComponentObjectImpl.java:177)
        at oracle.jbo.server.ApplicationModuleImpl.getDBTransaction(ApplicationModuleImpl.java:3656)
        at model.AppModuleImpl.callStoredFunction(AppModuleImpl.java:128)
        at model.AppModuleImpl.callFuncWithArgs(AppModuleImpl.java:160)
        at model.SparesTEOImpl.validateUnitPrice(SparesTEOImpl.java:55)
        at model.SparesTEOImpl.main(SparesTEOImpl.java:67)
    Process exited with exit code 1.
    Please tell me how to solve this problem...

  • URGENT- PLEASE HELP: java.lang.threads and BC4J

    Hi,
    according to my issue "no def found for view" in the same titled thread I'm wondering how you would implement asynchronous calls of methods that use BC4J to update a couple of data.
    To be more precise:
    A requirement of our software is to start an update database job, which can take a couple of minutes/hours, from the web browser. Before it will be executed the logged-in user receives a notification that this batch job has been started.
    I dont't want to use JMS overhead and MD Beans for this simple requirement, therefore I implemented a class that extends java.lang.Thread and put all the update codings within the run method. After having called the start-method of the thread I get a JBO-25022(No XML file found) error when I try to set a new value for an attribute of the row. The row consists of attributes which belong to four entity objects that mus be updated.
    When calling the run method directly, everything works fine.
    My questions:
    * do you know any workaround how to make the xml files
    reachable?
    * how would you implement anschronous calls of long time-
    consuming jobs?
    * is this a bug of BC4J?
    Any help, tip, hint is really appreciated.
    Stefan

    Arno,
    many thanks for your reply:
    Here is an excerpt of the source code of my thread "Aenderungsdienst":
    public class Aenderungsdienst extends java.lang.Thread
    private SviAdministrationModuleImpl mSviModul;
    // Application module that contains view object
    // IKViewImpl
    public Aenderungsdienst(SviAdministrationModuleImpl aSviModul)
    mSviModul = aSviModul;
    public void run()
    ausfuehrenAenderungsdienst(mAenderungsdienstNr); <--error within this methode
    private int ausfuehrenAenderungsdienst(String aAenderungsdienstNr)
    int rAnzahlSaetze = 0;
    try
    IkViewImpl aenderungen = mSviModul.getIkView();
    aenderungen.suchenAenderungssaetze(aAenderungsdienstNr); <-- method within View Object Impl that executes a query with customized where-clauses
    if ((rAnzahlSaetze = aenderungen.getRowCount()) > 0)
    IkViewRowImpl ik = null;
    while (aenderungen.hasNext())
    ik = (IkViewRowImpl) aenderungen.next();
    ik.setBestandsstatus("B"); <-- error occurs here when setting the status of a current row in my rowset to "B"
    mSviModul.getTransaction().postChanges();
    mSviModul.getTransaction().commit();
    catch (Exception e)
    e.printStackTrace();
    mSviModul.getTransaction().rollback();
    //todo: Verarbeitungsprotokoll erstellen
    return rAnzahlSaetze;
    This thread will be called by the application module "sviAdministrationModuleImpl":
    public void ausfuehrenAenderungsdienst(String
    aAenderungsdienstNr)
    Aenderungsdienst aenderungsdienst = new
    Aenderungsdienst(this);
    aenderungsdienst.setAenderungsdienstNr
    (aAenderungsdienstNr);
    aenderungsdienst.start();
    Using the start() method of the thread causes this exception:
    [653] No xml file: /hvbg/svi/model/businessobjects/businessobjects.xml, metaobj = hvbg.svi.model.businessobjects.businessobjects
    [654] Cannot Load parent Package : hvbg.svi.model.businessobjects.businessobjects
    [655] Business Object Browsing may be unavailable
    [656] No xml file: /hvbg/svi/model/businessobjects/IK_Inlandsbankverb.xml, metaobj = hvbg.svi.model.businessobjects.IK_Inlandsbankverb
    09.03.2004 10:27:41 hvbg.common.businessobjects.HvbgEntityImpl setAttributeInternal
    SCHWERWIEGEND: Fehler beim Setzen des Attributs 1 im Entity Objekt: JBO-25002: Definition hvbg.svi.model.businessobjects.IK_Inlandsbankverb vom Typ Entitätszuordnung nicht gefunden.
    09.03.2004 10:27:42 hvbg.svi.model.dienste.Aenderungsdienst ausfuehrenAenderungsdienst
    SCHWERWIEGEND: Beim Ausführen des Aenderungsdienstes 618 trat während der DB-Aktualisierung ein schwerer Fehler auf:
    JBO-25002: Definition hvbg.svi.model.businessobjects.IK_Inlandsbankverb vom Typ Entitätszuordnung nicht gefunden.
    oracle.jbo.NoDefException: JBO-25002: Definition hvbg.svi.model.businessobjects.IK_Inlandsbankverb vom Typ Entitätszuordnung nicht gefunden.
         at oracle.jbo.mom.DefinitionManager.findDefinitionObject(DefinitionManager.java:328)
         at oracle.jbo.mom.DefinitionManager.findDefinitionObject(DefinitionManager.java:268)
         at oracle.jbo.server.MetaObjectManager.findMetaObject(MetaObjectManager.java:649)
         at oracle.jbo.server.EntityAssociation.findEntityAssociation(EntityAssociation.java:98)
         at oracle.jbo.server.AssociationDefImpl.resolveEntityAssociation(AssociationDefImpl.java:725)
         at oracle.jbo.server.AssociationDefImpl.getEntityAssociation(AssociationDefImpl.java:135)
         at oracle.jbo.server.AssociationDefImpl.hasContainer(AssociationDefImpl.java:546)
         at oracle.jbo.server.AssociationDefImpl.getContainer(AssociationDefImpl.java:468)
         at oracle.jbo.server.EntityImpl.getContainer(EntityImpl.java:1573)
         at oracle.jbo.server.EntityImpl.setValidated(EntityImpl.java:1649)
         at oracle.jbo.server.EntityImpl.setAttributeValueInternal(EntityImpl.java:2081)
         at oracle.jbo.server.EntityImpl.setAttributeValue(EntityImpl.java:1985)
         at oracle.jbo.server.AttributeDefImpl.set(AttributeDefImpl.java:1700)
         at oracle.jbo.server.EntityImpl.setAttributeInternal(EntityImpl.java:946)
         at hvbg.common.businessobjects.HvbgEntityImpl.setAttributeInternal(HvbgEntityImpl.java:56)
         at hvbg.svi.model.businessobjects.IKImpl.setBestandsstatus(IKImpl.java:174)
         at hvbg.svi.model.businessobjects.IKImpl.setAttrInvokeAccessor(IKImpl.java:770)
         at oracle.jbo.server.EntityImpl.setAttribute(EntityImpl.java:859)
         at oracle.jbo.server.ViewRowStorage.setAttributeValue(ViewRowStorage.java:1108)
         at oracle.jbo.server.ViewRowStorage.setAttributeInternal(ViewRowStorage.java:1019)
         at oracle.jbo.server.ViewRowImpl.setAttributeInternal(ViewRowImpl.java:1047)
         at hvbg.svi.model.dataviews.IkViewRowImpl.setBestandsstatus(IkViewRowImpl.java:264)
         at hvbg.svi.model.dienste.Aenderungsdienst.ausfuehrenAenderungsdienst(Aenderungsdienst.java:337)
         at hvbg.svi.model.dienste.Aenderungsdienst.run(Aenderungsdienst.java:290)
    Using run(), everything works perfectly.
    The view object IKView consists of four entity objects which are linked by associations. There exists an association between the entity objects ik and inlandbankverb. The xml-file for the association object is named "ik_inlandsbankverb.xml". It seems so that this definition could not be found when calling my thread in asynchronous (via start()-method call) mode.
    Is this a bug of JDeveloper?
    Thanks in advance,
    Stefan

Maybe you are looking for