• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Changing ClassPath

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I append to/change my ClassPath? I can't get any of my beans to work with Tomcat 4. I've copied them into every tomcat directory... just to expirement- though I knew it wouldn't help. I thought that I just had to place them in either the WEB-INF/classes or <TOMCAT_HOME>/classes directory.
I think that the problem is that when I start Tomcat it gives me this:
Using CATALINA_BASE: C:\Tomcat
Using CATALINA_HOME: C:\Tomcat
Using CLASSPATH: C:\Tomcat\bin\bootstrap.jar;C:\jdk\lib\tools.jar
Using JAVA_HOME C:\jdk
I need to add my class directory to that classpath... methinks. Am I right? If I am- How can I do that. If I'm wrong... what might be my problem?
Thank you kindly.
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
George:
When you put the bean class files in the WEB-INF/classes dir, they are automatically in the CLASSPATH. You don't have to do anything special.
Having said that, when you put bean classes in the WEB-INF/classes, the whole Java world knows that these are beans without any package stmts, right!
Now there is a sticky thing with no-package bean classes.... . When you use bean without a package stmt, the App Server will look for the bean class in the same package as that of the generated Servlet code. And we don't know what package the generated servlet code is, so generally the JSP fails.
Bottomline, put your beans in a package and then access them. Ofcourse in this case you will put the bean class files in the WEB-INF/classes/mycom/mypackage/ directory which reflects the package stmt in your bean class.
Good luck.
- satya
 
George Larry
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe if I give you all the details of my bean-creation attempt...
I created a file called testBean.java that had the bean stuff in it:
package meanBean;
public class testBean {
...
}
I saved it and ran javac testBean.java to create testBean.class
I'm running this from the example dir so I place my testBean.java/.class files in the dir:
C:\Tomcat\webapps\examples\WEB-INF\classes\test\meanBean
(I also tried placing the class file in:
C:\Tomcat\classes\test\meanBean)
From my .jsp file I try to call the bean:
<jsp:useBean id="myBean" scope="page" class="meanBean.testBean" />
But I'm getting an error:
Class meanBean.testBean not found.
Please let me know what I'm doing wrong. If you've already told me... I'm sorry, but I didn't get it- Would you mind trying again?
Thank you so much-
[ February 04, 2002: Message edited by: George Larry ]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

C:\Tomcat\webapps\examples\WEB-INF\classes\test\meanBean

Since your package stmt for the code is:
package meanBean;
Your .class file (.java is not needed) should be in the dir
C:\Tomcat\webapps\examples\WEB-INF\classes\meanBean
Let me know what happens. Right now I an not at my system so I can't try it.
Also if this doesn't work, pl. post the URL you are using to access the JSP and where you are placing the JSP.
Good luck.
- satya
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello ..
i also had the same problem that george had with placing the .class files.
i've my .class file placed in
C:\Program Files\Apache Group\Tomcat\webapps\myfirstapp\WEB-INF\classes\test\userdata.class
where test is the name of the package.
my .jsp file placed in
C:\Program Files\Apache Group\Tomcat\webapps\ROOT\harit\
From my .jsp file I tried to call the bean:
<jsp:useBean id="emp" scope="page" class="test.userdata" />
but i'm getting an error..
package test does not exist
please help me where i'm doing an error...do i need to set any CLASSPATH for running this JSP
thanks in advance
--sumana
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your JSP is in the ROOT web application, while your beans are in the "myfirstapp" web application. That won't work. Put the beans and the JSP in the same web application.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Sumana!!
put class files under Install-Dir/webapps/ROOT/WEB-INF/classes/packagename/
put jsp files under Install-Dir/webapps/ROOT/packagename/
no additional classpath settings is needed.
hope, this helps u..
sreek.
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I am having problems with storing the class file with tomcat 4.
I always get this error:
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] C:\Tomcat\work\Standalone\localhost\_\MyPackage\index_jsp.java:7: cannot resolve symbol
[javac] symbol : class Calculator
[javac] location: package MyPackage
[javac] import MyPackage.Calculator;
[javac] ^
[javac] 1 error

Why is it pointing to the location "C:\Tomcat\work\Standalone\localhost\_\MyPackage\index_jsp".

Thanks
 
We don't have time to be charming! Quick, read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic