[deepamehta-devel] Question about "org.neo4j.graphdb.NotInTransactionException" when creating TopicType

Martin Tippmann martin.tippmann at gmail.com
Sat Sep 13 03:15:12 CEST 2014


Hi everyone!

2014-09-12 20:20 GMT+02:00 Malte Reissig <mre at deepamehta.de>:
>
>  My latest dm4-freifunk-api plugin should not even compile with the
> current 4.4-SNAPSHOT and that's why I wonder where you got that specific
> "dms.createTopic(...)"-statement from. To make it easier I would suggest
> to go back the 4.3 stable with our development.
>

I've got it working with 4.4-SNAPSHOT now.

The only change that was required was [1]. It now imports the data fine and
I can see it in the webclient! Very cool!


> Nonetheless your error message points to a completely different issue
> which I did not ran into, we're missing a Transaction around our
> CREATE-operation. Please try to wrap the "dms.createTopic()"-call into a
> Transaction by using something similar to the following code.
>
> DeepaMehtaTransaction tx = dms.beginTx();
> try {
>      // do stuff here
>      dms.createTopic(....);
>      tx.succes();
> } catch (Exception) {
>      tx.failure()
> } finally() {
>      tx.finish();
> }
>

That fixed it! Thanks!



> And because of your question regarding the use of "Jackson": Since
> DeepaMehta 4 already ships with Jettison, I would ditch another JSON
> lib, yes. Jettison is pretty straightforward to use and we anyway have
> to be parsing the whole API directory very carefully (manually) cause of
> its wilderness. Lets get in touch somewhen soon for solving the open
> questions regarding how to complete the application model in
> dm4-freifunk-api for your queries.
>

I'll write you a mail on the topic. I've made some progress on my original
idea to just parse the JSON schema for creating the topic types and I and
Andi think that's probably the best way. The schema and the data is prone
to rather a lot of changes and maintaining a fork in Java of the schema is
something I'd rather would avoid. I'm quite late on the problem but I think
it's still a feasible way to go.

The basic idea is to parse the schema and create the topic types (likely
for multiple versions) and then parse the current API data and import
things. The big advantage of this approach would be - if it works - that
getting the data into DeepaMehta is no problem in the future. All moving
parts are the API schema and the community data.

I hope I have some basic implementation ready by Sunday and then I'll see
how good this will work.

>
> Tomorrow I will update my repo to be compatible with 4.3 and also solve
> the TransactionException issue. We can then still upgrade to DM 4.4
> later, after its released.
>

It's working now with 4.4-SNAPSHOT after adding the transaction code.


>
> Cheers,
> Malte
>


2014-09-12 21:39 GMT+02:00 Jörg Richter <jri at deepamehta.de>:
>
> If your code is invoked via a resource method (= invoked via a HTTP
> request), be it directly or indirectly, just annotate the resource method
> with @Transactional. This will create a transaction on a per-request basis.
>

Ah. I've tried that as I stumbled upon the Trac-Ticket but it did not work.
Now I know why :)


> However, if your code is NOT invoked via a HTTP request -- e.g. when you
> are in a migration or in a test -- you must create the transaction
> manually, as Malte mentioned. That is, ONE transaction wrapping your entire
> migration (resp. test) code. Hint: calling tx.failure() is not necessary.
>
> This ticket (and its comments) explain the new transaction handling of
> upcoming DM 4.4.:
> https://trac.deepamehta.de/ticket/698
>
> DM 4.4 will contain considerable API changes against DM 4.3. You possibly
> will have less adaption work when jumping on the 4.4-SNAPSHOT train right
> now (master branch).
>

Okay. Thanks for the help and I think I'll go this way as everything is
working now fine!

Thanks again for the help from everyone.

regards
Martin


1:
https://github.com/freifunk/query.api.freifunk.net/commit/e0ec028555a8ef8897cb34e9d94d5e02249355e3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.deepamehta.de/pipermail/devel-lists.deepamehta.de/attachments/20140913/70fb8ae2/attachment.html>


More information about the devel mailing list