0

I am getting below error while using istack-commons-runtime-3.0.11/4.0.0 jars particularly. Also tried using lower version JARs as suggested by some of the blogs but didn't work.

Error: java.lang.NoSuchMethodError: com.sun.istack.localization.LocalizableMessageFactory.(Ljava/lang/String;Lcom/sun/istack/localization/LocalizableMessageFactory$ResourceBundleSupplier;)V]

Any kind of help would be really appreciated.

  • Probably you should add a proper dependency. Check these answers https://stackoverflow.com/questions/18078766/java-lang-noclassdeffounderror-com-sun-istack-localization-localizable – I.G. Feb 11 '21 at 07:39

2 Answers2

0

Just had a similar kidda problem, and this is how I fixed it. The following steps are a working way to add a library. I had done the first two steps right, but I hadn't done the last one by dragging the ".jar" file direct from the file system into the "lib" folder on my eclipse project. Additionally, I had to remove the previous version of the library from both the build path and the "lib" folder.

Step 1 - Add .jar to build path enter image description here

Step 2 - Associate sources and javadocs (optional) enter image description here

Step 3 - Actually drag .jar file into "lib" folder (not optional)

  • I have added the JAR under lib folder as well as I could see it in the build path. It seems that few other JARs like jaxb-core contains the class with similar name. Which is causing the confusion for a classloader. How do I specify to the classloader that i need to load a class form a particular JAR only? – shubham bhopale Feb 11 '21 at 08:07
0

This is the contents of istack-commons-runtime-4.0.0:

As you can see it has what you need. Therefore if you are getting NoSuchMethod error, it means you have another conflicting version of this somewhere in your libraries.

/*
 * Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Distribution License v. 1.0, which is available at
 * http://www.eclipse.org/org/documents/edl-v10.php.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

package com.sun.istack.localization;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * @author WS Development Team
 */
public class LocalizableMessageFactory {

    private final String _bundlename;
    private final ResourceBundleSupplier _rbSupplier;

    @Deprecated
    public LocalizableMessageFactory(String bundlename) {
        _bundlename = bundlename;
        _rbSupplier = null;
    }

    public LocalizableMessageFactory(String bundlename, ResourceBundleSupplier rbSupplier) {
        _bundlename = bundlename;
        _rbSupplier = rbSupplier;
    }

    public Localizable getMessage(String key, Object... args) {
        return new LocalizableMessage(_bundlename, _rbSupplier, key, args);
    }

    public interface ResourceBundleSupplier {
        /**
         * Gets the ResourceBundle.
         * @param locale the requested bundle's locale
         * @return ResourceBundle
         */
        ResourceBundle getResourceBundle(Locale locale);
    }

}

If you use Maven, open your IDE (Eclipse/Intellij), open your pom.xml file, and look into your dependencies and filter for istack and see if there are lower versions included as transitive dependencies.

In eclipse, click on pom.xml --> Dependencies --> type istack in your filter.

Example:

enter image description here

JCompetence
  • 6,997
  • 3
  • 19
  • 26
  • You are right. Probably jaxb-core is having the class with a similar name. But I am not using the maven instead adding the JARs under the 'lib' folder. How should I solve this then in case both the JARs are needed and refer to the specific version of the LocalizedMessageFactory class form istack-commons JAR? – shubham bhopale Feb 11 '21 at 08:11
  • @shubhambhopale It does not get conflicts by just ClassName, it has to match com.sun.istack.localization package as well, therefore I think you have a jar that has this package exactly... I dont know how to exclude dependencies from libs/jars...I know it can be done by maven... – JCompetence Feb 11 '21 at 08:14
  • No, it's not that simple. JAXB was repackaged many times, and that class can be in any jar either having 'jax' in name, or being referenced by. – 9ilsdx 9rvj 0lo May 14 '21 at 11:16