• 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

Class not found errors for JSPs in sub-directories

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

Main-Issue:
- I have some java-class files in the \<my-web-app>\web-inf\classes directory. These classes do not belong to any packages.
- I have some jsps in the \<my-web-app>\ directory and also in some sub-directories in the \<my-web-app>\ directory. Example: \<my-web-app>\test\index1.jsp.
- The jsps in the \<my-web-app>\ can invoke the classes in the \<my-web-app>\web-inf\classes directory with no issues. But, the jsps in the sub-directories CANNOT see the classes in the \<my-web-app>\web-inf\classes directory. I get a "class not found" error. (this is just in oc4j).

First of all, just a background to the issue:
- I am trying to port a web application from JRUN to OC4J.
- I want to do this with minimal changes to the existing code.
- The application has been running on JRUN for a while. I only see the above mentioned error (class not found) error when trying to run it on oc4j.
- As a test, I created my own test application to verify:
(-) I wrote a simple java class (test.class) with no package and placed it in the web-inf\classes directory
(-) I wrote a jsp file (index.jsp) to invoke test.class. I placed the jsp at the top-level directory of the web-app.
(-) I wrote another jsp file (index1.jsp) to invoke test.class as well. I placed that jsp file in a sub-directory in the top-level directory of the web-app.
(-) index.jsp worked without any problems. index1.jsp gave the "class not found" error.

(-) As another test, I then modified the class to be in a package (com.benny). I then changed the jsps to call "com.benny.test" rather than just "test". This time, both index.jsp and index1.jsp worked fine.

So, I guess my question is, do these classes have to be in a package? I am trying to avoid having to make a lot of changes to the app. If they do have to be in packages, then I have re-compile a lot of class files, add import statements to jsps, etc.

Any help/suggestion would be appreciated.

Thanks,
Benny
 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you paste a little bit of the code so we can see what it's looks like?

i would think you should be able to access them through the jsp import directive.

www.binaryfrost.com
 
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

I have some java-class files in the \<my-web-app>\web-inf\classes directory. These classes do not belong to any packages.



That's a non-starter before even getting to anything else. All classes referenced must be in a package other than the default.

And, you do know it's WEB-INF, not web-inf, right? When posting, please try to be accurate to these kinds of details.
[ November 28, 2005: Message edited by: Bear Bibeault ]
 
Benny Andrews
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello:

The example j2ee application that I created to test is really simple.

Here is my directory structure:
\benny_test\web-inf\classes\test.class
\benny_test\web-inf\web.xml
\benny_test\index.jsp
\benny_test\test\index1.jsp

***************************************************************************

Here is the contents of the test.class file:
public class test
{
private String t = null;

public test(String t1)
{
setTest(t1);
}

public void setTest(String t1)
{
t = t1;
}

public String getTest()
{
return t;
}
}

***************************************************************************

Here is the contents of the index.jsp file:
<b> hello </b> <br />

<%
String test_str = null;
test ts = new test("Hello from the main jsp directory");
test_str = ts.getTest();
%>

<b> test_str is: </b> <%=test_str%>

<br /><br />

Click <a href="test/index1.jsp"> here </a> to test your jsp index1.jsp file in the test sub-directory

***************************************************************************

And, here is the contents of the test/index1.jsp file:

<b> hello from test sub-directory </b> <br />

<%
String test_str = null;
test ts = new test("Hello from the jsp test sub-directory");
test_str = ts.getTest();
%>

<b> test_str is: </b> <%=test_str%>
***************************************************************************

As you can see there are no import statements for test.class in the jsp pages.

index.jsp works fine.
test/index1.jsp gives me the following error:

Request URI:/benny_test/test/index1.jsp Exception: OracleJSP racle.jsp.provider.JspCompileException: Errors compiling:C:\OC4J\j2ee\home\application-deployments\default\benny_test\persistence\_pages\_test\_index1.java

[jsp src:line #:5] cannot resolve symbol symbol : class test location: class _test._index1 test ts = new test("Hello from the jsp test sub-directory");

[jsp src:line #:5] cannot resolve symbol symbol : class test location: class _test._index1 test ts = new test("Hello from the jsp test sub-directory");
 
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
You can move your classes into packages, or you can continue to have problems. Your choice.
 
Benny Andrews
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Bear:

Yes, sorry it is WEB-INF, not web-inf. I have it as WEB-INF.

Also, the application is working fine on JRUN. The classes can be seen even though they are not in packages and even though import statements are missing in the jsp files.

I get the "class not found" error when I try to run the application on OC4J.

I created a small j2ee application just for testing. I am seeing that the jsp's that are within sub-directories are not able to see the classes in the web-inf\classes directory, if the classes are not in packages and there are no import statements for those classes in the jsps. But the jsps that are at the top-level directory of the web-app are able to see those classes.

So, I'm wondering why the jsps in the top-level directory can see the classes, but the jsps in the sub-directories cannot.

Thanks,
Benny
 
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

So, I'm wondering why the jsps in the top-level directory can see the classes, but the jsps in the sub-directories cannot.



A fluke most likely. If you were to run the app in Tomcat, I'm willing to bet they'd all error.

If you want the app to work reliably, all the classes must be in non-default packages. This is a limitation of the JRE 1.4+ and class-loaders.
[ November 28, 2005: Message edited by: Bear Bibeault ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic