• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java bean usage in JSP(s)

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Java folks,

Any help is very much appreciated.

here is my problem which I dont see in the development environment but production (Apache Tomcat 6.0.29).

I am importing a java bean in home.jsp page and referring the same type bean in another jsp simply errors out like below. In fact the Movie bean has beean already accessed in the home.jsp, so its very much present in the class path, only when accessing the Bean Type second time in the same session in another JSP breaks the application.

Any ideas? BTW bean is Serializable, every thing works in the development environment, where I run the webserver through Eclipse

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 71 in the jsp file: /list.jsp
Movie cannot be resolved to a type
68:
69: }
70:
71: ResultSetHandler<List<Movie>> h = new BeanListHandler(Movie.class);
72: if (session.getAttribute(movieListName) == null){

Nagendra
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do import the movie class right? <%@ page import="com.mypackage.Movie" %>
And the movie class is in a java package?


So what is different between your dev environment and production?
The version of Tomcat?
The version of java?
The operating system?
What compiler is it using to compile the JSPs?
 
Nagendra Putti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stefan Evans wrote:You do import the movie class right? <%@ page import="com.mypackage.Movie" %>
And the movie class is in a java package?


So what is different between your dev environment and production?
The version of Tomcat?
The version of java?
The operating system?
What compiler is it using to compile the JSPs?



Thanks for the response,

The class file is imported, it has very valid package structure, I tested this application Tomcat 7, 6.0.29 and 6.0.27 (with same problem every where) assuming this is Tomcat issue, because my development is run on 6.0.27.

The same bean is very much accessible in welcome page with the same used in another Page acting as if its not present.

SYS CONFIG : Windows 2008 R2, tomcat 6.0.29. JDK 1.6.


Thanks again for your time
 
Nagendra Putti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved the problem by creating a jar file with the classes of java beans and putting the same in Common tomcat shared libs folder.
 
Stefan Evans
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nagendra Putti wrote:Solved the problem by creating a jar file with the classes of java beans and putting the same in Common tomcat shared libs folder.



I thought you said that the class was present in the classpath?
Putting stuff in the Tomcat lib folder doesn't sound like a good solution to me.

Classes should be under WEB-INF/classes (in their folder package structure of course) or bundled in jars in the WEB-INF/lib folder,

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Stefan Evans wrote:Putting stuff in the Tomcat lib folder doesn't sound like a good solution to me.


It is indeed a poor solution to the issue.
 
Nagendra Putti
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

Stefan Evans wrote:Putting stuff in the Tomcat lib folder doesn't sound like a good solution to me.


It is indeed a poor solution to the issue.




In fact, I my self not happy about the solution, but I already spent three days on finding the solution. So decided to get the work done and optimize it later.

This is what happening, welcome page in production (virtual host) has access to WEB-INF/classes/com.package.Beans, but once you are in the JSP folder and you try to access other JSP(s) from the welcome page, they can't see the same beans which are already accessed in welcome page. Since jsp are in separate jsp folder, there should be problem with bean ref path.

Web folder structure.
Web
jsp/jsp pages
Web-inf
classes

 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
WEB-INF, not Web-inf.
 
reply
    Bookmark Topic Watch Topic
  • New Topic