Why Inner class cannot access static variables

Why is it that inner class can use only static final variables of the outerclass, and not ordinary static variables of the outer class. "Yes the JLS sepcifies that only final static variables can be used inside an inner class, esp a non blank final variable". But why this restriction.
Thanks.

so what are final static variables treated as if they
are not variables. So if the final static value is
not loaded when the class is loaded how will the
class know about the value.??The actual value wil be substituted for the name of a static final value at compile time. That's why you can use them in switch statements where you can't use any variable variable.
This is something to watch out for, by the way, because if you use a public static final value from one class in another the actual value will be compiled into the using class, so if you change the value where it's defined the class using it will have the old value until it's recompiled.

Similar Messages

  • Why inner classes cannot have static declarations ?

    Hi Friends,
    When i tried to make static declarations on a inner class which is non static, i am getting compilation error saying "inner classes cannot have static declarations". I want to know reason behind this implementation.
    Code which i have tried:
    public class TestOuter
    class TestInner{
    static int i =10;
    public static boolean validate(int a){
    if(a==0)
    System.out.println("Invalid data");
    return false;
    return true;
    public static void main(String a[]){
    boolean result = new TestOuter.TestInner.validate(0);
    System.out.println("Result="+result);
    Thanks,
    Shiju V.

    so I think if the
    outer class is not static , then Inner class can't be
    static as well. This is incorrect. An enclosed class can be indeed static while the outer is not, and vice versa.
    The difference between static/non static in regards to enclosed classes is that the static ones are 'top-level' and cannot access the members of the enclosing class.
    The effect of making an enclosed class static means there is only one instance of any variables, no matter how many instances of the outer class are created. In this situation how could the static inner class know which variables to access of its non static outer class. Of course the answer is that it could not know, and thus an static inner class cannot access instance variables of its enclosing class.
    Now, regarding non-static inner classes, and trying to give a valid answer to the original post:
    As with instance methods and variables, a non-static inner class is associated with an instance of its enclosing class and has direct access to that object's instance variables and methods.
    TestOuter outer = new TestOuter();
    TestOuter.TestInner inner = outer.new TestInner();Because an inner class is associated with an instance (inner class implicitly keeps a reference to the object of the enclosing class that created it), it cannot define any static members itself. Static members cannot access the this pointer.
    So, in an ordinary (non-static) inner class, the link to the outer class object is achieved with a special this reference. A static inner class does not have that special this reference, nor would a static method/variable of an ordinary (non-static) inner class.

  • Why method local inner class can use final variable rather than....

    Hi all
    Just a quick question.
    Why method-local inner class can access final variable defined in method only?
    I know the reason why it can not access instance variable in method.
    Just can not figure out why??
    any reply would be appreciated.
    Steven

    Local classes can most definitely reference instance variables. The reason they cannot reference non final local variables is because the local class instance can remain in memory after the method returns. When the method returns the local variables go out of scope, so a copy of them is needed. If the variables weren't final then the copy of the variable in the method could change, while the copy in the local class didn't, so they'd be out of synch.

  • Why can an inner.inner class not be static?

    First, look at these 2 classes:
    public class A1 {
    public A1() {
    new B1.C1();
    public class B1 {
    public static class C1 {
    public class A2 {
    public A2() {
    new B2.C2();
    class B2 {
    public static class C2 {
    Class A2 will compile just fine, but A1 will not saying that I can't define class C1 as static.
    Why not?
    Class C1 is not associated with an instance of B1 (because it's static), and we already have an instance of A1 (since we're in the constructor).
    Why is this so radically different that A2 (which works)?

    In class A1 the inner class B1 is just like a mehtod of class A1.
    So how we cant create static variable inside a method , similarly the class A1
    didnt accepting its inner class b! to create static class.
    (This is my assumption/view only, may be wrong)

  • Why can't I access the variables in my threads?

    hello.
    another question about threads..
    ==========================
    I have an inner class that implements Runnable (i.e. a thread) and has a variable in it. I want to be able to access that variable from outside the thread class so that I can set or retrieve the variable.
    here is the code for the program
    class myClass
         public static void main(String[] args)
              myClass c = new myClass();
         myClass()
              Thread t = new Thread(new myThread());
              t.number = 1;
              t.start();
         class myThread implements Runnable
              int number = 0;
              public void run()
         }//end myThread
    }//end myClassthe line
    t.number = 1;
    where I try to set the number variable to 1 gives me an error (in the MyClass constructor)
    This is my error
    AccessThreadVars.java:11: cannot find symbol
    symbol  : variable number
    location: class java.lang.Thread
              t.number = 1;
                        ^
    1 errorif I put a method in myThread, and then try to call that method from myClass (via t.MethodName()) it gives me that same error telling me it can't find it..
    what am I doing wrong? how can I get access my thread's variables and methods??

    1. Type names should start with an uppercase letter
    2. t is defined as a Thread, not as a myThread
    (which, may I insist, should be "MyThread"), so the
    compiler has no means of detecting that "number" is
    an accessible field of the object... which wouldn't be accessible anyway, cause you're trying to get attributes from your Runnable after wrapping it inside a Thread.
    Why don't you do something like :
    MyThread t = new MyThread();
    t.number = 1;
    new Thread(myThread).start();?
    I bet you don't use Thread's own methods anyway...

  • How can I write an instance of a class in a static variable

    Hi !
    I have an instance of a class
    Devisen dev = new Devisen();
    In an other class I have a static method and I need there the content of some variables from dev.
    public static void abc()
    { String text=dev.textfield.getText()
    I get the errormessage, that the I cannot use the Not-static variable dev in a static variable.
    I understand that I cannot reference to the class Devisen because Devisen is not static I so I had to reference to an instance. But an instance is the same as a class with static methodes. (I think so)
    Is there a possibility, if I am in a static method, to call the content of a JTextField of an instance of a class ?
    Thank you Wolfgang

    Hallo, here is more code for my problem:
    class Login {
       Devisen dev=new Devisen();
    class Devisen {
       JTextField field2;
       if (!Check.check_field2()) return; // if value not okay than return
    class Check {
       public static void check_field2()
         HOW TO GET THE CONTENT OF field2 HERE ?
    One solution ist to give the instance to the static function, with the keyword "this"
    if (!Check.check_field2(this)) return;and get the instance
    public static void check_field2(Devisen dev)BUT is that a problem for memory to give every method an instance of the class ? I have 50 fields to control and I dont want do give every check_method an instance of Devisen, if this is a problem for performance.
    Or do I only give the place where the existing instance is.
    Hmm...?
    Thank you Wolfgang

  • Inner Classes Changing Access Rights Of Parent  Members

    I read that if you access a parent class's private memebers or methods from within an inner class, those members of methods will automatically and silently be converted to having package access. This seems dangerous and I'd like to know how I could design around it.
    Here is my current dilemma. I have an EventHandler class whose handleEvent() method changes with the object's state. I've implemented this using the Strategy Pattern, where the Strategy objects are inner classes of EventHandler. The problem is that these Strategy objects need access to certain private members and methods of their parent. There is no reason, however, to give package access to these members and methods. What can I do? Or does this suggest that I need a design change? Other than this issue, though, I'm quite happy with the design.
    Thanks for any thoughts,
    John

    When inner classes access private fields or methods, the compiler generates new package-private methods
    with names like "access$000":
    import java.lang.reflect.*;
    public class X {
        private void x() {}
        class Y {
            public void y() {
                x();
        public static void main(String[] args) {
            Method[] methods = X.class.getDeclaredMethods();
            for(int i=0; i<methods.length; ++i)
                System.out.println(methods.getName());
    So it's not correct that the access to fields or methods is changed, just that additional methods are added.
    Unless you're in the habit of writing method names that contain '$', I think it's unlikely that you'll directly call
    these new methods, and if you do, it should be easy to spot!

  • Accessing static variable from subclass

    Hi,
    this question is probably fairly common but I can't seem to find the answer around: Can somebody please explain the rationale behind the following behavior ?
    public abstract class SuperClass {
        static String mess;
    public class SubClass extends SuperClass {
        static {
            mess = "Hello world!";
        static String getMess() {
            return mess;
    public class mymain {
        public static final void main(String[] args) {
            System.out.println(SubClass.getMess());
    }gives "Hello world!" as expected whereas
    public abstract class SuperClass {
        static String mess;
        static String getMess() {
            return mess;
    public class SubClass extends SuperClass {
        static {
            mess = "Hello world!";
    public class mymain {
        public static final void main(String[] args) {
            System.out.println(SubClass.getMess());
    }gives "null". It looks like the initialization block is not executed. Why?
    Thanks for your insight,
    Chris

    >
    You're essentially claiming you need to override some static methods.No, there is indeed misunderstanding here. What I need to do is implement the methods with the signature given, I'm not overriding existing methods, in fact I'm not even deriving from any existing class. I only have to create the entry points in my code as defined, then publish them to the DB, and Oracle is going to use them (I think they can be called callbacks, also again not 100% sure).
    Then it happens that in my particular case it's natural to have a master containing all the code and then subclasses that only define a few specific parameters that are to be used by the static (and instance) methods. Hence the final design. Currently my code looks like the following and seems to work (fingers crossed):
    class ParseFileCLL extends ParseFile {
        // Name of the row type.
        private final static String rowType = "CLLROW";
        // Here I initialize static fields of the ParseFile master class.
        static {
            fileType = "CLL";
            fileStruct = new FileStruct(34);
        // Type methods implementing ODCITable interface.
        static public BigDecimal ODCITablePrepare(STRUCT[] sctx, STRUCT tfinfo, String sysName)
                throws SQLException {
            // prepareContext is a static helper method defined in the master class.
            return prepareContext(funcType, rowType, rowSetType, tfinfo);
    // Other ODCI methods are only accessed directly in the master class, NOT in the subclass. Or else... WEIRD BUGS!
    // In other words:
    //  publish ParseFile.ODCITableStart() -> ok
    //  publish ParseFileCLL.ODCITableStart() -> crash
    }Not surprising. Java has plenty of undefined or inconsistently-defined behavior. The JLS is by no means perfect.
    >
    Well I kind of admire your composure about this, but it seems to me that if it's indeed the case, the meaning of it would be that the code could work in JVM 1.5.0.15 and not in 1.5.0.16, or worse run ok on Windows and not on Linux, which is if I understand correctly precisely the kind of behavior that Java was meant to cure, at least at its inception.
    I think there might be other elements to the story though.
    Thanks,
    Chris

  • Slow performance when multiple threads access static variable

    Originally, I was trying to keep track of the number of function calls for a specific function that was called across many threads. I initially implemented this by incrementing a static variable, and noticed some pretty horrible performance. Does anyone have an ideas?
    (I know this code is "incorrect" since increments are not atomic, even with a volatile keyword)
    Essentially, I'm running two threads that try to increment a variable a billion times each. The first time through, they increment a shared static variable. As expected, the result is wrong 1339999601 instead of 2 billion, but the funny thing is it takes about 14 seconds. Now, the second time through, they increment a local variable and add it to the static variable at the end. This runs correctly (assuming the final increment doesn't interleave which is highly unprobable) and runs in about a second.
    Why the performance hit? I'm not even using volatile (just for refernce if I make the variable volatile runtime hits about 30 seconds)
    Again I realize this code is incorrect, this is purely an interesting side-expirement.
    package gui;
    public class SlowExample implements Runnable
         public static void main(String[] args)
              SlowExample se1 = new SlowExample(1, true);
              SlowExample se2 = new SlowExample(2, true);
              Thread t1 = new Thread(se1);
              Thread t2 = new Thread(se2);
              try
                   long time = System.nanoTime();
                   t1.start();
                   t2.start();
                   t1.join();
                   t2.join();
                   time = System.nanoTime() - time;
                   System.out.println(count + " - " + time/1000000000.0);
                   Thread.sleep(100);
              catch (InterruptedException e)
                   e.printStackTrace();
              count = 0;
              se1 = new SlowExample(1, false);
              se2 = new SlowExample(2, false);
              t1 = new Thread(se1);
              t2 = new Thread(se2);
              try
                   long time = System.nanoTime();
                   t1.start();
                   t2.start();
                   t1.join();
                   t2.join();
                   time = System.nanoTime() - time;
                   System.out.println(count + " - " + time/1000000000.0);
              catch (InterruptedException e)
                   e.printStackTrace();
               * Results:
               * 1339999601 - 14.25520115
               * 2000000000 - 1.102497384
         private static int count = 0;
         public int ID;
         boolean loopType;
         public SlowExample(int ID, boolean loopType)
              this.ID = ID;
              this.loopType = loopType;
         public void run()
              if (loopType)
                   //billion times
                   for (int a=0;a<1000000000;a++)
                        count++;
              else
                   int count1 = 0;
                   //billion times
                   for (int a=0;a<1000000000;a++)
                        count1++;
                   count += count1;
    }

    Peter__Lawrey wrote:
    Your computer has different types of memory
    - registers
    - level 1 cache
    - level 2 cache
    - main memory.
    - non CPU local main memory (if you have multiple CPUs with their own memory banks)
    These memory types have different speeds. Depending on how you use a variable affects which memory it is placed in.Plus you have the hotspot compiler kicking in sometime during the run. In other words for some time the VM is interpreting the code and then all of a sudden its compiled and executing the code compiled. Reliable micro benchmarking in java is not easy. See [Robust Java benchmarking, Part 1: Issues|http://www.ibm.com/developerworks/java/library/j-benchmark1.html]

  • Accessing static variables

    class Array{
    static int m = 10; // how to access this variable in main()?
    public static void main(String [] args) {
    int m = 45;
    System.out.print(m );
    return ;
    }

    One problem is you are doing stuff in main that should not be done in main.
    Main is always only for kicking a program off and ensuring it cleans up nice when done, that is it. Sooner you figure this out and get into good habits the better.
    Second, you have two m variables, which one do expect to get accessed? But still, getting out of main before doing your computations will make your problem much easier to see and fix, so do that first.
    JSG

  • JDeveloper 10.1.2.0.0 - Inner class cannot be found

    Hi!<br>
    <br>
    I use Apache MyFaces 1.1.1 (Nightly Build 20051130) to create a Web app and imported all necessary libraries. I want to write a custom ViewHandler at the moment and experience a strange problem. I want to use a public inner class of javax.faces.application.StateManager, named SerializedView, but this class cannot be found when I try to import it with the following statement:<br>
    import javax.faces.application.StateManager.SerializedView;<br>
    JDeveloper just says: <br>
    Imported class 'javax.faces.application.StateManager.SerializedView' not found<br>
    I already successfully use many other javax.faces classes, like StateManager...<br>
    Any help would highly be appreciated, since this is a real blocker for me.<br>
    <br>
    Regards,
    Matthias

    Hi again!<br>
    <br>
    The problem is solved for the most part now. Compilation works fine, although the Java editor says the class SerializedView cannot be found.<br>
    <br>
    So the Java editor's behavior is still strange...<br>
    <br>
    Regards,<br>
    Matthias

  • Class cannot access its superinterface

    We're migrating an application from jDeveloper 9 to jDeveloper 10g (10.1.3.5), and have got almost everything working on the new server.
    However, one thing is not working: whenever a DataTable is set up with an edittarget (to edit a row in a new webpage, and where state is maintained via a cookie),
    I get an error message in the resulting webpage.
    Here is an example of such an editable DataTable:
    <jbo:DataTable datasource="dsPrisliste" edittarget="ApPristilbudView_Edit.jsp" /> The "intermediate" file, ApPristilbudView_Edit.jsp, essentially does the following:
    <%@ page language="java" import="oracle.jbo.html.*, oracle.jbo.http.*" errorPage="errorpage.jsp" contentType="text/html;charset=windows-1252" %>
    <%@ taglib  uri="/webapp/DataTags.tld"  prefix="jbo" %>
    <html>
    <head>
    <META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
    </head>
    <body>
    %>
    <jbo:ApplicationModule id="am" configname="myApp.bc.BcModSalgsRapp.BcModSalgsRappLocal" releasemode="Reserved" />
    <%
      session.setAttribute("ApPristilbud_am", am);
    %>
    <jbo:DataSource id="ds" appid="am" viewobject="ApPristilbudView" />
    <h4>Pristilbud</h4>
    <jbo:DataEdit datasource="ds" relativeUrlPath="DataEditApPristilbudComp.jsp" />
    <jbo:ReleasePageResources />
    </body>
    </html> which results in the error message:
    <font size="3">
    Error Message: class oracle.jbo.http.HttpSessionCookieImpl cannot access its superinterface oracle.jbo.http.BindingListener
    </font>
    <font size="3" color="blue">
    <tt>
    Pristilbud
    Application Error
    Error Message: class oracle.jbo.http.HttpSessionCookieImpl cannot access its superinterface oracle.jbo.http.BindingListener
    Ugyldig klasse: oracle.jbo.http.HttpSessionCookieImpl Laster: approd.web.aptest:0.0.0
    Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4J_approd/applications/approd/aptest/WEB-INF/lib/bc4jhtml.jar Konfigurasjon: WEB-INF/lib/ directory in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\applications\approd\aptest\WEB-INF\lib
    Avhengig klasse: DataEditApPristilbudComp Laster: approd.web.aptest.jsp32124385:0.0.0 Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4Japprod/application-deployments/approd/aptest/persistence/_pages/
    Konfigurasjon: *.jsp in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\application-deployments\approd\aptest\persistence\_pages
    javax.servlet.jsp.JspTagException: class oracle.jbo.http.HttpSessionCookieImpl cannot access its superinterface oracle.jbo.http.BindingListener
         Ugyldig klasse: oracle.jbo.http.HttpSessionCookieImpl
         Laster: approd.web.aptest:0.0.0
         Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4J_approd/applications/approd/aptest/WEB-INF/lib/bc4jhtml.jar
         Konfigurasjon: WEB-INF/lib/ directory in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\applications\approd\aptest\WEB-INF\lib
         Avhengig klasse: _DataEditApPristilbudComp
         Laster: approd.web.aptest.jsp32124385:0.0.0
         Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4J_approd/application-deployments/approd/aptest/persistence/_pages/
         Konfigurasjon: *.jsp in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\application-deployments\approd\aptest\persistence\_pages
         at oracle.jbo.html.jsp.datatags.ComponentTag.doStartTag(ComponentTag.java:70)
         at ApPristilbudView_Edit._jspService(_ApPristilbudView__Edit.java:119)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    </tt></font>
    Unfortunately, parts of that is in Norwegian:
    Laster = Loading
    Ugyldig klasse = invalid class
    Avhengig klasse = invalid class
    Kodekilde: Code source
    What can I try, to fix this problem? Obviously, this is a run-time error (I get no warnings or errors during compilation), so perhaps something is incorrectly configured on the server container instance ("OC4J_approd")?
    I should also mention that this (i.e., editing data) works perfectly when I run the application on the local server (from within JDeveloper)...
    - j
    Edited by: joakim00 on Dec 7, 2012 1:04 AM

    We're migrating an application from jDeveloper 9 to jDeveloper 10g (10.1.3.5), and have got almost everything working on the new server.
    However, one thing is not working: whenever a DataTable is set up with an edittarget (to edit a row in a new webpage, and where state is maintained via a cookie),
    I get an error message in the resulting webpage.
    Here is an example of such an editable DataTable:
    <jbo:DataTable datasource="dsPrisliste" edittarget="ApPristilbudView_Edit.jsp" /> The "intermediate" file, ApPristilbudView_Edit.jsp, essentially does the following:
    <%@ page language="java" import="oracle.jbo.html.*, oracle.jbo.http.*" errorPage="errorpage.jsp" contentType="text/html;charset=windows-1252" %>
    <%@ taglib  uri="/webapp/DataTags.tld"  prefix="jbo" %>
    <html>
    <head>
    <META NAME="GENERATOR" CONTENT="Oracle JDeveloper">
    </head>
    <body>
    %>
    <jbo:ApplicationModule id="am" configname="myApp.bc.BcModSalgsRapp.BcModSalgsRappLocal" releasemode="Reserved" />
    <%
      session.setAttribute("ApPristilbud_am", am);
    %>
    <jbo:DataSource id="ds" appid="am" viewobject="ApPristilbudView" />
    <h4>Pristilbud</h4>
    <jbo:DataEdit datasource="ds" relativeUrlPath="DataEditApPristilbudComp.jsp" />
    <jbo:ReleasePageResources />
    </body>
    </html> which results in the error message:
    <font size="3">
    Error Message: class oracle.jbo.http.HttpSessionCookieImpl cannot access its superinterface oracle.jbo.http.BindingListener
    </font>
    <font size="3" color="blue">
    <tt>
    Pristilbud
    Application Error
    Error Message: class oracle.jbo.http.HttpSessionCookieImpl cannot access its superinterface oracle.jbo.http.BindingListener
    Ugyldig klasse: oracle.jbo.http.HttpSessionCookieImpl Laster: approd.web.aptest:0.0.0
    Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4J_approd/applications/approd/aptest/WEB-INF/lib/bc4jhtml.jar Konfigurasjon: WEB-INF/lib/ directory in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\applications\approd\aptest\WEB-INF\lib
    Avhengig klasse: DataEditApPristilbudComp Laster: approd.web.aptest.jsp32124385:0.0.0 Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4Japprod/application-deployments/approd/aptest/persistence/_pages/
    Konfigurasjon: *.jsp in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\application-deployments\approd\aptest\persistence\_pages
    javax.servlet.jsp.JspTagException: class oracle.jbo.http.HttpSessionCookieImpl cannot access its superinterface oracle.jbo.http.BindingListener
         Ugyldig klasse: oracle.jbo.http.HttpSessionCookieImpl
         Laster: approd.web.aptest:0.0.0
         Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4J_approd/applications/approd/aptest/WEB-INF/lib/bc4jhtml.jar
         Konfigurasjon: WEB-INF/lib/ directory in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\applications\approd\aptest\WEB-INF\lib
         Avhengig klasse: _DataEditApPristilbudComp
         Laster: approd.web.aptest.jsp32124385:0.0.0
         Kodekilde: /D:/oracle/10.1.3.1/OracleAS/j2ee/OC4J_approd/application-deployments/approd/aptest/persistence/_pages/
         Konfigurasjon: *.jsp in D:\oracle\10.1.3.1\OracleAS\j2ee\OC4J_approd\application-deployments\approd\aptest\persistence\_pages
         at oracle.jbo.html.jsp.datatags.ComponentTag.doStartTag(ComponentTag.java:70)
         at ApPristilbudView_Edit._jspService(_ApPristilbudView__Edit.java:119)
         at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
         at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
         at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
         at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    </tt></font>
    Unfortunately, parts of that is in Norwegian:
    Laster = Loading
    Ugyldig klasse = invalid class
    Avhengig klasse = invalid class
    Kodekilde: Code source
    What can I try, to fix this problem? Obviously, this is a run-time error (I get no warnings or errors during compilation), so perhaps something is incorrectly configured on the server container instance ("OC4J_approd")?
    I should also mention that this (i.e., editing data) works perfectly when I run the application on the local server (from within JDeveloper)...
    - j
    Edited by: joakim00 on Dec 7, 2012 1:04 AM

  • How to access static variable from a Thread class

    Kindly help me.......
    here's the code.....
    class Thread1 extends Thread
    int j=0;
    myClass2 mc = new myClass2();
         public void run()
              for( int a=0;a<6;a++)
                        {try
                             { Thread.sleep(5000);
                             catch(Exception e){System.out.println("Interrupted Exception");}
                             j++;
    mc.change1(i);
    } System.out.println("Thread1 executes "+j+" times");
    class Thread2 extends Thread
    int k=0;
         myClass2 mc1 = new myClass2();
         public void run()
              for( int a=0;a<6;a++)
                        {try
                             { Thread.sleep(5000);
                             catch(Exception e){System.out.println("Interrupted Exception");}
                             k++;
    mc1.change2(i);
    }System.out.println("Thread2 executes "+k+" times");
    class myClass2
    static int i=5;
    public synchronized void change1(int s)
    s=6;
    System.out.println("New value of i:"+s);
    public synchronized void change2(int s)
    s=7;
    System.out.println("New value of i:"+s);
         public static void main(String args[])
    Thread1 b1 = new Thread1();
    Thread2 b2 = new Thread2();
         b1.start();
    b2.start();
    I am unable to pass the variable i in my method call in Thread1: mc.change1(i); and similarly in Thread2:mc.change2(i);

    You can declare your i variable in myClass2 as public static and then simply call there
        mc.change1( myClass2.i ) ;

  • Accessing static variable using GWT remote servlet

    Hi all,
    Using GWT, I'm trying to call two methods which exist in a
    RemoteService from my entrypoint class.
    I have two methods within my remoteService servlet, method A and
    method B.
    Method A returns an int and sets an arraylist.
    Method B returns the arraylist, myList.
    I'm assuming that a single callback is associated with a single
    servlet method? Is it possible to access the arraylist, which has been
    set from calling method A, using the callback?
    e.g.
    //client code:
                   MyServiceAsync myService = (MyServiceAsync)
    GWT.create(MyService.class);
                   AsyncCallback callback = new AsyncCallback(){
                      public void onSuccess(Object result) {
                      public void onFailure(Throwable caught) {
                  myService.foo(callback);
    // servlet code
    public class MyServiceImpl extends RemoteServiceServlet implements
    MyService{
           public static List myList = new ArrayList();
           public int A(){
                   setB();
                   return 10;
           public void setB(){
                   // this adds five elements to a static arraylist, myList
           public List getB(){
                   return myList;
    }

    Ok, frist solution (the better one) is that You can create a class that will both contain the int and the list. E.g.
    public class MyObject implements Serializable {
    private int value;
    private List<Object> list;
    //getters and settersThen You can set the values You're interested in the RemotServiceServlet and simply return this object - aync callbacks can return various types of objects (not only primitives) but under two conditions:
    1) The object must implement the Serializable interface
    2) The object must have public no argument constructor or no constructor at all.
    Then in your client class You'll have:
    MyServiceAsync myService = (MyServiceAsync) GWT.create(MyService.class);
    AsyncCallback<MyObject> callback = new AsyncCallback<MyObject>(){
    public void onSuccess(MyObject result) {
      result.getList();
      result.getInt();
    public void onFailure(Throwable caught) {
    myService.A(callback);
    };The second solution is to invoke a method B callback in the result of A's callback:
    MyServiceAsync myService = (MyServiceAsync) GWT.create(MyService.class);
    AsyncCallback aCallback = new AsyncCallback(){
    public void onSuccess(Object result) {
       //here You get the in value
       AsyncCallback bCallback = new AsyncCallback(){
        public void onSuccess(Object result) {
         //here You get the list
        public void onFailure(Throwable caught) {
        myService.B(bCallback);
    public void onFailure(Throwable caught) {
    myService.A(aCallback);Hope this is clear and will help You. (Remember also the use generics!)

  • Why CR2008 SDK cannot access conditionformula inside TextObject?

    After I drag a numeric type formulafield into textobject and set some condition formulas such as decimal separator at the formulafield by the CR designer, I try to access these kind of formulas by code. The result is I get nothing. the code like this,
    CrystalDecisions.CrystalReports.Engine.ReportDocument boReport = New CrystalDecisions.CrystalReports.Engine.ReportDocument();
    boReport.Load("Report1.rpt")
    cdRptDoc= boReport.ReportClientDocument;
    TextObject  textobject = (TextObject)(cdRptDoc.ReportDefinition.Areas[0].Sections[0].ReportObjects[0]);
    ParagraphFieldElement paraElement = (ParagraphFieldElement)(textObj.Paragraphs[0].ParagraphElements[0]);
    ConditionFormula conditionformula = paraElement.FieldFormat.NumericFormat.ConditionFormulas[CrNumericFieldFormatConditionFormulaTypeEnum.crNumericFieldFormatConditionFormulaTypeDecimalSymbol];
    if(conditionformula != null)
         MessageBox.Show(conditionformula.Text);
    Why?
    Edited by: Robert Xiang on Jun 10, 2010 10:57 AM

    I believe you will need to use the InProc RAS APIs to modify the formula.
    See KBase [1471500 - Using the RAS SDK for VS .NET, how do you set a field's background color?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_dev/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes.do].
    For more info re. InprocRas see [this|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10b840c0-623f-2b10-03b5-9d1913866b32] article.
    Ludek

Maybe you are looking for

  • HP DV-6822TX heating and randomly shutting down

    Hi, Ive had this HP DV6822TX for over 3 years now and its been working happily. Ive had Windows 7 for over 6 months and its been all hunky dory. Recently, Ive noticed that the back of laptop heats quite a lot and sometimes it shuts down and doesn't w

  • UnsupportedOperationException after moving to Tomcat 6.0

    I recently started testing my application on JEE 5/JSF 1.2/Tomcat 6.0. It was previously running without error on J2EE 1.4/JSF 1.1/Tomcat 5.5. Upon calling a method via an ActionListener, this exception occurs. It oddly appears to be with a pojo stri

  • Code inspection warnings in Function Group

    Hello, Help appreciated. I have created a Function Group. When code inspection is done it is giving following warnings : Warnings: 1. Message code Len The parameter "I_INHDR" is transferred as value. Use reference transfer 2. Message Code MESSAGEGM1

  • Notebook HP Pavilion | Touchsmart

    My laptop has always been very efficient and useful, but a couple problems have been occuring with it latly.  One of the largest problems, is my Increadibly huge framerate drops happening this past month. Windows 8.1 without many tasks open, will run

  • Problema flex pantalla

    buenas a todos tengo un lenovo g510 que de hace unas semanas para aqui me esta dando problemas de pantalla, segun como la oriente se ve bien o se ve mal, en un monitor externo se ve bien ya se por cable hdmi o vga. creo que es el cable flex que esta