tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Funk <funk...@joedog.org>
Subject Re: precompilation trouble
Date Mon, 17 Jan 2005 15:44:11 GMT
Ahh. Here is your issue:

if (beanName == null) {
     try {
         Class bean = ctxt.getClassLoader().loadClass(klass);
         int modifiers = bean.getModifiers();
         if (!Modifier.isPublic(modifiers) ||
             Modifier.isInterface(modifiers) ||
             Modifier.isAbstract(modifiers)) {
             throw new Exception("Invalid bean class modifier");
         }
         // Check that there is a 0 arg constructor
         bean.getConstructor(new Class[] {});
         generateNew = true;
     } catch (Exception e) {
         // Cannot instantiate the specified class
         if (ctxt.getOptions().getErrorOnUseBeanInvalidClassAttribute()) {
             err.jspError(n, "jsp.error.invalid.bean", klass);
         }
     }
}

At compile time - jasper is checking that the default constructor of a bean 
may be invoked. By invoking the constructor at compile time - the class is 
loaded by the JVM. This will in turn cause the JVM to call any static 
initializers. (In which you have)


-Tim


Marcus Beyer wrote:

> Tim Funk schrieb:
> 
>> There here, but your 1st post was a on a Friday afternoon. And the 
>> errors were not very clear. Stack traces and a better description is 
>> probably in order.
> 
> 
> I see :-)
> 
> === description ===
> 
> I am using the ant script I found on page
> <http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jasper-howto.html>. The 
> relevant software I use is Tomcat 5.0.26 (the one that comes with JBoss 
> 3.2.5) and JSF 1.1_01 reference implementation (the latest release).
> 
> BTW: Is there a way to let Tomcat do the job of JSP compilation on 
> deployment? I mean without the need of visiting each page manually?
> 
> === stack trace ===
> 
>   [jasper2] SCHWERWIEGEND: java.lang.NullPointerException
>   [jasper2] java.lang.RuntimeException: java.lang.NullPointerException
>   [jasper2] at MyHelper.getManagedBean(ManagedBeanHelper.java:43)
>   [jasper2] at MyBean.loadValues(DomainListBean.java:93)
>   [jasper2] at MyBean.<init>(DomainListBean.java:47)
>   [jasper2] at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>   [jasper2] at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

> 
>   [jasper2] at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

> 
>   [jasper2] at 
> java.lang.reflect.Constructor.newInstance(Constructor.java:274)
>   [jasper2] at java.lang.Class.newInstance0(Class.java:308)
>   [jasper2] at java.lang.Class.newInstance(Class.java:261)
>   [jasper2] at 
> org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1212) 
> 
>   [jasper2] at 
> org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1116)
>   [jasper2] at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
>   [jasper2] at 
> org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213)
>   [jasper2] at 
> org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219)
>   [jasper2] at org.apache.jasper.compiler.Node$Root.accept(Node.java:456)
>   [jasper2] at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163)
>   [jasper2] at 
> org.apache.jasper.compiler.Generator.generate(Generator.java:3261)
>   [jasper2] at 
> org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
>   [jasper2] at 
> org.apache.jasper.compiler.Compiler.compile(Compiler.java:470)
>   [jasper2] at org.apache.jasper.JspC.processFile(JspC.java:776)
>   [jasper2] at org.apache.jasper.JspC.execute(JspC.java:905)
>   [jasper2] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   [jasper2] at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
> 
>   [jasper2] at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

> 
>   [jasper2] at java.lang.reflect.Method.invoke(Method.java:324)
>   [jasper2] at 
> org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:124)
>   [jasper2] at 
> org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
>   [jasper2] at org.apache.tools.ant.Task.perform(Task.java:364)
>   [jasper2] at org.apache.tools.ant.Target.execute(Target.java:301)
>   [jasper2] at org.apache.tools.ant.Target.performTasks(Target.java:328)
>   [jasper2] at 
> org.apache.tools.ant.Project.executeTarget(Project.java:1215)
>   [jasper2] at 
> org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.run(InternalAntRunner.java:379)

> 
>   [jasper2] at 
> org.eclipse.ant.internal.ui.antsupport.InternalAntRunner.main(InternalAntRunner.java:135)

> 
>   [jasper2] Caused by: java.lang.NullPointerException
>   [jasper2] at MyHelper.getManagedBean(ManagedBeanHelper.java:36)
>   [jasper2] ... 32 more
> 
> thanx!
> Marcus
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 

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


Mime
View raw message