Only a type can be imported. org.apache.commons.httpclient.HttpClient resolves to a package [message #183846] |
Wed, 06 December 2006 21:56  |
Eclipse User |
|
|
|
I am writing a JSP page that connects to another web server to extract some
information to be shown on the page. I'm using apache common's httpclient.
This is a sample of the code:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page
import=" org.apache.commons.httpclient.params.HttpConnectionManagerPa rams "%>
<%@page import="org.apache.commons.httpclient.SimpleHttpConnectionManager "%>
<%@page import="org.apache.commons.httpclient.HttpClient"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
System.setProperty("org.apache.commons.logging.Log",
"org.apache.commons.logging.impl.SimpleLog");
System.setProperty(" org.apache.commons.logging.simplelog.log.org.apache.commons. httpclient ",
"fatal");
HttpConnectionManagerParams hcmpParams = new
HttpConnectionManagerParams();
hcmpParams.setSoTimeout(3000);
SimpleHttpConnectionManager shcmConnManager = new
SimpleHttpConnectionManager();
shcmConnManager.setParams(hcmpParams);
HttpClient hClient = new HttpClient(shcmConnManager);
%>
</body>
</html>
In WTP I can create the JSP without problems or errors, but when I try to
run in an Apache 5.5 server inside WTP I get
org.apache.jasper.JasperException: Unable to compile class for JSP
Generated servlet error:
Only a type can be imported.
org.apache.commons.httpclient.params.HttpConnectionManagerPa rams resolves to
a package
Generated servlet error:
Only a type can be imported.
org.apache.commons.httpclient.SimpleHttpConnectionManager resolves to a
package
Generated servlet error:
Only a type can be imported. org.apache.commons.httpclient.HttpClient
resolves to a package
An error occurred at line: 12 in the jsp file: /account/login2.jsp
Generated servlet error:
HttpConnectionManagerParams cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /account/login2.jsp
Generated servlet error:
HttpConnectionManagerParams cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /account/login2.jsp
Generated servlet error:
SimpleHttpConnectionManager cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /account/login2.jsp
Generated servlet error:
SimpleHttpConnectionManager cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /account/login2.jsp
Generated servlet error:
HttpClient cannot be resolved to a type
An error occurred at line: 12 in the jsp file: /account/login2.jsp
Generated servlet error:
HttpClient cannot be resolved to a type
org.apache.jasper.servlet.JspServletWrapper.handleJspExcepti on(JspServletWrapper.java:512) org.apache.jasper.servlet.JspServletWrapper.service(JspServl etWrapper.java:377) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServl et.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java :264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) root causeorg.apache.jasper.JasperException: Unable to compile class for JSPGenerated servlet error:Only a type can be imported.org.apache.commons.httpclient.params.HttpConnection ManagerParams resolves toa packageGenerated servlet error:Only a type can be imported.org.apache.commons.httpclient.SimpleHttpConnectionM anager resolves to apackageGenerated servlet error:Only a type can be imported. org.apache.commons.httpclient.HttpClientresolves to a packageAn error occurred at line: 12 in the jsp file: /account/login2.jspGenerated servlet error:HttpConnectionManagerParams cannot be resolved to a typeAn error occurred at line: 12 in the jsp file: /account/login2.jspGenerated servlet error:HttpConnectionManagerParams cannot be resolved to a typeAn error occurred at line: 12 in the jsp file: /account/login2.jspGenerated servlet error:SimpleHttpConnectionManager cannot be resolved to a typeAn error occurred at line: 12 in the jsp file: /account/login2.jspGenerated servlet error:SimpleHttpConnectionManager cannot be resolved to a typeAn error occurred at line: 12 in the jsp file: /account/login2.jspGenerated servlet error:HttpClient cannot be resolved to a typeAn error occurred at line: 12 in the jsp file: /account/login2.jspGenerated servlet error:HttpClient cannot be resolved to a type org.apache.jasper.compiler.DefaultErrorHandler.javacError(De faultErrorHandler.java:84) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorD ispatcher.java:328) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTComp iler.java:414) org.apache.jasper.compiler.Compiler.compile(Compiler.java:29 7) org.apache.jasper.compiler.Compiler.compile(Compiler.java:27 6) org.apache.jasper.compiler.Compiler.compile(Compiler.java:26 4) org.apache.jasper.JspCompilationContext.compile(JspCompilati onContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServl etWrapper.java:305) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServl et.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java :264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) note The full stack trace of the root cause is available in the ApacheTomcat/5.5.20 logs.The JAR was added to the project's Java Build Path. As a test I created aJava application in the same project that uses the same classes and it worksfine. I think I need to add it to the server project too but I'm not surehow. I tried adding the jar file to web.xml as<servlet><servlet-name>jsp</servlet-name><servlet-class >org.apache.jasper.servlet.JspServlet</servlet-class><init-param ><param-name>fork</param-name><param-value>false</param-value ></init-param><init-param><param-name>xpoweredBy</param-name ><param-value>false</param-value></init-param><init-param ><param-name>classpath</param-name><param-value> c:/JavaResources/commons-httpclient-3.0.1/commons-httpclient -3.0.1.jar </param-value></init-param><load-on-startup>3</load-on-startup ></servlet>but it didn't work. Does anyone knows what am I missing or doing wrong?ThanksFernando
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06026 seconds