gluonhq / maps

https://gluonhq.com/labs/maps/
GNU General Public License v3.0
140 stars 36 forks source link

Exception: Storage Service is not available #8

Closed ThomasDaheim closed 3 years ago

ThomasDaheim commented 7 years ago

Hi,

I'm using com.gluonhq:maps:1.0.1 in my code an get the following messages during startup. Afterwards, everything seems to run fine... Any ideas?

Thanks, Thomas

May 16, 2017 5:09:27 PM com.gluonhq.charm.down.Platform <clinit>
SEVERE: javafx.platform is not defined. Desktop will be assumed by default.
May 16, 2017 5:09:27 PM com.gluonhq.impl.maps.ImageRetriever <clinit>
SEVERE: null
java.io.IOException: Storage Service is not available
    at com.gluonhq.impl.maps.ImageRetriever.lambda$static$20(ImageRetriever.java:67)
    at java.util.Optional.orElseThrow(Optional.java:290)
    at com.gluonhq.impl.maps.ImageRetriever.<clinit>(ImageRetriever.java:67)
    at com.gluonhq.impl.maps.MapTile.<init>(MapTile.java:85)
    at com.gluonhq.impl.maps.BaseMap.loadTiles(BaseMap.java:327)
    at com.gluonhq.impl.maps.BaseMap.layoutChildren(BaseMap.java:465)
    at javafx.scene.Parent.layout(Parent.java:1087)
    at javafx.scene.Parent.layout(Parent.java:1093)
    at javafx.scene.Parent.layout(Parent.java:1093)
    at javafx.scene.Parent.layout(Parent.java:1093)
    at javafx.scene.Parent.layout(Parent.java:1093)
    at javafx.scene.Parent.layout(Parent.java:1093)
    at javafx.scene.Scene.doLayoutPass(Scene.java:552)
    at javafx.scene.Scene.preferredSize(Scene.java:1646)
    at javafx.scene.Scene.impl_preferredSize(Scene.java:1720)
    at javafx.stage.Window$9.invalidated(Window.java:846)
    at javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:109)
    at javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:144)
    at javafx.stage.Window.setShowing(Window.java:922)
    at javafx.stage.Window.show(Window.java:937)
    at javafx.stage.Stage.show(Stage.java:259)
    at tf.gpx.edit.main.GPXEditorManager.start(GPXEditorManager.java:109)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
    at java.lang.Thread.run(Thread.java:745)
jasjisdo commented 7 years ago

I do this to cache map tiles in my home dir:

in main of my javafx application:

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {

        if(isWindows() || isMac() || isUnix()) {
            System.setProperty("javafx.platform" , "Desktop");
        }

        // define service for desktop
        StorageService storageService = new StorageService() {
            @Override
            public Optional<File> getPrivateStorage() {
                // user home app config location (linux: /home/[yourname]/.gluonmaps)
                return Optional.of(new File(System.getProperty("user.home")));
            }

            @Override
            public Optional<File> getPublicStorage(String subdirectory) {
                // this should work on desktop systems because home path is public
                return getPrivateStorage();
            }

            @Override
            public boolean isExternalStorageWritable() {
                //noinspection ConstantConditions
                return getPrivateStorage().get().canWrite();
            }

            @Override
            public boolean isExternalStorageReadable() {
                //noinspection ConstantConditions
                return getPrivateStorage().get().canRead();
            }
        };

        // define service factory for desktop
        ServiceFactory<StorageService> storageServiceFactory = new ServiceFactory<StorageService>() {

            @Override
            public Class<StorageService> getServiceType() {
                return StorageService.class;
            }

            @Override
            public Optional<StorageService> getInstance() {
                return Optional.of(storageService);
            }

        };
        // register service
        Services.registerServiceFactory(storageServiceFactory);

        launch(args);

    }
ThomasDaheim commented 7 years ago

Thanks, would have a look at this. Still I would think that no exception should be thrown with vanilla usage.

ThomasDaheim commented 7 years ago

Seems to work, thanks a lot!

Now I'm only left with some debug output:

Jun 25, 2017 5:45:25 PM com.gluonhq.impl.maps.ImageRetriever <clinit>
INFO: hasfilecache = true
Jun 25, 2017 5:45:25 PM com.gluonhq.impl.maps.ImageRetriever$CacheThread doCache
INFO: retrieve http://tile.openstreetmap.org/0/0/0.png and store \0\0\0.png
brightspectrum commented 5 years ago

I am using modular Java 12. The approach above does not seem to work for me since com.gluonhq.attach.storage.impl does not seem to be exported in the module-info. It looks like if DesktopStorageService was in my classpath then it would be used. It looks like this class is in https://nexus.gluonhq.com/nexus/content/repositories/releases/com/gluonhq/attach/storage/4.0.2/storage-4.0.2-desktop.jar. I can't figure out how to add this as a Maven dependency yet though.

jperedadnr commented 5 years ago

@brightspectrum Did you check the sample's build: https://github.com/gluonhq/maps/blob/master/samples/mobile/build.gradle, you need to use the desktop classifier.

brightspectrum commented 5 years ago

Thanks. I got it working now by adding the desktop classifier in my pom.xml. No more exceptions and my tiles are now being cached in C:\Users\.gluon.gluonmaps `

com.gluonhq.attach storage 4.0.2 desktop

`

ikeboatn commented 4 years ago

How do I get around this error:

com.gluonhq.charm.down.Platform SEVERE: javafx.platform is not defined. Desktop will be assumed by default.

Trying to run the fiftystates sample applications. Any ideas? Tried the above suggestions but didn't work for me.

Thanks

jperedadnr commented 4 years ago

@ikeboatn This is the Maps repository, If you have issues running the Gluon MObile samples, post them in their issue tracker.

Also, I don't see how your issue relates to the Storage Service either.

ikeboatn commented 4 years ago

Sent from my Huawei phoneThanks for the feedback. -------- Original message --------From: José Pereda notifications@github.comDate: Today, 12:15 PMTo: gluonhq/maps maps@noreply.github.comCc: ikeboatn ikeboatn@gmail.com, Mention mention@noreply.github.comSubject: Re: [gluonhq/maps] Exception: Storage Service is not available (#8)@ikeboatn This is the Maps repository, If you have issues running the Gluon MObile samples, post them in their issue tracker. Also, I don't see how your issue relates to the Storage Service either.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or mute the thread.

sonica799 commented 4 years ago

Hello, I'm having the same issue.. Can you please help me?

abhinayagarwal commented 3 years ago

Gluon Maps has a dependency on Attach and this wasn't explicitly mention in the published pom and may cause an issue if the dependency to Attach isn't explicitly declared.

This has been fixed with #54

julesledev commented 2 years ago

I use vanilla js and i have this problem too

image