?
Solved

2 Questions about Beans plus a Hello World Bean Exception

Posted on 2003-03-12
10
Medium Priority
?
290 Views
Last Modified: 2010-04-01
I'm just trying to deploy a simple HelloWorld Bean which is called by a JSP and i'm getting a ton of errors and i'm not sure why.  Just for background, i'm running JBoss and Tomcat bundle (JBoss 3.0.6 and Tomcat 4.1.18).

I have three questions,
(1) Do I have to map the bean into my web.xml file?  I'm pretty sure I have to but of all the documentation (and the book I have), there is no mention of doing this.

(2) Since JSP are not compiled like a servlet but the bean has to be compiled first, do I have to make a WAR file to deploy it?  Reason i'm asking is, again, my book doesn't say I have to do this.  It basically says, drop it into the deploy directory in JBoss and all is fine....which didn't work for me.

(2) As stated before, i'm trying to use my bean inside a jsp and i'll explain what i've done thus far.
a. Compiled the HelloWorldBean.java into a class file and put it into my BeanTest\WEB-INF\classes directory
b. Configured web.xml to find the HelloWorldBean.class I just made as follows:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
   <servlet>
       <servlet-name>HelloWorldBean</servlet-name>
       <servlet-class>HelloWorldBean</servlet-class>
   </servlet>

   <servlet-mapping>
       <servlet-name>HelloWorldBean</servlet-name>
       <url-pattern>/HelloWorldBean</url-pattern>
   </servlet-mapping>
</web-app>

c. Then I made a jsp file called HelloWorldBeanEdition.jsp as follows:
<HTML>
<HEAD>Hello World - Bean Edition</HEAD>

<BODY>
<jsp:useBean id="hello" class="helloBean.HelloWorldBean" />
<jsp:setProperty name="hello" property="name" param="name" />
Hello, <jsp:getProperty name="hello" property="name" />
</BODY>
</HTML>

d. Then I made a war file containing everything in BeanTest
e. Stuck the war file into my deploy directory and tried to access it through the browser URL: http://localhost:8080/BeanTest/HelloWorldBeanEdition.jsp

That's when I got all the following errors - which I have been trying to fix for hours:

NOTE: I have a index.html file in my war file that works fine.

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: helloBean.HelloWorldBean
      at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:183)
      at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:691)
      at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:552)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
      at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1070)
      at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1076)
      at org.apache.jasper.compiler.Node$Root.accept(Node.java:232)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
      at org.apache.jasper.compiler.Generator.generate(Generator.java:1871)
      at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:238)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      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.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      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.StandardContext.invoke(StandardContext.java:2415)
      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:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
      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.coyote.http11.Http11Processor.process(Http11Processor.java:432)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
      at java.lang.Thread.run(Thread.java:536)


root cause

java.lang.ClassNotFoundException: helloBean.HelloWorldBean
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1428)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1274)
      at org.apache.jasper.compiler.BeanRepository.getBeanType(BeanRepository.java:181)
      at org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:691)
      at org.apache.jasper.compiler.Node$GetProperty.accept(Node.java:552)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
      at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:1070)
      at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:1076)
      at org.apache.jasper.compiler.Node$Root.accept(Node.java:232)
      at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:1028)
      at org.apache.jasper.compiler.Generator.generate(Generator.java:1871)
      at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:238)
      at org.apache.jasper.compiler.Compiler.compile(Compiler.java:351)
      at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
      at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
      at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
      at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
      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.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      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.StandardContext.invoke(StandardContext.java:2415)
      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:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
      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.coyote.http11.Http11Processor.process(Http11Processor.java:432)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:386)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:534)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:530)
      at java.lang.Thread.run(Thread.java:536)

0
Comment
Question by:KABOOM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 8125095
>> Do I have to map the bean into my web.xml file?
no!

>> do I have to make a WAR file to deploy it?
you don't have to

>> a. Compiled the HelloWorldBean.java into a class file and put it into my BeanTest\WEB-INF\classes directory
make sure you use package for your bean, for example, make this line the every first line of your HelloWorldBean.java:
package helloBean;

IMPORTANT: then compile and put class file at BeanTest\WEB-INF\classes\helloBean\HelloWorldBean.class

>> b. Configured web.xml to find the HelloWorldBean.class I just made as follows:
remove all these, only servlet need mapping in web.xml, not beans, those lines in web.xml can cause context failed to load.

restart server and try again.
0
 

Author Comment

by:KABOOM
ID: 8126027
Ok, I got rid of my web.xml file.  I also imported my bean in my jsp but now I get a MAPPING configuration error and i'm not sure why.

Below is my HelloWorldBeanEdition.jsp:

<%@ page import="helloBean.*" %>
<HTML>
<HEAD>Hello World - Bean Edition</HEAD>
<BODY>
<jsp:useBean id="hello"
class="helloBean.HelloWorldBean" />
<jsp:setProperty name="hello" property="name" param="name" />
Hello, <jsp:getProperty name="hello" property="name" />
</BODY>
</HTML>

This jsp resides in:
C:\jboss-3.0.6_tomcat-4.1.18\server\default\deploy\BeanTest

and I put my class file where you said (in the classes directory inside BeanTest).

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8130052
hmmm, can you double check on these?
1. your web.xml should looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
  PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
  "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
</web-app>

2. make sure this is the first line of HelloWorldBean.java:
package helloBean;

3. make sure your class file is under BeanTest\WEB-INF\classes\helloBean, notice that this is helloBean subdir under classes.

4. remember to restart server.

post the stack trace if you still have problem, thanks.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:KABOOM
ID: 8133145
Hi Kennethxu.  Thanks for the help and it still didn't work.  Again, i'm still getting the mapping configuration error and can't even access the index.html file in the deploy/BeanTest directory.  Here's the exact error from JBoss as follows:
MAPPING configuration error for request URI /BeanTest/HelloWorldBeanEdition.jsp

I'll post all of my files and directory structure:
First my directory structure in deploy directory

Deploy
|-BeanTest
|--WEB-INF
|----classes
|--------helloBean
|---------------HelloWorldBean.class
|---------------HelloWorldBean.java
|----lib
|----web.xml
|--HelloWorldBeanEdition.jsp
|--index.html


WEB.XML FILE
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
   PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
   "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>


</web-app>


HELLOWORLDBEAN.JAVA
package helloBean;

public class HelloWorldBean implements java.io.Serializable
{  String name;
     
   public HelloWorldBean()
   {  this.name = "World"; }

   public String getName()
   {  return this.name; }

   public void setName(String name)
   {  this.name = name; }
}


HELLOWORLDBEANEDITION.JSP

<HTML>
<HEAD>Hello World - Bean Edition</HEAD>

<BODY>
<jsp:useBean id="hello" class="helloBean.HelloWorldBean" />
<jsp:setProperty name="hello" property="name" param="name" />
Hello, <jsp:getProperty name="hello" property="name" />
</BODY>
</HTML>
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 200 total points
ID: 8133632
rename your BeanTest dir to BeanTest.war :-)
0
 

Author Comment

by:KABOOM
ID: 8133684
Wow!  That worked! I have to admit, i'm a little puzzled why that worked and all of the books i've read - didn't say to do that.  Is that a JBoss specific implementation or did I just miss reading it?

0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8133714
that's jboss specific, jboss's deployment scaner look for *.war, be it a dir or a war file.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8133724
this is because, tomcat only handles webapp, but jboss need to handle webapp, j2ee app and etc. so jboss uses extension to differentiate.
0
 

Author Comment

by:KABOOM
ID: 8134025
Your a life saver.

Thanks again.
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 8136740
my pleasure to help :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
What's worse than having your data encrypted by ransomware? Getting attacked by a so-called "wiper," which simply destroys the data and offers you no hope of ever seeing it again.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question