Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

2 Questions about Beans plus a Hello World Bean Exception

Posted on 2003-03-12
10
Medium Priority
?
293 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
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Use this step by step method when setting up QuickBooks Online. They will allow you to explore the various features of the advanced settings available to you.
The article explains the process to deploy a Self-Service password reset portal I developed a few years ago. Hopefully, it will prove useful to someone.  Any comments, bug reports etc. are welcome...
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline
Suggested Courses

581 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