The import org.apache cannot be resolved

One Star frb
One Star

The import org.apache cannot be resolved

Hi all,
I've created a custom Talend component, which at certain step connects to an external Http service. For that, I'm using
org.apache.commons.httpclient

through javajet imports. I've seen the modules already exist in the Modules view. Nevertheless, when running a job the console outputs:
Execution failed : Failed to generate code.


This is my begin code:
<%@ jet 
   imports="
       org.talend.core.model.process.INode
       org.talend.core.model.process.ElementParameterParser
       org.talend.core.model.metadata.IMetadataTable
       org.talend.core.model.metadata.IMetadataColumn
       org.talend.core.model.process.IConnection
       org.talend.core.model.process.IConnectionCategory
       org.talend.designer.codegen.config.CodeGeneratorArgument
       org.talend.core.model.metadata.types.JavaTypesManager
       org.talend.core.model.metadata.types.JavaType
       java.util.List
       java.util.Map
       org.apache.commons.httpclient.*
       org.apache.commons.httpclient.methods.*
       org.apache.commons.httpclient.params.HttpMethodParams
   "
%>
<%
   // Get the CID
   CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
   INode node = (INode)codeGenArgument.getArgument();
   String cid = node.getUniqueName();
   // Get the component parameters
   String orionEndpoint = ElementParameterParser.getValue(node, "__ORION_ENDPOINT__");
   String authEndpoint = ElementParameterParser.getValue(node, "__AUTH_ENDPOINT__");
   String authUsername = ElementParameterParser.getValue(node, "__AUTH_USERNAME__");
   String authPassword = ElementParameterParser.getValue(node, "__AUTH_PASSWORD__");
   String entityIdField = ElementParameterParser.getValue(node, "__ENTITY_ID_FIELD__");
   String entityTypeField = ElementParameterParser.getValue(node, "__ENTITY_TYPE_FIELD__");
   String defaultEntityType = ElementParameterParser.getValue(node, "__DEFAULT_ENTITY_TYPE__");
   String ignoredFilds = ElementParameterParser.getValue(node, "__IGNORED_FIELDS__");
%>
   System.out.println("I am the begin section");
   HttpClient client = new HttpClient();
   PostMethod method = new PostMethod(<%=authEndpoint%>);
   method.setRequestHeader(new Header("Content-Type", "application/json"));
   method.setRequestBody("{\"username\":\"" + <%=authUsername%> + "\",\"password\":\"" + <%=authPassword%> + "\"}");
   try {
       int statusCode = client.executeMethod(method);
       if (statusCode != HttpStatus.SC_OK) {
           System.err.println("Method failed: " + method.getStatusLine());
       } // if
       byte[] responseBody = method.getResponseBody();
       System.out.println(new String(responseBody));
   } catch (HttpException e) {
     System.err.println("Fatal protocol violation: " + e.getMessage());
     e.printStackTrace();
   } catch (IOException e) {
     System.err.println("Fatal transport error: " + e.getMessage());
     e.printStackTrace();
   } finally {
     method.releaseConnection();
   } // try

And this is my imports secton in the Component Descriptor file:
<IMPORTS>
 <IMPORTS>
     <IMPORT
       NAME="commons-httpclient"
       MODULE="commons-httpclient-3.1.jar"
       REQUIRED="true"
     />
 </IMPORTS>

In the modules view I'm able to see the following:


Any hints about how to fix this issue? My Talend version is 6.2.0.
Community Manager

Re: The import org.apache cannot be resolved

Have you put the commons-httpclient-3.1.jar file in your custom component folder?
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: The import org.apache cannot be resolved

Here I simply did restart the IDE and my custom component recognized the importation.