The stacktrace you provided shows that Play is complaining about a
lack of a database, so I'd guess is something in your Play! config.
It will require *some* database, even if its a dummy db that you're
not going to use, but afaik, Play! won't function without one. You
might be able to remove their JPA plugin and just use Imperium, but
that's not something I've tried.
Many of the Play internals were quite JPA/SQL specific in the 1.1 and
earlier releases. I am not familiar w/ 1.2 or the forthcoming 2.0,
but I doubt that has changed. I mentioned this tight dependency to
Guillame on their list and that it made it hard to swap in something
like Empire, but I don't know if any efforts were made on that front
to remedy the issue.
Cheers,
Mike
[1] https://github.com/mhgrove/Imperium
I will point out that I've never tested Imperium w/ Play 1.1 or newer.
You didn't specify which version of Play! you're using, but if its
recent, it's possible that something in the Play! startup has changed
such that the Imperium startup won't work anymore.
> * copy the libs from dist directory into my newly created play! app's
> lib folder
> - excluding play, javassist and jpa libs (I assume, they are already
> part of play)
>
Play & JPA do. Javassist you might want to double check. iirc, Play!
does use Javassist, but the versions might not be the same. I don't
think that would contribute to the issue you're seeing, but it's worth
mentioning.
> * made entry for Empire Plugin in conf/play.plugins:
>
> 1001:com.clarkparsia.play.imperium.EmpirePlugin
>
> * created /empire.configuration:
>
> annotation.provider =
> com.clarkparsia.empire.util.PropertiesAnnotationProvider
> 0.name = demo
> 0.factory =
> com.clarkparsia.empire.sesametwo.RepositoryDataSourceFactory
> 0.url = http://localhost:8090/openrdf-sesame
> 0.repo = temp
>
> 1.name = context2
> 1.factory = com.clarkparsia.empire.jena.JenaTestDataSourceFactory
>
These look fine, but I suggest using the aliases "sesame" and "jena"
respectively for the factories.
> * created /empire.annotation.index
>
> com.clarkparsia.empire.annotation.RdfsClass=models.Term
> javax.persistence.NamedQuery=
>
> * the ...NamedQuery property is empty, because I don't know what to
> specify here
That's ok. These just specify which classes contain the specified
annotations. It can be expensive to scan the entire classpath to find
these things, so this helps alleviate that by just telling Empire
where to look.
>
> * enabled db=mem in application.conf (the only thing I changed)
>
> * created a Model class
>
> package models;
> import ...
> @Namespaces({
> "dc", "http://purl.org/dc/elements/1.1/",
> ...
> })
> @RdfsClass("zbwext:Descriptor")
> @Entity
> public class Term extends RdfModel {
>
> @RdfProperty("skos:prefLabel")
> private String prefLabel;
>
> public String getPrefLabel() {
> return prefLabel;
> }
>
> public void setPrefLabel(String prefLabel) {
> this.prefLabel = prefLabel;
> }
> }
>
> * and created a simple init test in my controller
>
> public static void index() {
> Empire.init(new OpenRdfEmpireModule());
Don't include this call to init. You should let Imperium worry about
initializing Empire.
>
> // create an EntityManager for the specified persistence context
> EntityManager aManager =
> Persistence.createEntityManagerFactory("demo")
> .createEntityManager();
This is not the correct way to get an EntityManager w/ Imperium...
>
> Term term = Imperium.em().find(Term.class, URI.create("http://zbw.eu/
> stw/descriptor/11182-6"));
... however this is.
Imperium auto-starts transactions like the JPA plugin, this part of
the trace is in that code intercepting the call before it gets to your
controller. From the error message, it sounds like Empire could not
find its configuration file. You might want to double check the
location of the file, perhaps put a breakpoint into Empire and see if
its correctly reading in the configuration. Easiest thing here would
be to put a breakpoint in the constructor of DefaultEmpireModule which
is where it will load the configuration and see if its completed
correctly.
Yes, a minimal running example would be a great resource to have.
Cheers,
Mike
Well if theModules contains an instance of DefaultEmpireModule, a
constructor is being called. It sounds like its the case that it
could not find an empire configuration file in any standard location
and tried to cobble one together from what was in your application
conf or read a VirtualFile out of the conf directory.
If you put a breakpoint in the EmpirePlugin, you can see @ L102 where
it tries to build a configuration based on what's in Play!'s
configuration. Looking at the isEmpireConfigFound method in
EmpirePlugin, it's out of date wrt to what Empire would prefer. In
fact, looking at your previous email, I see you said you created a
file 'empire.configuration' which is correct, but Imperium does not
check for that file as it was written against an earlier version of
Empire.
The workaround would appear to be seeing in your application.conf the
property "empire.config" to the file path to your configuration file.
If that resolves the problem, I'll update the EmpirePlugin to reflect
the current status of Empire.
Cheers,
Mike