facebook

JSP nested class validation error (in MyEclipse v3.8)

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #226453 Reply

    My eclipse config:
    Eclipse Platform
    Version: 3.1.0
    Build id: I20050219-1500

    MyEclipse:
    Version: 3.8+QF2-BetaFor3.1
    BuildId: 200502031200-3.8.4+QF2-BetaFor3.1

    This problem relates to an earlier post:
    http://www.myeclipseide.com/modules.php?op=modload&name=PNphpBB2&file=viewtopic&t=1081

    The problem:
    MyEclipse JSP validation no longer allows references to nested classes in jsp:useBean tags, eg:

    I have a java class com.ispek.action.welcome.WelcomePageComponent with a static nested inner class named ViewBean. In my jsp page I have the following line:

    <jsp:useBean id="welcome" scope="session" class="com.ispek.action.welcome.WelcomePageComponent$ViewBean"/>
    

    This produces the error:

    The nested type com.ispek.action.welcome.WelcomePageComponent$ViewBean cannot be referenced using its binary name

    If I change the class string to:

    com.ispek.action.welcome.WelcomePageComponent.ViewBean

    JSP compilation succeeds but Weblogic Server fails to compile the JSP.

    We have been operating for some time now using the first notation (..WelcomePageComponent$ViewBean) which works fine with Weblogic Server 7.x and 8.x, and with MyEclipse for eclipse v3.0x

    Does anyone know of a way around this problem? Is there an option in MyEclipse preferences to allow nested class references in this format?

    Any help appreciated.

    Cheers,
    Theo.

    #226498 Reply

    Riyad Kalla
    Member

    I am researching this…

    #226510 Reply

    Riyad Kalla
    Member

    Theo,
    I just got this back from one of our developers:

    WebLogic’s JSP compiler is not conforming to the spec
    (ftp://ftp.javasoft.com/docs/specs/langspec-2.0.pdf). Although the compiled
    name of an inner class is Outer$Inner, the only valid way to reference it in
    Java source code, according to the spec (see syntax section), is
    Outer.Inner.

    While we realize this is not what you wanted to hear, there isn’t much we can do to offer ‘breaking’ this in the editor so WebLogic is happy. I can’t think of a nice workaround off the top of my head, but I will keep researching this issue to see if there is one available.

    #227745 Reply

    Scott hunter
    Member

    It appears that JRun 4.0 behaves the same way. Using “.” separation for inner class as a bean throws a ClassNotFoundException, and only “$” will work.

    Just in case someone else encounters this problem.

    #228036 Reply

    thanks rkalla,
    I think problem relates to the distinction between the two supported formats, eg:

      ForNameTest$MyInner, and
      ForNameTest.MyInner

    This issue is discussed in:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4378381, and
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4628117
    The resolution is that the fully qualified name contains only “.”, but String literal references must contain “$” for inner class references.

    Given the useBean tag class property is a String literal it seems reasonable that “$” notation should at least be supported.

    The following code demonstrates what the Sun JDK supports at runtime:

    
    /**
     * Demonstrate use of "ForNameTest$MyInner" vs "ForNameTest.MyInner". 
     */
    public class ForNameTest
    {
        public static class MyInner    {  }
        /**
         * @param args
         * @throws Exception
         */
        public static void main(String[] args)
        {
            System.out.println("Sun JDK version: " + System.getProperty("java.version"));
            loadClass("ForNameTest");
            loadClass("ForNameTest$MyInner");
            loadClass("ForNameTest.MyInner"); // doesn't work
            System.out.println("Found class: " + ForNameTest.MyInner.class.getName());
        }
        public static void loadClass(String className)
        {
            try
            {
                Class loadedClass = Class.forName(className);
                System.out.println("Loaded class: " + loadedClass.getName() + " (using: " + className + ")");
            }
            catch (Exception e)
            {
                System.out.println(e);
            }
        }
    }

    Output
    Sun JDK version: 1.4.2_05
    Loaded class: ForNameTest (using: ForNameTest)
    Loaded class: ForNameTest$MyInner (using: ForNameTest$MyInner)
    java.lang.ClassNotFoundException: ForNameTest.MyInner
    Found class: ForNameTest$MyInner

    We first came across this issue prior to purchasing MyEclipse licences because we were unable to take advantage of JSP syntax highlighting (the main reason for our purchase) without support for “Outer$Inner” style useBean references.
    Thankfully the problem was fixed for us in MyEclipse v2.6.4 (for Eclipse v3.0). Here are a couple of postings from support-scott on this issue:

    Posted: Dec 19, 2003 – 04:12 PM
    While NOP is technically correct, and obviously has read both the JLS and the JSP specs, interpreting the $ as he noted would be perfectly acceptable, provided the user loosened up the proposed compliance setting. It makes perfect sense. If they choose to compile with full compliance, then the offending line will be marked as an error as the spec states. But the user still gets to choose, and if he chooses to loosen spec compliance he also looses the ability to create top level classes with $ in there name. Of course, I’ve never seen anyone actually do this, since only those of us who’ve really read the specs would even know you could. 😉

    –Scott
    MyEclipse Support

    and

    Post Posted: Dec 22, 2003 – 07:46 AM
    Reply with quote Back to top
    It seems from all the input will actually satisfy everyone. NOP can leave the validator in a fully compliant configuration so that he won’t have problems with generated code, and the BEA users can “soften it” a bit so that MyEclipse will accept the BEA-specific non-compliant format.

    –Scott
    MyEclipse Support

    Could you please provide a similar fix for MyEclipse version 3.8.4 (for Eclipse 3.1)?

    thanks,
    theo.

    #228094 Reply

    Riyad Kalla
    Member

    Theo, excellent post I just got this back from one of our devs that handles editor issues:

    Please thank Theo for his research and cogent, well-articulated post. He is
    correct and the syntax he’s using should be supported.

    So we thank you and will take care of this (but it will most likely be after 4.0, when I bring up the idea of doing more for 4.0 our developers go into spasms).

    #228237 Reply

    Riyad, if there’s any chance of getting this change included earlier it would be greatly appreciated.
    We are unable to move from MyEclipse v2.6.4 due to this issue.

    Alternatively is there any chance you could issue a separate patch? August seems a long way off…

    thanks,
    theo.

    #228238 Reply

    Riyad Kalla
    Member

    Theo,
    I will certainly see if I can bump it, and if not in 4.0, hopefully in 4.0.1 or the followup patch.

    #243497 Reply

    rkalla, could you please give me an update on the status of this fix?

    Please let me know if this has been addressed and if so in which release?

    thanks,
    theo

    #248088 Reply

    rkalla, could you please give me an update on the status of this fix?

    Please let me know if this has been addressed and if so in which release?

    thanks,
    theo

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: JSP nested class validation error (in MyEclipse v3.8)

You must be logged in to post in the forum log in