Opened 11 years ago

Closed 11 years ago

#42 closed task (fixed)

Expected resource locations for UoM API?

Reported by: jbartels Owned by:
Priority: major Milestone:
Component: Keywords: formatting
Cc:

Description

I'm attempting to use the UoM API and I am having some difficulty with the initialization.

I'm attempting to use a very simple case:

Unit unit = UnitFormat.getInstance().parse("some unit string");

I am getting an error

java.lang.Error: No service provider found for org.unitsofmeasure.util.UnitFormatProvider
        at org.unitsofmeasure.util.UnitFormat.findJarServiceProvider(UnitFormat.java:173)
        at org.unitsofmeasure.util.UnitFormat.<clinit>(UnitFormat.java:51)

I looked at UnitFormat?.java and it appears to be using a resource loader looking in META-INF/services. I placed the UoM JAR in that path in my project and still no luck.

Where should the UoM JARs be located within a project so that the resources can be found??

Change History (1)

comment:1 in reply to:  description Changed 11 years ago by Werner Keil

Keywords: formatting added
Resolution: fixed
Status: newclosed

Sorry if this may have caused confustion. After thorough checks against target containers especially OSGi this mechanism from Java 6 was found to be incompatible. Mainly due to circular dependencies between an implementing OSGi bundle and the base API.

The latest version of UOM API no longer contains a concrete or abstract class named UnitFormat?, but an interface. Driving reason beside the mentioned issue were further inspiration by the JSR-108 successor UCAR (where this exists in a similar way) and different class hierarchies e.g. under Eclipse and ICU4J as opposed to other frameworks. A direct dependency to java.util.text.Format wasn't suitable for some of these ecosystems as others (ICU4J) define their own subclasses of that class while others use entirely different formatters.

Test code shows 2 examples named BaseFormat? and SimpleFormat? using the new interface. Those are blueprints, so in non-test code, please implement your own. Contributions to the test code are welcome while further unit tests are gradually added.

Replying to jbartels:

I'm attempting to use the UoM API and I am having some difficulty with the initialization.

I'm attempting to use a very simple case:

Unit unit = UnitFormat.getInstance().parse("some unit string");

I am getting an error

java.lang.Error: No service provider found for org.unitsofmeasure.util.UnitFormatProvider
        at org.unitsofmeasure.util.UnitFormat.findJarServiceProvider(UnitFormat.java:173)
        at org.unitsofmeasure.util.UnitFormat.<clinit>(UnitFormat.java:51)

I looked at UnitFormat?.java and it appears to be using a resource loader looking in META-INF/services. I placed the UoM JAR in that path in my project and still no luck.

Where should the UoM JARs be located within a project so that the resources can be found??

Note: See TracTickets for help on using tickets.