Scheduling problem

27 views
Skip to first unread message

Nick Barrett

unread,
Sep 22, 2015, 3:57:06 AM9/22/15
to utterlyidle
Hi all, 

I'm wishing to use the scheduling loveliness to run some jobs on a periodic basis, but I'm having some basic configuration trouble. 

I've followed the documentation in https://github.com/bodar/utterlyidle/wiki/24.-Scheduling and so far, my features contain these resources:

@Override
public Resources addResources(Resources resources) throws Exception {
resources.add(annotatedClass(BatchScheduleResource.class));
return resources;
}

and my RestApplication contains these modules:

add(bindingsModule(bindings(extensions)));
add(new PortalComplianceFeatures());
add(new ScheduleModule());
add(new JobsModule());
add(new ProfilingModule());
 

I get this: com.googlecode.yadic.ContainerException: interface com.googlecode.lazyrecords.Records not found in container


Oh, my bodar dependancies are:

<dependency>
<groupId>com.googlecode.utterlyidle</groupId>
<artifactId>utterlyidle</artifactId>
<version>1.52</version>
</dependency>
<dependency>
<groupId>com.googlecode.totallylazy</groupId>
<artifactId>totallylazy</artifactId>
<version>1.77</version>
</dependency>
<dependency>
<groupId>com.googlecode.lazyrecords</groupId>
<artifactId>lazyrecords</artifactId>
<version>2.25</version>
</dependency>

Any ideas please?

Cheers, Nick

Mike

unread,
Sep 22, 2015, 4:24:52 AM9/22/15
to utter...@googlegroups.com
Nick,

you need to write a custom module to stick an instance of Records
from the lazryrecords project in either request or application
scope. You can use MemoryRecords if you don't care about
persistence after process dies, or one of the other implementation
(SqlRecords) if you do care and want to persist to a database.

Take care,
Mike.



On Tue Sep 22 02:57:06 CDT 2015, Nick Barrett
> -- You received this message because you are subscribed to the
> Google Groups "utterlyidle" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to utterlyidle...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Nick Barrett

unread,
Sep 22, 2015, 4:29:26 AM9/22/15
to utter...@googlegroups.com
Hi Mike, long time no speak! Thanks for reply.

Yes, I began to do that by adding Records into Application scope but when I start my application I get:

Caused by: java.lang.NoClassDefFoundError: com/googlecode/totallylazy/predicates/Predicate

which sounds really strange as TL is already a project dependency….

I must be doing something really wrong here?

Cheers
Nicl
> You received this message because you are subscribed to a topic in the Google Groups "utterlyidle" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/utterlyidle/yVvrhlNbznY/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to utterlyidle...@googlegroups.com.

Alex Luker

unread,
Sep 22, 2015, 10:42:30 AM9/22/15
to utter...@googlegroups.com

No idea if it's this, but you may well be using incompatible versions of the stack.

Looks like you're using a 2. version of Lazy Records, and a 1. version of UI and TL.

Mike

unread,
Sep 22, 2015, 11:20:40 AM9/22/15
to utter...@googlegroups.com
I think Alex is right, for what its worth :)

On Tue Sep 22 09:42:29 CDT 2015, Alex Luker <alex....@gmail.com>
wrote:

> No idea if it's this, but you may well be using incompatible
> versions of
> the stack.
>
> Looks like you're using a 2. version of Lazy Records, and a 1.
> version of
> UI and TL.
> On 22 Sep 2015 09:29, "Nick Barrett" <nick.ba...@gmail.com>
> wrote:
>
>> Hi Mike, long time no speak! Thanks for reply.
>>
>> Yes, I began to do that by adding Records into Application scope
>> but when
>> I start my application I get:
>>
>> Caused by: java.lang.NoClassDefFoundError:
>> com/googlecode/totallylazy/predicates/Predicate
>>
>> which sounds really strange as TL is already a project
>> dependency?.

Nick Barrett

unread,
Sep 22, 2015, 1:06:28 PM9/22/15
to utter...@googlegroups.com
Thanks Mike & Alex…

So, I adjusted the versions of the dependencies to be the latest (including pre-release). Previously I was using only the released versions and that didn’t work :-)

So now I have got over the class cast exceptions but I am still having trouble scheduling stuff  due to 400 Unsatisfiable Parameters

Scheduling seems to be configured okay as http://localhost:8000/schedules/list works okay -> {schedules=[], schedulerIsRunning=true}

But when I try and schedule something e.g. a post to this endpoint: http://localhost:8000/portal-compliance/instruction/2011788


Nearly there!….any ideas?
Cheers
Nick

Alex Luker

unread,
Sep 22, 2015, 2:43:10 PM9/22/15
to utter...@googlegroups.com
Seems to be expecting your ID to be a valid UUID. Try posting to 

http://localhost:8000/schedules/schedule//de305d54-75b4-431b-adb2-eb6b9e546014/60/portal-compliance/instruction/2011788

If you run UtterlyIdle in debug mode it prints out exceptions encountered when trying to match the resources - Can be helpful in diagnosing the problem (that or debugging the binding matching).

Alex Luker

unread,
Sep 22, 2015, 2:43:54 PM9/22/15
to utter...@googlegroups.com
I messed up that URL - just replace 12345 with a uuid

Nick Barrett

unread,
Sep 22, 2015, 4:10:24 PM9/22/15
to utter...@googlegroups.com
Awesome Alex, thanks! 

Got that working now and have updated the scheduling part of the Wiki to help future people.

My remaining challenge is to be able to query the schedule and / or jobs and get JSON back. When I call:

application.handle(get("/schedules/list").contentType("application/json; charset=utf-8").build()

I seem to get HTML back which is not quite what I’m after. Can I pass my UUID job Id into some get method?

Jobs seems to give me back empty JSON array but there’s nothing in that as I’ve not created a job have I?

Alex Luker

unread,
Sep 22, 2015, 4:19:29 PM9/22/15
to utter...@googlegroups.com
It might be because you're using .contentType rather than .accepting("application/json") - You need to tell the server what you want back, rather than what you're sending.

Nick Barrett

unread,
Sep 22, 2015, 4:34:39 PM9/22/15
to utter...@googlegroups.com, Alex Luker
Good point, but Actually that didn’t make any difference… when I print out the response to 
application.handle(get("/schedules/list").accepting("application/json").build()
I still get HTML:


HTTP/1.1 303 See Other
Content-Type: text/html; charset="UTF-8"
Date: Tue, 22 Sep 2015 20:31:49 UTC
Location: /schedules/list
Content-Length: 223

<html>
<head>
    <title>See Other</title>
    <link rel="stylesheet" href="/utterlyidle/rendering/style.css" type="text/css"/>
</head>
<body>
<h1>See Other</h1>
<a href="/schedules/list">/schedules/list</a>
</body>
</html>
schedules=HTTP/1.1 200 OK
Content-Type: application/json; charset="UTF-8"
Date: Tue, 22 Sep 2015 20:31:49 UTC
Content-Length: 416

{schedules=[{duration=null, request={method=POST, raw=POST /portal-compliance/instruction/2011788 HTTP/1.1
X-Forwarded-For: e35c6cd4-3655-45d5-bfee-541ae122c9c8
Content-Length: 0

, uri=/portal-compliance/instruction/2011788, entity=}, seconds=30, response=null, start=null, started=Tue Sep 22 21:31:49 BST 2015, id=5b1d21a3-8f33-447b-8652-a9917d8f6509, completed=null, status=running}], schedulerIsRunning=true}

Alex Luker

unread,
Sep 24, 2015, 4:19:49 PM9/24/15
to utter...@googlegroups.com
So it turned out that the JSON rendering wasn't registered for the schedules resource. What you were seeing was just the toString of a HashMap. I've pushed a fix to master, so if you upgrade to the latest it should be working. 

Nick Barrett

unread,
Sep 24, 2015, 5:04:59 PM9/24/15
to utter...@googlegroups.com
awesome Alex, I’ll give it  whirl….

Thanks again for being attentive :-)

Xuemin Guan

unread,
Sep 24, 2015, 5:37:04 PM9/24/15
to utter...@googlegroups.com
The Utterly Idle Alex Consultancy. 


Sent from Mailbox

Nick Barrett

unread,
Sep 24, 2015, 5:37:49 PM9/24/15
to utter...@googlegroups.com
The Utterly Awesome Alex Consultancy

Nick Barrett

unread,
Sep 24, 2015, 6:04:44 PM9/24/15
to utter...@googlegroups.com
All good now - thanks again!


{
  • schedules
    [
    • {
      • duration44,
      • request
        {
        • method"POST",
        • raw"POST /portal-compliance/all-active-instructions HTTP/1.1 X-Forwarded-For: e12f8c01-f04e-4302-b8a5-0649658d0611 Content-Length: 0 ",
        • uri"/portal-compliance/all-active-instructions",
        • entity""
        },
      • seconds800,
      • response
        {
        • code200,
        • isOktrue,

(etc)

On 24 Sep 2015, at 22:37, Xuemin Guan <gxu...@gmail.com> wrote:

Reply all
Reply to author
Forward
0 new messages