[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5280
  • Last Modified:

Only a type can be imported. MyClass.anyclass resolves to a package error

I have an app that uses JSP's, java libraries (API) with Tomcat and MySQL. The app works fine, however, since I migrate to a new server, I start getting this error.

"Only a type can be imported. MyClass.anyclass resolves to a package error"

The funny thing here is that JSP's that are located in the root directory (public_html) works fine, while all the other JSP's throw this exception:

If I move any JSP from "public_html/any_directory" to "public_html", then that very same JSP works fine.

The java libraries are located in a jar file, in WEB-INF/lib, and it's classpath is perfectly written.

As you may know, Tomcat compiles JSP's the first time they're executed, so I checked the code generated for both JSP's (public_html/my_jsp.jsp and public_html/someFolder/my_jsp.jsp), and they are exactly the same, however, only the one located in public_html works.

Evidently, there is a problem with tomcat's classpath, but I've been trying to fix this for many days, and still having the problem.

Altough, I know there's nothing wrong with the code of the JSP's, here it is, in case that helps. I'm sure that this error is caused by some Tomcat's configuration, however, I haven't been able to find it.

<%@ page import="Solutio.AdminRH.Entity.ICatalogosAdminDB" %>
<%!

private ICatalogosAdminDB theObj = null;
public void jspInit() {
try {
theObj = new ICatalogosAdminDB();
} catch (Exception ex) {
System.out.println(ex);
}
}

public void jspDestroy() {
theObj = null;
}
%>
<html>
...
...

Any help will be really appreciated.

Thank you.
0
sergiomn
Asked:
sergiomn
  • 3
  • 2
1 Solution
 
objectsCommented:
where are you importing MyClass.anyclass?

0
 
objectsCommented:
be worth clearing tomcats work directory and restart tomcat

0
 
sergiomnAuthor Commented:
at the begining of any JSP, in the code I paste, is the first line:

<%@ page import="Solutio.AdminRH.Entity.ICatalogosAdminDB" %>

I said "MyClass.anyclass" because it happens with any class, and any jsp of the app (except for those located in public_html, as mentioned.

However, In this specific case, the error says:

"Only a type can be imported. Solutio.AdminRH.Entity.IPruebaAdminDB resolves to a package"

And yes, I've tried cleaning the work directory.

Thank you, any help will be really appreciated.
0
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!

 
objectsCommented:
any other apps running on that instance of tomcat?
Anything unusual in the logs when the context starts up?

0
 
KuldeepchaturvediCommented:
http://forums.sun.com/thread.jspa?threadID=5368651&tstart=0

is it the same problem ( & are you the same person as above post? evidently it states that it was fixed)
0
 
sergiomnAuthor Commented:
Yes, it's the same, and somebody there helped me, so now it's fixed.

thanks
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now