- This topic has 27 replies, 5 voices, and was last updated 21 years, 3 months ago by
No Operation.
-
AuthorPosts
-
skkunkkMemberMy environment
Eclipse 2.1.2
MyEclipse 2.6.4
No additional eclipse plugins
Windows 2000My issue
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 “cannot load class: com.ispek.action.welcome.WelcomePageComponent.ViewBean”
I tried changing the class string to “com.ispek.action.welcome.WelcomePageComponent$ViewBean”
but this produced the error
“the type com.ispek.action.welcome.WelcomePageComponent$ViewBean is an incorrectly specified nested type; replace the ‘$’ with a ‘.'”I have checked my /WEB-INF/classes directory and the WelcomePageComponent.class and WelcomePageComponent$ViewBean.class files exist.
The structure of nesting the view bean within the component is a common structure being used on this project and in each case the jsp:usebean is causing an error.
Is there something I am missing in my use of jsp:usebean?
Cheers,
Peter
Riyad KallaMemberI hate to ask, but did you try the useBean with the period instead of the $?
skkunkkMemberYes, that is the problem.
>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 “cannot load class: >com.ispek.action.welcome.WelcomePageComponent.ViewBean”
Riyad KallaMemberWoops, sorry I’m learning how to read as we go here 🙂
Scott can probably help you better, I really don’t know. As long as the class is public/static you SHOULD be able to see and use it. I’m also not clear if this is a MyEclipse compiler error if you really can’t use this page in your web application server.
skkunkkMemberI can use the page in Weblogic 8. It is from an existing project. I am evaluating MyEclipse to see if it can speed up our development. I have found it a useful addition to eclipse. The problem is that a good majority of our jsp ‘s are showing up in the package explorer decorated with a red compile error flag because this problem.
Has anyone successfully used inner classes in this way with MyEclipse.
Scott AndersonParticipantGood diagnosing guys. I tested this out and have to quantify it as a bug, right now. I’ve entered it into our internal tracking system so we can address it in the next service release. Sorry for the inconvenience.
–Scott
MyEclipse Support
skkunkkMemberThanks for the quick response.
Scott AndersonParticipantNo problem. In all honesty, although I admit we need to support usage of nested classes (since it’s in the spec), I’m curious as to the advantage of using them versus standard classes. Can you tell me why you chose to go this route with your application and what advantage it provides? Just interested.
–Scott
MyEclipse Support
Scott AndersonParticipantGood news on this one. The fix was snuck into the final build of 2.7 so it should be available later today. How’s that for bugfix turnaround?
–Scott
MyEclipse Support
Riyad KallaMemberDamn! This is one of the coolest parts of being so close to the development company.
Scott AndersonParticipantSkkunkk,
Well, 2.7 RC1 is out and should fix this. Please let us know if it addresses the problem you experienced.
–Scott
MyEclipse Support
skkunkkMember@scott wrote:
No problem. In all honesty, although I admit we need to support usage of nested classes (since it’s in the spec), I’m curious as to the advantage of using them versus standard classes. Can you tell me why you chose to go this route with your application and what advantage it provides? Just interested.
–Scott
MyEclipse SupportWe are using the Struts framework for our application and the decision was made early to wrap our components (forms and actions) into one class to avoid a proliferation of directories. A component will typically consist of around 4 actions (display, save and any other functions) and a form. As the project is now in its fourth year as a web app and has around 500 pages we have found it to be a convenient packaging structure.
Thanks once againg for getting this change into the release, it is working fine. We do however have an issue with Weblogic as they have implemented nested class loading in jsp’s in a rather lazy way. They require the useBean tag class attribute to be specified as OuterClassName$NestedClassName
As far as I can see from section 8.5 of the java spec the correct way to refer to such a class is OuterClassName.NestedClassName ( “If a member class or interface declared with simple name C is directly enclosed within the declaration of a class with fully qualified name N, then the member class or interface has the fully qualified name N.C. ” )
So I guess is it up to MyEclipse to decide if it wants to support pages written to be deployed on Weblogic (not sure how it works in other application servers).
Thanks,
Peter
support-michaelKeymasterWe are very senstive about compromising specs since it leads to the type of problem you have encountered. I’m pitching your delimma to my management team to determine if they are willing to support this WLS non-spec syntax.
Michael
MyEclipse Support
skkunkkMemberI raised out issue with bea and received the following response. They make the valid point that their class loader is working like suns.
behavior as you have described. Then, I searched our resource database and found out that there were a couple of issue already reported for this
I have tested the application you sent and I saw the same issue. After going through the issue notes, I found out that BEA recommends that users always use the $ sign with inner classes and not the . sign. This is what our jsp developer has to say about this issue :
—————————————————————————————————————————————————————————————————-
“So we must recommend to customers to always use ‘$’ for an inner class within jsp:useBean and internally change the $ to a . for generating types. e.g
given foo.Bar$Inner
generated code should look like
foo.Bar.Inner test = (foo.Bar.Inner) Beans.instantiate(classloader,”foo.Bar$Inner”);
The fix would be simple and would have to be made in JspLexer i think.
(Aside: even sun’s urlclassloader doesnt support ‘.’ notation for classloading i.e class.forName(“foo.Bar.Inner”) in the above case will give you a ClassNotFoundException)”
—————————————————————————————————————————————————————————————————-In another case, one person raised a question as to why the javap command allows “.” with innerclass while the jsp container does not. According to the developer :
—————————————————————————————————————————————————————————————————-
“This is due to a variation in the way javap and java class loaders search for class files. I don’t know why this variation exists, but the difference is lower level than WLS. We could probably modify our class finders to use a similar algorithm as javap, but I don’t think we should because then we would have different behavior depending on whether the class was in the webapp or the system classpath. Since the system classes are still loaded with a java classloader, we don’t have control over the search algorithm.”
—————————————————————————————————————————————————————————————————-Thus, it seems that WebLogic will only support $ and not . with nested classes.
No OperationMemberRegarding foo.Bar.Inner and foo.Bar$Inner, to generate the code below, the “jsp devloper” has to replace either ‘$’ with ‘.’ or ‘.’ with ‘$’:
foo.Bar.Inner test = (foo.Bar.Inner) Beans.instantiate(classloader,”foo.Bar$Inner”);
Maybe replacing ‘$’ with ‘.’ seems to be easier, but dont forget that you may name a stand-alone class foo.Bar$No$Inner:
package foo; public class Bar$No$Inner // legal!!! { ... }
so replacing ‘$’ with ‘.’ requires additional programming too.
From the view of a Java programmer, where you have to use the ‘.’ in your Java code to access inner classes, it is clear that there is no demand to learn exotic exceptions for each product.
You want a standard behaviour!So dear “BEA jsp developer”, do your job – thank you.
NOP
-
AuthorPosts