tuxBurner / play-neo4jplugin

Neo4J Plugin for Play 2.4
39 stars 11 forks source link

Cannot init the Global object[neo4j.services.Neo4JServiceProvider cannot be cast to neo4j.services.Neo4JServiceProvider] #18

Closed maximepvrt closed 9 years ago

maximepvrt commented 9 years ago

Hi, In my projet I have a big problem ...

play.api.PlayException: Cannot init the Global object[neo4j.services.Neo4JServiceProvider cannot be cast to neo4j.services.Neo4JServiceProvider]
    at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:59) ~[play_2.10-2.3.8.jar:2.3.8]
    at play.api.WithDefaultGlobal$$anonfun$play$api$WithDefaultGlobal$$globalInstance$1.apply(Application.scala:53) ~[play_2.10-2.3.8.jar:2.3.8]
    at play.utils.Threads$.withContextClassLoader(Threads.scala:21) ~[play_2.10-2.3.8.jar:2.3.8]
    at play.api.WithDefaultGlobal$class.play$api$WithDefaultGlobal$$globalInstance(Application.scala:52) ~[play_2.10-2.3.8.jar:2.3.8]
    at play.api.DefaultApplication.play$api$WithDefaultGlobal$$globalInstance$lzycompute(Application.scala:402) ~[play_2.10-2.3.8.jar:2.3.8]
Caused by: java.lang.ClassCastException: neo4j.services.Neo4JServiceProvider cannot be cast to neo4j.services.Neo4JServiceProvider
    at neo4j.services.Neo4JServiceProvider.get(Neo4JServiceProvider.java:21) ~[na:na]
    at AuthService.<init>(AuthService.java:27) ~[na:na]
    at MyEnvironment.<init>(MyEnvironment.scala:10) ~[na:na]
    at Global.<init>(Global.java:8) ~[na:na]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40]

the source code is here : https://github.com/hubzer/hubzr-api

If I change

private UserRepository userRepository = Neo4JServiceProvider.get().userRepository;

by

private UserRepository userRepository = null;

in AuthService, my app starts :/

Thanks

tuxBurner commented 9 years ago

Hi @maximepvrt i have no rights to access your repo :) Which Version of Play are you using ?

maximepvrt commented 9 years ago

now it's good, I have change rights to access your repo :) Play 2.3.x

tuxBurner commented 9 years ago

Hi @maximepvrt i am looking into your project. I already have a project using securesocial with neo4j if you want you can take a look at https://github.com/tuxBurner/play-project-template/tree/play23

tuxBurner commented 9 years ago

Hi @maximepvrt i think the Problem is in your AuthService :)

private UserRepository userRepository = Neo4JServiceProvider.get().userRepository;

will not work because the AuthService gets instantiated before the play plugin starts up.

So dont use it as a field just call it in evry method where you need it.

maximepvrt commented 9 years ago

Thanks !! When do you think released the plugin for play 2.4 ?

tuxBurner commented 9 years ago

@maximepvrt i hope this week i get it done :)