Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
Expand all | Collapse all

Problem with JAVA code and Apache HTTP Client

  • 1.  Problem with JAVA code and Apache HTTP Client

    Posted Mon October 19, 2020 11:13 AM

    Hi, can anybody help me with mysterious problem on MAXIMO 7.6.1.x where code that worked in previous versions suddenly fails.

    code is pretty simple (it is a method in a bean class which executes the following):

    try { URIBuilder uri_bld = new URIBuilder(); uri_bld.setScheme("https") .setHost("some.server") .setPort(8101) .setPath("/some/path"); URI htt_uri = uri_bld.build(); /* both variants HttpClientBuilder.build() or HttpClients.createDefault() fail for the same reason CloseableHttpClient htt_cln = HttpClientBuilder.create() .useSystemProperties() .build(); */ CloseableHttpClient htt_cln = HttpClients.createDefault(); HttpGet httpGet = new HttpGet(htt_uri); CloseableHttpResponse response = htt_cln.execute(httpGet); String responseContent = EntityUtils.toString(response.getEntity()); } catch (Exception e) { e.printStackTrace(); }

    the error given is:

    15.10.2020 13:04:59:663 CEST] 00000137 SystemErr R java.lang.NoClassDefFoundError: org.apache.http.impl.conn.ManagedHttpClientConnectionFactory (initialization failure)

    at java.lang.J9VMInternals.initializationAlreadyFailed(J9VMInternals.java:96)

    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$InternalConnectionFactory.<init>(PoolingHttpClientConnectionManager.java:572)

    .....

    Caused by: java.lang.NoSuchFieldError: org/apache/http/message/BasicLineFormatter.INSTANCE

    at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:52)

    at org.apache.http.impl.io.DefaultHttpRequestWriterFactory.<init>(DefaultHttpRequestWriterFactory.java:56)

    The code depend only on libraries provided by IBM (and Apache HTTP Client but were included by IBM into lib folder of MAXIMO)

    Classloader suggests all appropriate classes are loaded.

    Best regards

    Matej Potočnik






    #Maximo
    #AssetandFacilitiesManagement
    #SupportMigration
    #Support


  • 2.  RE: Problem with JAVA code and Apache HTTP Client

    Posted Thu November 05, 2020 11:32 AM

    answer to my self, and for anybody who is interested :)

    in buildmaximo.xml for building business objects it is stated that libraries used are:

    lib/httpcore-4.4.4.jar

    lib/httpmime-4.2.5.jar

    lib/httpclient-4.5.2.jar

    but in lib directory (maximo/applications/maximo/lib) there still resides httpcore-4.2.4.jar which is naturally also deployed to WebSphere.

    THIS IS THE CULPRIT!






    #Maximo
    #AssetandFacilitiesManagement
    #Support
    #SupportMigration