Error about create datareader

hi, I’m using version 0.9
I follow the example on github, but I get following error:

java.lang.UnsupportedOperationException: Cannot create DataReader. Solutions: avoid import via calling load directly, provide a DataReader or use e.g. GraphHopperOSM or a different subclass
at com.graphhopper.GraphHopper.createReader(GraphHopper.java:717)
at com.graphhopper.GraphHopper.importData(GraphHopper.java:710)
at com.graphhopper.GraphHopper.process(GraphHopper.java:681)
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:659)
at controller.PlanningController.test(PlanningController.java:28)

My maven configure:

com.graphhopper
graphhopper-core
0.9.0


com.graphhopper
graphhopper-reader-osm
0.9.0


com.graphhopper
graphhopper-map-matching-core
0.9.0

My code:
> hopper = new GraphHopper().forServer();
25> hopper.setDataReaderFile("/WEB-INF/map-resource/hk_area.osm");
26> hopper.setGraphHopperLocation("/WEB-INF/graphhopper");
27> hopper.setEncodingManager(new EncodingManager(“car”));
28> hopper.importOrLoad();

anyone can help figure this problem?

instead new GraphHopper() try new GraphHopperOSM()

1 Like

thanks, it works.
but another problem occurs,

Directory /WEB-INF/graphhopper does not exist and cannot created to place lock file there: /WEB-INF/graphhopper/gh.lock
at com.graphhopper.storage.NativeFSLockFactory$NativeLock.tryLock(NativeFSLockFactory.java:110)
at com.graphhopper.GraphHopper.process(GraphHopper.java:636)
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:619)

could you help take a look? I have already create the directory.

Are you sure it’s /WEB-INF and not WEB-INF?