You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2004/06/09 22:26:22 UTC

DO NOT REPLY [Bug 29478] New: - problem with JSPC and useBean and static initialization

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29478>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29478

problem with JSPC and useBean and static initialization

           Summary: problem with JSPC and useBean and static initialization
           Product: Tomcat 5
           Version: 5.0.25
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Jasper
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: jgrannis@fuelquest.com


We have a form bean that does some static initialization which references some
classes which only work if the system is actually running.  For some reason,
though, when jspc is processing the useBean tag referring to this bean, it tries
to instantiate the bean, which fails b/c, of course, it is not doing so in the
context of a running system, but is doing so while building.  We did not have
this problem with jasper 1, but we do in jasper 2.  Also, fyi, we have tomcat
5.0.26 (least, that's what it says on system startup) but that wasn't an option
in the version box.  Here's the tag from the jsp:

<jsp:useBean id="MaintainProductForm"
class="com.fuelquest.products.web.MaintainProductForm" scope="request"/>

here's the jspc output, including the stack trace:

jspc:
     [java] log4j:WARN No appenders could be found for logger
(org.apache.jasper.compiler.JspRuntimeContext).
     [java] log4j:WARN Please initialize the log4j system properly.
     [java] java.lang.NoClassDefFoundError
     [java]     at
com.fuelquest.relationships.AbstractRelationshipTypeProvider.getRelationshipType(AbstractRelationshipTypeProvider.java:71)
     [java]     at
com.fuelquest.products.ProductRelationshipTypes.getProductFtaRelationshipType(ProductRelationshipTypes.java:71)
     [java]     at
com.fuelquest.products.web.MaintainProductForm.<clinit>(MaintainProductForm.java:76)
     [java]     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
     [java]     at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
     [java]     at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
     [java]     at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
     [java]     at java.lang.Class.newInstance0(Class.java:308)
     [java]     at java.lang.Class.newInstance(Class.java:261)
     [java]     at
org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1212)
     [java]     at org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
     [java]     at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
     [java]     at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
     [java]     at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
     [java]     at org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
     [java]     at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
     [java]     at
org.apache.jasper.compiler.Generator.generate(Generator.java:3261)
     [java]     at
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
     [java]     at org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
     [java]     at org.apache.jasper.JspC.processFile(JspC.java:776)
     [java]     at org.apache.jasper.JspC.execute(JspC.java:905)
     [java]     at org.apache.jasper.JspC.main(JspC.java:195)
     [java] Exception in thread "main" 

     [java] Java Result: 1

We can probably code around this problem, but it does seem a bit "odd", to say
the least, that jasper would be instantiating classes and form beans in order to
generate java code....it seems like it could learn everything it needs to by
inspecting the Class without needing to actually create an instance.  I'm not
really defending the static initialization that takes place in the class, it
wasn't really my idea, but it really shouldn't matter to jasper one way or the
other.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org