JSP Inner class generates IllegalAccess Error

I created an inner class inside of a JSP file. Unfortunately, Weblogic 5.1.0
          compiles the inner class as private. So I got an IllegalAccessError. Is
          there a way to use inner classes in JSP files?
          Thank you.
          - Remington
          Here is my code:
          <%
          Object obj = new Object()
          public int hashCode()
          return 100;
          out.println( "obj: " + obj.hashCode() );
          %>
          Error messages:
          Wed Jan 31 17:23:38 PST 2001:<E> <ServletContext-General> Servlet failed
          with Exception
          java.lang.IllegalAccessError: try to access class
          jsp_servlet/_test/_test01$1 from class jsp_servlet/_test/_test01
          at jsp_servlet._test._test01._jspService(_test01.java:66)
          at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
          at
          weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
          :105)
          at
          weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
          l.java:742)
          at
          weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
          l.java:686)
          at
          weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
          Manager.java:247)
          at
          weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
          at
          weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
          at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
          Code)
          

Works ok with sp8.
          Remington Li <[email protected]> wrote:
          > I created an inner class inside of a JSP file. Unfortunately, Weblogic 5.1.0
          > compiles the inner class as private. So I got an IllegalAccessError. Is
          > there a way to use inner classes in JSP files?
          > Thank you.
          > - Remington
          > Here is my code:
          > <%
          > Object obj = new Object()
          > {
          > public int hashCode()
          > {
          > return 100;
          > }
          > };
          > out.println( "obj: " + obj.hashCode() );
          > %>
          > Error messages:
          > Wed Jan 31 17:23:38 PST 2001:<E> <ServletContext-General> Servlet failed
          > with Exception
          > java.lang.IllegalAccessError: try to access class
          > jsp_servlet/_test/_test01$1 from class jsp_servlet/_test/_test01
          > at jsp_servlet._test._test01._jspService(_test01.java:66)
          > at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
          > at
          > weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
          > :105)
          > at
          > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
          > l.java:742)
          > at
          > weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
          > l.java:686)
          > at
          > weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
          > Manager.java:247)
          > at
          > weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java:361)
          > at
          > weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java:261)
          > at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled
          > Code)
          Dimitri
          

Similar Messages

  • Inner classes generated by xmlbeans

    I was given a library to use that most of it was created with the apache xmlbeans framework. The following code works within the eclipse java ide but JDeveloper does not find the inner factory class of the QueryEnterpriseAckDocument class. How does JDeveloper handle working with inner classes. This may be an issue that requires going back to eclipse as the ide.
         QueryEnterpriseAckDocument ackDoc = QueryEnterpriseAckDocument.Factory.newInstance();
         QueryEnterpriseAckDocument.QueryEnterpriseAck ack = ackDoc.addNewQueryEnterpriseAck();
    thanks,
    Jeremy Wilson
         

    Is there some kind of meta-specification for JSR 269 that explains the design goals? Not really, only what is here http://jcp.org/en/jsr/detail?id=269
    With such a document, it might also be easier to figure out how processors are supposed to work.JSR 269 is designed to permit solutions to various complex scenarios rather than provide solutions. Those scenarios and their intended solution are not often obvious from the API specs.
    You might like to take a look at https://hickory.dev.java.net/ where I have a project to supply some tooling to assist annotation processor authors, and a wiki to document things. Allocating time to this is not easy, but the 3 packages in the API there are pretty robust. The test cases in source code for those have plenty of examples of some of the more complex design goals, such as the ability to write an annotation processor which works correctly in an incremental compile scenario, when the generated file derives from more than one source file, not all of which may be included in an incremental compile.
    Other than that, if you have any particular questions, just ask in this forum, and Joe (JSR 269 spec lead) or myself should be able to answer them for you.
    Bruce
    Edited by: brucechapman on Feb 4, 2008 1:35 PM

  • Inner class not found error when compiling project

    I tried to use 9iDS (JDeveloper 9.0.2.822) to generate applet that has textbox and button.
    I inserted UI components trough UI editor and added actionlistener there.
    Now when trying to compile (and run) project I get always "Class MyClass$1 not found in class MyPackage.MyClass"
    This only happens if both package and class are same named. If not it works... Is this feature of java, jdeveloper or something other? (Well, actually this is not a problem because rarely packages and classes are named as same.)

    Also, it's probably a good idea to name your packages different than your classesMoreover, common naming conventions dictate you should never even use capitals in your package names if I'm not mistaken. Whereas class names should always at least begin with a capital.
    This will help prevent a lot of confusion, both for the developer and the IDE. ;-)

  • Generated servlet error - unable to compile class for JSP - using NB5.5/SS9

    I am using NB5.5 beta2 and Sun server 9.0 with JSF 1.1 - all is OK when I am creating firts JSF application - welcomeJSF.jsp page is rendered normally - but when I am adding one more jsp with JSP view and so on - then - I am getting errors in both JSF pages - both - in original welcomeJSF and the new invoice.jsp page
    here is code for typical error
    org.apache.jasper.JasperException: Unable to compile class for JSP
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\ERPSolution\org\apache\jsp\welcomeJSF_jsp.java:99: cannot find symbol
    [javac] symbol : method setJspId(java.lang.String)
    [javac] location: class com.sun.faces.taglib.jsf_core.ViewTag
    [javac] jspxth_f_view_0.setJspId("id7");
    [javac] ^
    Generated servlet error:
    [javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\ERPSolution\org\apache\jsp\welcomeJSF_jsp.java:144: cannot find symbol
    [javac] symbol : method setJspId(java.lang.String)
    [javac] location: class com.sun.faces.taglib.html_basic.OutputTextTag
    [javac] jspxth_h_outputText_0.setJspId("id17");
    [javac] ^
    Generated servlet error:
    [javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\ERPSolution\org\apache\jsp\welcomeJSF_jsp.java:145: setValue(java.lang.String) in com.sun.faces.taglib.html_basic.OutputTextTag cannot be applied to (javax.el.ValueExpression)
    [javac] jspxth_h_outputText_0.setValue(org.apache.jasper.runtime.PageContextImpl.getValueExpression("Java Server Faces", (PageContext)_jspx_page_context, java.lang.Object.class, null));
    [javac] ^
    [javac] 3 errors
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:94)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:384)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:461)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:528)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:507)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:495)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:530)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:409)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:317)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:414)
         com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:455)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:139)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
         com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
         com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
         org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
         com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
         com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
         com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
         com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
         com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
         com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
         com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    note The full stack trace of the root cause is available in the Sun Java System Application Server Platform Edition 9.0 logs.
    and there is output for another error:
    Generated servlet error:
    [javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\ERPSolution\org\apache\jsp\welcomeJSF_jsp.java:144: cannot find symbol
    [javac] symbol : method setJspId(java.lang.String)
    [javac] location: class com.sun.faces.taglib.html_basic.OutputTextTag
    [javac] jspxth_h_outputText_0.setJspId("id17");
    [javac] ^
    Generated servlet error:
    [javac] E:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\ERPSolution\org\apache\jsp\welcomeJSF_jsp.java:145: setValue(java.lang.String) in com.sun.faces.taglib.html_basic.OutputTextTag cannot be applied to (javax.el.ValueExpression)
    [javac] jspxth_h_outputText_0.setValue(org.apache.jasper.runtime.PageContextImpl.getValueExpression("Java Server Faces", (PageContext)_jspx_page_context, java.lang.Object.class, null));
    [javac] ^
    [javac] 3 errors
    and here is code of my new invoice.jsp page:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <%--
    The taglib directive below imports the JSTL library. If you uncomment it,
    you must also add the JSTL library to the project. The Add Library... action
    on Libraries node in Projects view can be used to add the JSTL 1.1 library.
    --%>
    <%--
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    --%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <f:view>
       <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
          <h1><h:outputText value="Java Server Faces" /></h1>
        <h:inputText value="#{managerBean.currentInvoice.id}"/>
        <h:inputText value="#{managerBean.currentInvoice.description}"/>
        <h:inputText value="#{managerBean.currentInvoice.total}"/>
        <h:commandButton value="new_invoice"
                         type="submit"
                         actionListener="#{managerBean.createNewInvoice}"/> 
        </body>
    </f:view>and faces-config.xml file:
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
    <!-- =========== FULL CONFIGURATION FILE ================================== -->
    <faces-config>
        <managed-bean>
            <managed-bean-name>managerBean</managed-bean-name>
            <managed-bean-class>com.brl.ERPSolution.ui.ManagerBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
    </faces-config>managerBean was intended to be backing beans which will call the facaed beans of EJB 3.0 entity beans - but at presnet - almost empty methods are declared there:
    package com.brl.ERPSolution.ui;
    import javax.faces.event.ActionEvent;
    import com.brl.solutions.EJB3.*;
    * @author Administrator
    public class ManagerBean {
        protected int currentInvoiceId;
        protected Invoices currentInvoice;
        protected InvoicesFacade invoicesFacade;
        /** Creates a new instance of ManagerBean */
        public ManagerBean() {
        /* business methods */
        public void createNewInvoice(ActionEvent actionEvent)
            invoicesFacade.create(this.currentInvoice);
        public Invoices getCurrentInvoice()
            return this.currentInvoice;
        public void setCurrentInvoice(Invoices currentInvoice)
            this.currentInvoice=currentInvoice;
    }I read in one blog (actually - the only page which was returned by yahoo - so - this should be very rare error!!!) to try to use Sun server's verifier.bat - and - it reported 0 errors and 0 warning. Build was succesfull as well and also - deployment was without errors - but - above mentioned error appeared during the automatic compilation of jsp pages/servlet when newly deployed jsps are first accessed from remote browser.
    So - is it possible, please, to receive some advice - what to do further? I feel that my invoice.jsp page can be with errors, - however - the original welcomeJSF.jsp should be working without errors even the erronwous JFS jsp page is added to web application.
    Thans for any adice or hint in advance!!!

    OK - I have made 'clean and build main project' from NB menu and the deployed the resulting *.war and the error messages have disappeared... So - it seems to be bug...

  • OJC error w/ assert & inner class

    The following code generates an error:
    public class Foo {
    public class Bar {}
    public Foo() {}
    public static void main(String[] args) {
    assert false == true:"Foo Bar";
    ojc Foo.java -source 1.4 -classpath c:\j2sdk1.4.1\jre\lib\rt.jar -verbose
    [jdk location retrieved from JAVA_HOME environment variable: c:\j2sdk1.4.1]
    [classpath: c:\j2sdk1.4.1\lib\rt.jar;c:\j2sdk1.4.1\lib\i18n.jar;c:\j2sdk1.4.1\li
    b\sunrsasign.jar;c:\j2sdk1.4.1\lib\jsse.jar;c:\j2sdk1.4.1\lib\jce.jar;c:\j2sdk1.
    4.1\lib\charsets.jar;c:\j2sdk1.4.1\classes;c:\j2sdk1.4.1\jre\lib\rt.jar]
    [sourcepath: c:\j2sdk1.4.1\jre\lib\rt.jar]
    [encoding: default]
    makeLevel = 1
    [parsing C:\temp\Foo.java [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\AssertionError.class 50ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Error.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Throwable.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Object.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\io\Serializable.class 0ms]
    60ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Class.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\String.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Comparable.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\CharSequence.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\RuntimeException.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Exception.class 0ms]
    [flattening class Foo]
    [flattening class Foo$Bar]
    C:\temp\Foo.java:8: error #300: constructor AssertionError(<anything>) not found
    in class java.lang.AssertionError
    assert false == true:"Foo Bar";
    ^
    Total build elapsed time = 70ms
    [10 lines compiled in 70ms from 1 files, generating 0 classes]
    1 error
    The same code compiles fine with Sun's JDK 1.4.1 compiler. Removing the inner class allows the code to compile fine with OJC.
    Is this a known OJC bug?
    TIA,
    David

    It is a known bug that has been fixed in 9.0.4. We don't plan to ship 9.0.4
    anytime soon. If you are using 9.0.3, send me an email to
    [email protected] and I will send you a workaround. In your email
    specify the JDev build number that you are using (please, see
    about box).
    Regards,
    Michel

  • Issue with JSPs with inner classes (bug)

    FYI:
    Turning on Versioning in the registry (Disable=0) JSPs with inner classes causes the following IllegalAccessException...
    This has been confirmed with SP3 and SP4 with our testing...
    14/Jan/2002 13:26:24:4] error: Exception: SERVLET-run_failed: Failed in running template: /NASApp/fortune/foo.jsp, java
    lang.IllegalAccessError: try to access class jsp.APPS.fortune.foo$foobar from class jsp.APPS.fortune.foo
    xception Stack Trace:
    ava.lang.IllegalAccessError: try to access class jsp.APPS.fortune.foo$foobar from class jsp.APPS.fortune.foo
    at jsp.APPS.fortune.foo._jspService(foo.java:78)
    at org.apache.jasper.runtime.HttpJspBase.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJspCompiler(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUriRestrictOutput(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Unknown Source)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at java.lang.Thread.run(Thread.java:479)
    Looking for work around....
    Cheers,
    Martin Gee

    I do not see why you would use two sorts.
    And what is the issue exactly by the way? Errors?
    So, the records before the Merge Join need to come sorted, to achieve this simply tick:
    Arthur My Blog

  • JAXB: Error compiling classes generated by xjc (file name too long)

    Hi friends,
    I am trying to compile classes that are generated by using XJC tool on xsd file. The compilation fails with following message.
    buildxsdmodel:
        [javac] Compiling 794 source files to /home/uchamad/working/teleworker/ejb/build/classes
        [javac] /home/uchamad/working/teleworker/ejb/build/tmpsrc/uk/co/novatel/teleworker/model/wlr/bulksearch
    results/impl/ApplicationInformationTypeImpl.java:58372: error while writing
    uk.co.novatel.teleworker.model.wlr.bulksearchresults.impl.ApplicationInformationTypeImpl.XMLRequestID
    TypeImpl.SearchOrderResultsTypeImpl.SearchTypeDetailTypeImpl.OrderTypeImpl.OrderDetailsTypeImpl.
    OrderLinesTypeImpl.NumberPortingTypeImpl.OLODetailsTypeImpl.NumberLocationTypeImpl.OLOMainP
    STN1AddressTypeImpl.Unmarshaller: /home/uchamad/working/teleworker/ejb/build/classes/uk/co/novatel
    /teleworker/model/wlr/bulksearchresults/impl/ApplicationInformationTypeImpl$XMLRequestIDTypeImpl$S
    earchOrderResultsTypeImpl$SearchTypeDetailTypeImpl$OrderTypeImpl$OrderDetailsTypeImpl$OrderLin
    esTypeImpl$NumberPortingTypeImpl$OLODetailsTypeImpl$NumberLocationTypeImpl$OLOMainPSTN1A
    ddressTypeImpl$Unmarshaller.class (File name too long)
        [javac]                                             public class Unmarshaller
        [javac]                                                    ^
        [javac] 1 error
    The compiler is complaining about the file name being too long. This is happening because the java classes when generated from XSD contains deep nesting of inner classes. So when it comes to compile the .class name file is too long for the operating system.
    I am trying this on unix box.
    I wonder if there is a way to configure XJC so that it does not produce inner classes but instead keep them out.
    Any help would be appreciated.
    many thanks
    Usmangani

    Flattening your schema definition will flatten the output files, too -- that will probably be nice for coding as well since you wont have to use class names such as SomeTypeNestedInAnotherTypeThatHasYetAnotherType. Instead of having all of the elements defined directly within the enclosing root element, define logical chunks at the top level and incorporate them in the definition of real root element of your documents by reference.

  • Error in JSP : Ambiguous class

    In application i am getting following error :-
    Error in JSP, Ambiguous class: java.beans.Statement and java.sql.Statement
    here java.beans package is not imported still it gives error.
    if i write java.sql.Statement then it works fine.
    Code is as follows :-
    <%@ page
    language="java"
    import="java.sql.*"
    %>
    <%
    String a="Hello World";
    out.println(a);
    Statement st = null;
    %>
    Regards
    Rahul

    Hi Rahul,
    Someone had a similar question in another java newsgroup and there
    someone explained that "java.beans.*" is added to the imports in the
    generated Java file by the jsp container. Thus it seems to be an
    implicit import so as you already figured out you need to write the full
    path name to make it unambigous.
    Regards,
    /Helena
    Rahul wrote:
    In application i am getting following error :-
    Error in JSP, Ambiguous class: java.beans.Statement and java.sql.Statement
    here java.beans package is not imported still it gives error.
    if i write java.sql.Statement then it works fine.
    Code is as follows :-
    <%@ page
    language="java"
    import="java.sql.*"
    %>
    <%
    String a="Hello World";
    out.println(a);
    Statement st = null;
    %>
    Regards
    Rahul

  • Compiler error when useing switch statements in an inner class

    I have defined several constants in a class and want to use this constans also in an inner class.
    All the constants are defined as private static final int.
    All works fine except when useing the switch statement in the inner class. I get the compiler error ""constant expression required". If I change the definition from private static final to protected static final it works, but why?
    What's the difference?
    Look at an example:
    public class Switchtest
       private static final int AA = 0;     
       protected static final int BB = 1;     
       private static int i = 0;
       public Switchtest()
          i = 0; // <- OK
          switch(i)
             case AA: break; //<- OK, funny no problem
             case BB: break; //<- OK
             default: break;
      private class InnerClass
          public InnerClass()
             i = 0; // <- OK: is accessible
             if (AA == i) // <- OK: AA is seen by the inner class; i  is also accessible
                i = AA + 1;
             switch(i)
                case AA: break; // <- STRANGE?! Fail: Constant expression required
                case BB: break; // <- OK
                default: break;
    }Thank's a lot for an explanation.

    Just a though:
    Maybe some subclass of Switchtest could decalare its own variable AA that is not final, but it can not declare its own BB because it is visible from the superclass. Therefore the compiler can not know for sure that AA is final.

  • Calling an inner class in a jsp:usebean tag

    Hi everybody !
    Here's my problem : working in my project on multiple pages, I'm using inner classes/beans to limitate my '.java' files but I'm stuck when calling that 'inner-bean' in my jsp:usebean tag.
    First, I tried to declare in the class parameter : 'class="MyPrincipalBean.theInnerBean" but jsp returns me a 'not found' message.
    I tried an other issue with this :
    'class="MyPrincipalBean$theInnerBean" but I encountered a 'Attempt to use a bean type without a void constructor in jsp:useBean tag (JSP 1.1 specification, 2.13.1)'. Since I can't find that specification, I'm sending an SOS.
    Am I on the good way ? If somebody as encoutered that sort of problem, it would be very kind of you to help me.
    Thanks for your help !
    [email protected]

    Thanks for your help!
    I must recognize that my explainations weren't really precise.
    My principal bean owns a table of my inner-class type :
    public class FirstBean extends EntityBean {
    private SecondBean[] tabSB;
    public SecondBean[] getTabSB() {...}
    public void setTabSB(SecondBean[] p_tabSB) {...}
    public class SecondBean {...}
    So I can call a specific bean from the tab in my Servlet for another page.
    But I think I have the solution and I need your advise :
    I tried this :
    <jsp:useBean id="FirstBean" class="<...>.FirstBean" scope="session" />
    <jsp:useBean id="SecBean" beanName="<...>.FirstBean$SecondBean" type="<...>.FirstBean$SecondBean" scope="request" />
    And would you believe it ? It seems to work ! But I have to test this farther to be sure. What do you think of it ?

  • Error with inner Classes

    I've a Swing app in wich I've the following code :
    final ComboBoxEditor editor = comboBox.getEditor();
    editor.getEditorComponent().addKeyListener(new java.awt.event.KeyAdapter() {
    public void keyReleased(KeyEvent e) {
    combo_keyReleased(e,editor);
    Runned in a normal way it works, runned via Webstart 1.4.2 it gives me :
    java.lang.ClassFormatError: it/axioma/basic/application/templates/ClWidgetCombo$2 (Illegal Variable name " val$editor")
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(Unknown Source)
         at java.security.SecureClassLoader.defineClass(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.defineClass(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.access$100(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
    etc...
    Could someone explain me why ?
    Is there any workaround ?
    TIA
    Tullio

    There seems to be a problem using final variables with anonymous inner classes under a different classloader, see http://forum.java.sun.com/thread.jsp?forum=38&thread=372291

  • JDev Compiler Error? - Compiling inner classes

    This maybe just an interpretation of the language standard, but the compiler behavaviour is different from previous versions of JDeveloper and other Java IDE's, with no explanation found.
    Using JDeveloper 9.02.829 the following error is received.
    Error(13,9): class test$abc not found in class test.test
    when compiling the following class
    package test;
    public class test
    class abc { }
    public test()
    public void t ()
    abc a = new abc();
    The solution is to ensure the package name and class name are different (case sensitive) iff the class contains an inner class
    Whilst this can be done it can pose a problem porting older code into this release of JDeveloper, whilst no problem exists with other IDE's or older versions of the JDevloper IDE.
    The question is this a bug or a feature?

    This is a bug that got fixed a while back. The bug is with
    the fact that the class and the package have the same name.
    The bug is definitely fixed in 9.0.3 Preview Release which
    is currently available on OTN. 9.0.3 Production should be
    available anyday now.
    Michel

  • Error in compiling: file javax\servlet\jsp\PageContext.class not found

    Hi,
    i'm getting an error when I'm trying to compile an java file. The error is as follows:
    cannot access javax.servlet.jsp.PageContext
    file javax\servlet\jsp\PageContext.class not found
    Isn't the javax package included in jdk? I've installed jdk 1.3.1_03 and j2re1.4.0_02. Shouldn't this PageContext.class be automatically loaded when i've installed jdk?
    I'm getting desperated! I've tried almost everything: i've changed the classpath, moved the directory of the java file I'm trying to compile over and over but i'm getting no success!
    Any help is very welcome!
    Thankx,
    Nuno.

    hmmm... i had a look and it seems that what you are trying to "import" is actually in a package... instead of import try:
    package javax.servlet.jsp;you may need to go download this "package" and complile it in the directory you are working in.
    my advice: try the above statement (which does compile for me), if it doesn't work, you will need to find the source code for this package and compile it just like you do any other source code.
    hope this helps.

  • Trying to serialize inner class and getting various errors.

    Hi, I'm working on a program that contains the inner class User. user implements serializable, and writes just fine. For some strange reason, though, after I read it, I keep getting NullPointerExceptions in my code.
    I also tried it using externalization. The User class is essentially built around a HashMap. I have the following methods:
    public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(mainMap);
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    mainMap = (Map) in.readObject();
    String test = (String) in.readObject();
    Whenever inputstream.readObject() is called, though, I get an InvalidClassException; "no valid constructor." The sad part is that I have the method:
    public User () {
    main = new HashMap();
    Does anyone know what the problem is??? Thanks a lot!

    Does anyone know what the problem is???The inner class is not a static inner class. Therefore your constructor User, is actually User(OuterClass). Solution - make the class static OR use read and/or write resolution to reconstruct the relationship.

  • Problem with Outer and Inner Classes....or better way?

    Right now I'm trying to create an Inner class.
    My .java file compiles ok, and I create my jar file too.
    But when I try to instantiate the Inner class, it fails:
    java.lang.NoClassDefFoundError: com/myco/vlXML/vlXML$vlDocument.
    Here's the class code:
    public class vlXML{
        private ArrayList myDocList=new ArrayList(); //holds documents
        public vlXML(){
        private class vlDocument{
            public vlDocument(){
            //stuff goes here
        public vlDocument vlDOC(){
            return new vlDocument();
        public void addDocument(){
            vlXML xxx=new vlXML();
            vlDocument myDoc=xxx.vlDOC();
            myDocList.add(myDoc);
        public int getNumDocs(){
            return myDocList.size();
    }Then, from a jsp page, I call:
    vlXML junk1=new vlXML();
    junk1.addDocument();...and get the error...
    Can someone help me figure out why it's failing?
    Thanks....

    You nailed it - thanks....(duh!)
    While I have your attention, if you don't mind, I have another question.
    I'm creating a Class (outer) that allows my users to write a specific XML file (according to my own schema).
    Within the XML file, they can have multiple instances of certain tags, like "Document". "Document"s can have multiple fields.
    Since I don't know how many "Documents" they may want, I was planning on using an Inner Class of "Document", and then simply letting them "add" as many as necessary (thus the original code posted here).
    Does that seem like an efficient (logical/reasonable) methodology,
    or is there there something better?
    Thanks Again...

Maybe you are looking for

  • Printing a zoomed view in Preview.app

    How do you print a zoomed in view from Preview. In Adobe there is a choice to print current view. I cant figure out how in Preview.app.

  • Horizontal scroll bar in OAF screen flexible layout

    Hi Gurus, We have developed an OAF screen using flexible layout. Currently we have two tabs showing in the same window. We are unable to increase the number of columns in the result table of the flexible layout as there is no horizontally scroll bar

  • Why does cursor changes to arrow and typing stops

    When typing or attempting to type, the cursor drops from the end of the letter and turns into an arrow, which can appear anywhere on the screen.  I then have to move the mouse to the last place I typed.  Have restarted and shut down computer several

  • Is Externalizable is a marker interface???

    hey, What is a marker interface??? it should not have any methods, isn't it???then why is that the interface externalizable called as a marker ??? can anybody tell me the reason??

  • Synchronization in Vector

    I read that the class Vector is synchronized, but does this mean that it automatically synchronizes access from different threads or is it another feature? If it is another feature, do I have do synchronize both the Vector as the elements that it con