Exception NoSuchMethodError in org.hipparchus.util.MathUtils.twoSum(double, double)

Hello @bcazabonne,

I have a problem recently in AbsoluteDate.java. I have tried to create createGravityField(inputData); (as in the tutorial). But an exception raised in AbsoluteDate.java in line 315:

final SumAndResidual sumAndResidual = MathUtils.twoSum(seconds, tsOffset);

The execution is:

Exception in thread “main” java.lang.NoSuchMethodError: ‘org.hipparchus.util.MathUtils$SumAndResidual org.hipparchus.util.MathUtils.twoSum(double, double)’

Can you please help me to understand what is the problem? I appreciate it. Please note that I’m using the develop orekit.

Best regards,
-Amir

Hi @AmirAllahvirdi

Could you tell me what tutorial you are using?

Best regards,
Bryan

I’ve used org.orekit.tutorials.estimation.common to follow how-to-use Kalman filtering in orekit. In AbstractOrbitDetermination.java, line 397.

I have used the following piece of code to read the geopotential coefficient from the EGM2008 file and it works fine:

GravityFieldFactory.clearPotentialCoefficientsReaders();
		EGMFormatReader potentialCoefficientsReader = new EGMFormatReader("EGM2008_FREETIDE", false);
		GravityFieldFactory.addPotentialCoefficientsReader(potentialCoefficientsReader);
		int degree = inputData.getPropagator().getForceModels().getGravity().getDegree();
		int order = inputData.getPropagator().getForceModels().getGravity().getOrder();
		NormalizedSphericalHarmonicsProvider gravityField = GravityFieldFactory.getNormalizedProvider(degree, order);

Surprisingly I got the same exception in when I run:

        ForceModel moonForceModel = new HolmesFeatherstoneAttractionModel(
			                CelestialBodyFactory.getMoon().getInertiallyOrientedFrame(), gravityField);

Is there any problem with the twoSum method? I have checked the hipparchus 1.8 apidocs. There is no such method there.

Regards,
-Amir

@AmirAllahvirdi,

The implementation using MathUtils.twoSum(seconds, tsOffset) in AbsoluteDate class is recent (i.e. 5 weeks ago). It is a double implementation: one part in Hipparchus library (see commit 2b062b of Hipparchus) and one part in Orekit library (see commit 5b250e of Orekit).

Therefore, if you are using the development version of Orekit, you must also use the development version of Hipparchus library (i.e. master branch) in order to have the last changes in MathUtils.twoSum(...)

Best regards,
Bryan

@bcazabonne

Thanks for your reply Bryan,
I have imported both the orekit dev version and hipparchus master in Eclipse. But the error still exists!

Since I’m not an expert in java I’m doing something wrong. Here are my steps in importing them in eclipse:

  1. import Hipparchus master using git in Eclipse
  2. import Orekit develop using git in Eclipse
  3. import my own software in Eclipse

I have checked the build path of all projects and I did not find anything strange. I know it may silly but can you check if I miss any steps here? It’s now 2 days I’m on this point :pensive:

Best regards,
-Amir

Does your project is a Java project and have a pom.xml file to handle its dependencies?

If yes, you have to update the Orekit and Hipparchus versions to 11.0-SNAPSHOT and 1.9-SNAPSHOT, respectively.

If no, you can play with the build path in Eclipse.

  1. Right click on your project and Select Build Path.
  2. Click on Configure Build Path ....
  3. On the Projects window, add Orekit and Hipparchus from your workspace.
  4. Click on Apply and Apply and Close.
1 Like

Depending on how they are configured, Eclipse project may import dependencies from either official maven published artifacts or from other projects in the same eclipse workspace.
I guess your orekit-tutorial projects uses the maven published artifacts and doesn’t use the development versions you downloaded alongside, despite they are available close.

You can righ-click on the orekit-tutorials entry in the package explorer and from the context menu select “Build Path → Configure Build Path…”. Then, look into this wizard, there should be one tab for “Projects” where you could point to the develop version you downloaded/ You may also need to look at the “Order and Export” tab and rearrange the order for electing dependencies, making sure he projects are used before the “Maven Dependencies” (or even that the “Maven Dependencies” are unchecked).

Beware that this is not the standard setting since most people would like to use officially published version. This configuration is useful when someone needs to rely on still unpublished development version, so it requires this kind of manual configuration.

2 Likes

@bcazabonne

You were faster than me on this answer! :clap:

1 Like

Two answers are better than one. Especially if they are on the same way :slight_smile:

2 Likes

Dear @luc and @bcazabonne,

Thank you so much. It works fine! I appreciate your help. :pray:

Best regards,
-Amir