This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with simple bean that fails only at deployment location

 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some problems deploying a simple bean project as a trial basis. The program works perfectly at my home version of Tomcat.
Here is the jsp, it is called accessbean.jsp
The actaul file is located at: /cscs/www/tomcat/webapps/w0109699/simplebeanjsp
<html>
<head>
<jsp:useBean class="simplebean.lineBean" id="bean0" scope="session" />
<title>Using JavaBeans</title>
</head>
<body>

<%= bean0.stars(20) %>
Welcome to My Web page
<%= bean0.doubleLine(30) %>

Welcome to my Web site. <br>
<%= bean0.dividers()
%>
The default number of horizontal lines that will be displayed using this JavaBea
n is:
<jsp:getProperty name="bean0" property="lineRepeat" />
<jsp:setProperty name="bean0" property="lineRepeat" value="3" />
<%= bean0.dividers()
%>
The default number of horizontal lines that will be displayed using this JavaBea
n is:
<jsp:getProperty name="bean0" property="lineRepeat" />

</body>
</html>
My bean which I have called lineBean.java is located at:
/cscs/www/tomcat/webapps/w0109699/WEB-INF/classes/simplebean
package simplebean;
public class lineBean
{
private byte lineRepeat;
public lineBean()
{
lineRepeat = 5;
}
public String stars(int x)
{
String text = "<br>";
for (int i = 0; i < x; i++ )
text = text + "*";
return text + "<br>";
}
public String doubleLine(int x)
{
String text = "<br>";
for (int i = 0; i < x; i++)
text = text + "=";
return text + "<br>";
}
public String dividers()
{
String htmlCode = "";
for (int i = 0 ; i < lineRepeat; i++)
htmlCode = htmlCode + "<hr>";
return htmlCode;
}
public byte getLineRepeat()
{
return lineRepeat;
}
public void setLineRepeat(byte x)
{
lineRepeat = x;
}
}
At remote location I access the jsp with the following address in the browser https://intranet.cscs.wmin.ac.uk/tomcat/w0109699/simplebeanjsp/accessbean.jsp
but I get these errors:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:477)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:182)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2397)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:256)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:361)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:563)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:535)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:638)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:484)

root cause
org.apache.jasper.JasperException: simplebean.lineBean
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:183)
at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:676)
at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:552)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1014)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1056)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1062)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:232)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1014)
at org.apache.jasper.compiler.Generator.generate(Generator.java:1862)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:244)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:325)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:182)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2397)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:256)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:361)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:563)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:535)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:638)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Apache Tomcat/4.1.10
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition to giving the package in the useBean tag, you have to import it.
import simplebean.* ;
Otherwise the compiler does not know where to find the class.
Bill
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As suggested by William Brogden:
>mport simplebean.* ;
<html>
<head>
<%@ page import="simplebean.lineBean %>
<jsp:useBean class="simplebean.lineBean" id="bean0" scope="session" />
<title>Using JavaBeans</title>
</head>
<body>

<%= bean0.stars(20) %>
Welcome to My Web page
<%= bean0.doubleLine(30) %>

Welcome to my Web site. <br>
<%= bean0.dividers()
%>
The default number of horizontal lines that will be displayed using this JavaBea
n is:
<jsp:getProperty name="bean0" property="lineRepeat" />
<jsp:setProperty name="bean0" property="lineRepeat" value="3" />
<%= bean0.dividers()
%>
The default number of horizontal lines that will be displayed using this JavaBea
n is:
<jsp:getProperty name="bean0" property="lineRepeat" />

</body>
</html>
I still get the error:
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
...
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:256)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:484)

root cause
org.apache.jasper.JasperException: simplebean.lineBean
at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:183)
...
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
at java.lang.Thread.run(Thread.java:484)
--------------------------------------------------------------------------------
Apache Tomcat/4.1.10
 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi maybe this is a little bit off-topic,But as William said to import the bean,
Quote :
In addition to giving the package in the useBean tag, you have to import it.
import simplebean.* ;
But I am using a bean & NOT importing it ,it still works fine.Can u tell me why ?
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think your problem may be because you have not declared your bean class as "implements Serializable".
It is a condition of the JavaBeans API that all beans be serializable, so the Jasper JSP compiler is within its rights to complain that it can't instantiate the bean if it's not.
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a bean & NOT importing it ,it still works fine.Can u tell me why ?
As with any other import, you don't need to use an explicit import statement if the class you are using is in a package and you refer to your class by its "full" name (e.g. com.efsol.elius.LiteralToken)
 
northfield Sid
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>I think your problem may be because you have not declared your bean class as "implements Serializable".
I managed to solve the porblem without needing to change the code.
As stated earlier the program worked at home. The problem was with the remote deployment web server. I am not actually sure why but the system adminstrator says it is something to do with how its tomcat was installed. This meant I needed to use adminstrative rights by first stopping the program, then restarting and then finally reload when changes takes place.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic