Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Only a type can be imported. org.apache.commons.httpclient.HttpClient resolves to a package
Only a type can be imported. org.apache.commons.httpclient.HttpClient resolves to a package [message #183846] Thu, 07 December 2006 02:56 Go to next message
Fernando Margueirat is currently offline Fernando MargueiratFriend
Messages: 3
Registered: July 2009
Junior Member
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
Re: Only a type can be imported. org.apache.commons.httpclient.HttpClient resolves to a package [message #183944 is a reply to message #183846] Fri, 08 December 2006 13:59 Go to previous messageGo to next message
Larry Isaacs is currently offline Larry IsaacsFriend
Messages: 1354
Registered: July 2009
Senior Member
I finally found time to verify this. This occurs when you add a jar
directly to the Java Build Path instead of adding it as a J2EE Module
Dependency (via the project Properties page by the same name) or copying
the jar to the project's WEB-INF/lib. Either of these approaches
includes the jar in the webapp's WEB-INF/lib when the project is
published to a server or exported as a war file. Adding the jar
directly to the Java Build Path implies that the server will supply this
jar via something like Tomcat's "shared/lib" feature. The errors are
the result of not including the jar in the webapp, so the classes are
not present and the imports in the JSP are assumed by default to be
packages.

Cheers,
Larry

Fernando Margueirat wrote:
> 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 occu
rred 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) o
rg.apache.jasper.compiler.Compiler.compile(Compiler.java:276 ) 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
>
Re: Only a type can be imported. org.apache.commons.httpclient.HttpClient resolves to a package [message #184278 is a reply to message #183944] Sat, 09 December 2006 17:06 Go to previous message
Fernando Margueirat is currently offline Fernando MargueiratFriend
Messages: 3
Registered: July 2009
Junior Member
Thanks Larry

That nailed it.

Fernando
Previous Topic:Web project and does not work
Next Topic:The WS-I Test Assertion Document (TAD)document was either not found or could not
Goto Forum:
  


Current Time: Sat Apr 20 03:24:00 GMT 2024

Powered by FUDForum. Page generated in 0.04327 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top