[akka-user] Simple Akka + JAX-RS no worky

136 views
Skip to first unread message

Max Afonov

unread,
May 17, 2010, 4:50:48 PM5/17/10
to Akka User List
Hello All,

I'm working on integrating Akka into a servlet environment, with JAX-
RS to boot. Unfortunately, I've run into a weird issue that I can't
quite comprehend. Perhaps someone here has seen something like this.
Note also that I'm working off of akka/akka-samples/akka-sample-rest-
scala as a template.

Here's a simple dumbed-down project that expresses what I want to be
able to do:

http://gist.github.com/403961

In a nutshell, I'm exposing an actor (HelloService.scala) at "/hello"
that has the child endpoint "/world". It's supposed to send a message
to another actor (HelloActor.scala) that should reply with a string.
Nothing fancy. When I hit http://localhost:8080/hello/world, I see the
following on my console:

[warn] /hello/world
java.lang.IllegalArgumentException: object is not an instance of
declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider
$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:
149)

Here's the full stack trace if it helps:

https://gist.github.com/raw/403961/bd19001855473684e8600bf59e0014143d8f30fb/not_an_instance.txt

Is there anything obvious that I'm doing wrong? I'm running Akka 0.9
from master, rev 6154102.

Thanks for any and all insight,
-max

--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.

Viktor Klang

unread,
May 17, 2010, 5:14:22 PM5/17/10
to akka...@googlegroups.com
Hello Max,

I believe the very recent refactoring to introduce ActorRef has silently broken the JAX-RS integration sinze the ActorRepository no longer returns Actors, but ActorRefs, and Jersey is looking for the Actor instance.

I'll add it to the issue tracker and see if we can somehow fix this cleanly.

Thanks for reporting this!
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall

Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang

Jonas Bonér

unread,
May 17, 2010, 5:18:03 PM5/17/10
to akka...@googlegroups.com, akka...@googlegroups.com
Ah. Crap. Thanks for catching this.
Viktor, I think you are right.  
We need tests for this code. 

--
Jonas Bonér 

Viktor Klang

unread,
May 17, 2010, 5:28:47 PM5/17/10
to akka...@googlegroups.com
On Mon, May 17, 2010 at 11:18 PM, Jonas Bonér <jo...@jonasboner.com> wrote:
Ah. Crap. Thanks for catching this.
Viktor, I think you are right.  
We need tests for this code. 

Yeah, we do. I haven't had much time to think of a solution, but I'm starting to get skeptical at having the Actor class having the Jersey annotations at all, perhaps a better plan to switch to at most injecting actor-refs into rest-beans...

I'm just throwing ideas out there, I'm really tired and should sleep on it.
WDYT, Jonas?



 

Max Afonov

unread,
May 17, 2010, 5:36:29 PM5/17/10
to akka...@googlegroups.com
On Mon, May 17, 2010 at 17:28, Viktor Klang <viktor...@gmail.com> wrote:
> skeptical at having the Actor class having the Jersey annotations at all

IMHO this is only useful when an actor needs to take HTTP messages,
convert them and send them to itself. If there's a way for any old
servlet or Jersey resource to ! or !! an arbitrary actor, then the
class itself doesn't have to be an actor to begin with. If nothing
else, this yields cleaner code.

Jonas Bonér

unread,
May 18, 2010, 1:47:28 AM5/18/10
to akka...@googlegroups.com
On 17 May 2010 23:28, Viktor Klang <viktor...@gmail.com> wrote:


On Mon, May 17, 2010 at 11:18 PM, Jonas Bonér <jo...@jonasboner.com> wrote:
Ah. Crap. Thanks for catching this.
Viktor, I think you are right.  
We need tests for this code. 

Yeah, we do. I haven't had much time to think of a solution, but I'm starting to get skeptical at having the Actor class having the Jersey annotations at all, perhaps a better plan to switch to at most injecting actor-refs into rest-beans...

Yeah. Sounds like it.  



--
Jonas Bonér

work:   http://jayway.com
code:   http://akkasource.com
blog:    http://jonasboner.com
twitter: @jboner

Viktor Klang

unread,
May 18, 2010, 3:30:06 AM5/18/10
to akka...@googlegroups.com
On Tue, May 18, 2010 at 7:47 AM, Jonas Bonér <jo...@jonasboner.com> wrote:


On 17 May 2010 23:28, Viktor Klang <viktor...@gmail.com> wrote:


On Mon, May 17, 2010 at 11:18 PM, Jonas Bonér <jo...@jonasboner.com> wrote:
Ah. Crap. Thanks for catching this.
Viktor, I think you are right.  
We need tests for this code. 

Yeah, we do. I haven't had much time to think of a solution, but I'm starting to get skeptical at having the Actor class having the Jersey annotations at all, perhaps a better plan to switch to at most injecting actor-refs into rest-beans...

Yeah. Sounds like it.  

I'll see if I can talk to Paul Sandoz and JF about it.
 

Jonas Bonér

unread,
May 18, 2010, 3:31:11 AM5/18/10
to akka...@googlegroups.com
Good. Thanks.
Reply all
Reply to author
Forward
0 new messages