Issue integrating Akka and Spring

467 views
Skip to first unread message

geekinsf

unread,
Apr 4, 2011, 7:00:09 PM4/4/11
to Akka User List
Hello,

I'm using Spring 3.0 and Akka 1.0 . I'm running into an issue when
integrating Akka with Spring following the documentation available
here: http://doc.akka.io/spring-integration.

The error that I'm getting is:
====================
Exception in thread "main"
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 7 in XML document from class path resource [spring-config.xml] is
invalid; nested exception is org.xml.sax.SAXParseException: cvc-
complex-type.2.4.c: The matching wildcard is strict, but no
declaration can be found for element 'akka:untyped-actor'.
at
org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:
396)
..
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The
matching wildcard is strict, but no declaration can be found for
element 'akka:untyped-actor'.
at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)
... 19 more

My spring-config.xml is:
=================
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:akka="http://akka.io/schema/akka"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://akka.io/schema/akka http://akka.io/akka-1.0.xsd">

<akka:untyped-actor id="greeting" autostart="false"
implementation="example.HelloWorld" scope="prototype" timeout="1000"/>

</beans>

My bean source code is:
==================
public class HelloWorld extends UntypedActor {

public void onReceive(final Object from) {
getContext().replySafe(sayHelloWorldFrom((String) from));
}

public String sayHelloWorldFrom(String from) {
String result = "Hello, world, from " + from;
System.out.println(result);
return result;
}

public static void main(String args[]){
ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("spring-config.xml");
ActorRef actorRef = (ActorRef) context.getBean("greeting");
actorRef.sendRequestReply("John");
}


I'm new to Akka and appreciate your help.

Thank you!

√iktor Ҡlang

unread,
Apr 4, 2011, 7:07:57 PM4/4/11
to akka...@googlegroups.com
Hi Geekinsf,


If you're using Akka 1.0 you should look at the docs for 1.0, from the main page of doc.akka.io:

1.0 documentation:

This documentation covers the latest release ready code in 'master' branch in the repository.
If you want the documentation for the 1.0 release you can find it here.


Since you are not the first one who have missed this I apologize,
if someone find a better strategy on managing the docs, please let yourselves be known.


If you want to use autostart, I think it is new for 1.1-M1, which will be out in a couple of minutes, so hold out for it.

Cheers,


--
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,
Director of Research and Development
Scalable Solutions

Code:   github.com/viktorklang
Follow: twitter.com/viktorklang
Read:   klangism.tumblr.com

Martin

unread,
Apr 13, 2011, 3:45:06 AM4/13/11
to akka...@googlegroups.com
Hi Viktor,

I ran into the same problem as described above (and even after reading the documentation).

Previously I got the same error as stated in this post: http://groups.google.com/group/akka-user/browse_thread/thread/4fc3e47c48825242 ( Unable to locate Spring NamespaceHandler for XML schema namespace [http://akka.io/schema/akka]). I get rid of this error by using the following applicationContext.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:task="http://www.springframework.org/schema/task"
            http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
            http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
            http://akka.io/schema/akka=akka.spring.AkkaNamespaceHandler
            http://akka.io/akka-1.0-RC3.xsd=WEB-INF/spring/akka-1.0-RC3.xsd">

        <akka:untyped-actor id="myActor"
            implementation="com.mycoop.server.Actor"
            scope="singleton" autostart="true" >
        </akka:untyped-actor>
</beans>
 After getting rid of the namespace exception now I have the problem with Spring complaining about the complex type stuff.

Is there any (full) spring-akka example around there? The documentation is a bit poor on this topic :(


Thanks in advance,

Martin
 

√iktor Ҡlang

unread,
Apr 13, 2011, 4:17:58 AM4/13/11
to akka...@googlegroups.com

I'm not a Spring user so I wouldn't know, but having had to deal with XML a lot of times I assume that you need to point the akka namespace to an actual xsd, so check the schema URL for available xsds (for your version of akka)

Does that help?

Peter Veentjer

unread,
Apr 13, 2011, 4:22:24 AM4/13/11
to akka...@googlegroups.com
I'll  look into it.

2011/4/13 √iktor Ҡlang <viktor...@gmail.com>

Martin

unread,
Apr 13, 2011, 4:44:42 AM4/13/11
to akka...@googlegroups.com
The XSD http://akka.io/akka-1.0-RC3.xsd exists - I can view it in my browser. It is included in my akka-spring artifact I load with maven and I put it in my WEB-INF/spring- directory and referenced it (http://akka.io/akka-1.0-RC3.xsd=WEB-INF/spring/akka-1.0-RC3.xsd). I tried all paths that should be possible but the error stayed the same.

I must confess I'm a bit lost at the moment...

Peter Veentjer

unread,
Apr 13, 2011, 5:21:23 AM4/13/11
to akka...@googlegroups.com
Hi Martin,

I'm setting up a small project that relies on Akka 1.0 and does a basic actor initialization through the Spring functionality. I'm also running into some problems.

<?xml version="1.0" encoding="UTF-8"?>
       xmlns:akka="http://akka.io/schema/akka"
       xsi:schemaLocation="

    <akka:untyped-actor id="myActor"
                        implementation="DummyActor"
                        scope="singleton"
                        autostart="false">
    </akka:untyped-actor>
</beans>

And I get the following error:

11:18:21.811 [main] DEBUG o.s.b.f.xml.PluggableSchemaResolver - Couldn't find XML schema [http://akka.io/akka-1.0.xsd]: class path resource [akka/spring/akka-1.1-SNAPSHOT.xsd]
java.io.FileNotFoundException: class path resource [akka/spring/akka-1.1-SNAPSHOT.xsd] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141) ~[spring-core.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.xml.PluggableSchemaResolver.resolveEntity(PluggableSchemaResolver.java:114) ~[spring-beans.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.xml.DelegatingEntityResolver.resolveEntity(DelegatingEntityResolver.java:85) [spring-beans.jar:3.0.0.RELEASE]
at org.springframework.beans.factory.xml.ResourceEntityResolver.resolveEntity(ResourceEntityResolver.java:74) [spring-beans.jar:3.0.0.RELEASE]
at com.sun.org.apache.xerces.internal.util.EntityResolverWrapper.resolveEntity(EntityResolverWrapper.java:107) [na:1.6.0_22]
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.resolveEntity(XMLEntityManager.java:1100) [na:1.6.0_22]
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.resolveDocument(XMLSchemaLoader.java:595) [na:1.6.0_22]
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2432) [na:1.6.0_22]
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1782) [na:1.6.0_22]
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705) [na:1.6.0_22]
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400) [na:1.6.0_22]
So it is very strange that even though I'm using Akka 1.0 in this example, somehow a reference to Akka 1.1-SNAPSHOT is used. 

I'll keep you posted.


On Wed, Apr 13, 2011 at 10:44 AM, Martin <darkes...@gmail.com> wrote:
The XSD http://akka.io/akka-1.0-RC3.xsd exists - I can view it in my browser. It is included in my akka-spring artifact I load with maven and I put it in my WEB-INF/spring- directory and referenced it (http://akka.io/akka-1.0-RC3.xsd=WEB-INF/spring/akka-1.0-RC3.xsd). I tried all paths that should be possible but the error stayed the same.

I must confess I'm a bit lost at the moment...

Peter Veentjer

unread,
Apr 13, 2011, 5:25:40 AM4/13/11
to akka...@googlegroups.com
PS:

Can you try it using the following template?

<?xml version="1.0" encoding="UTF-8"?>
       xmlns:akka="http://akka.io/schema/akka"
       xsi:schemaLocation="

    <akka:untyped-actor id="myActor"
                        implementation="DummyActor"
                        scope="singleton"
                        autostart="true">
    </akka:untyped-actor>
</beans>

Although you get a 'java.io.FileNotFoundException: class path resource [akka/spring/akka-1.1-SNAPSHOT.xsd] cannot be opened because it does not exist', the example still works on my machine. So at least you should be able to continue.

Martin

unread,
Apr 13, 2011, 5:34:55 AM4/13/11
to akka...@googlegroups.com
Thanks for this information....

There is another point which I don't understand at all:

if I have a look at the Spring schemes the url structure is like this:
 - xmlns:jdbc="http://www.springframework.org/schema/jdbc" (namespace points to a list where the XSDs are located)
 - http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd (namespace url and actual url of the XSD)

The namespace of akka on the other hand is like this:
 - xmlns:akka="http://akka.io/schema/akka" (this points to a non existing url; I get a 404)
 - http://akka.io/schema/akka http://akka.io/akka-1.0-RC3.xsd (non existing NS and existing XSD)

So, why is the namespace not set to an existing location, like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:akka="http://akka.io/schema"
    xsi:schemaLocation="
            http://www.springframework.org/schema/beans
            http://akka.io/schema/
            http://akka.io/schema/akka-1.0-RC3.xsd">

This would match the Spring examples. Any hints on that?


Cheers,

Martin

Martin

unread,
Apr 13, 2011, 5:41:37 AM4/13/11
to akka...@googlegroups.com
I tried it, but this does not work. Anyhow I get an other exception, not yours
11:38:20.411 [main] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 18 in XML document from ServletContext resource [/WEB-INF/spring/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'akka:untyped-actor'.
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:124) ~[org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:93) ~[org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) ~[org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) ~[org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) ~[org.springframework.context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276) ~[org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197) ~[org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) [org.springframework.web-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4135) [catalina.jar:6.0.29]
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4630) [catalina.jar:6.0.29]
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791) [catalina.jar:6.0.29]
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771) [catalina.jar:6.0.29]
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546) [catalina.jar:6.0.29]
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:905) [catalina.jar:6.0.29]
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:740) [catalina.jar:6.0.29]
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:500) [catalina.jar:6.0.29]
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277) [catalina.jar:6.0.29]
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321) [catalina.jar:6.0.29]
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) [catalina.jar:6.0.29]
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053) [catalina.jar:6.0.29]
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:785) [catalina.jar:6.0.29]
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045) [catalina.jar:6.0.29]
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:445) [catalina.jar:6.0.29]
        at org.apache.catalina.core.StandardService.start(StandardService.java:519) [catalina.jar:6.0.29]
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:710) [catalina.jar:6.0.29]
        at org.apache.catalina.startup.Catalina.start(Catalina.java:581) [catalina.jar:6.0.29]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0_22]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) ~[na:1.6.0_22]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0_22]
        at java.lang.reflect.Method.invoke(Method.java:597) ~[na:1.6.0_22]
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) [bootstrap.jar:6.0.29]
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) [bootstrap.jar:6.0.29]

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'akka:untyped-actor'.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:417) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3182) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1927) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:705) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:400) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2755) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:235) ~[na:1.6.0_22]
        at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:284) ~[na:1.6.0_22]
        at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388) ~[org.springframework.beans-3.0.5.RELEASE.jar:3.0.5.RELEASE]
        ... 37 common frames omitted

Peter Veentjer

unread,
Apr 13, 2011, 5:43:43 AM4/13/11
to akka...@googlegroups.com
Can you upgrade to the Akka 1.0 release instead of the 1.0-RC3? 

--

Martin

unread,
Apr 13, 2011, 5:51:54 AM4/13/11
to akka...@googlegroups.com
Do you mean 1.0-SNAPSHOT? I cannot find a 1.0 only release in your repo.

And do I have to add akka-spring? If I have to RC3 is the latest available version.

Peter Veentjer

unread,
Apr 13, 2011, 5:56:01 AM4/13/11
to akka...@googlegroups.com
Hi Martin,

Akka 1.0 has been released quite some time ago. 

Are you using Maven to build and what are the repo's you are using?

I have downloaded the Akka 1.0 distribution from the website:


And based on the 1.0 release I created the example.

On Wed, Apr 13, 2011 at 11:51 AM, Martin <darkes...@gmail.com> wrote:
Do you mean 1.0-SNAPSHOT? I cannot find a 1.0 only release in your repo.

And do I have to add akka-spring? If I have to RC3 is the latest available version.

Martin

unread,
Apr 13, 2011, 6:54:49 AM4/13/11
to akka...@googlegroups.com
So, I looked into the wrong repo (http://www.scalablesolutions.se/akka/repository) where only a 1.0-SNAPSHOT was listed. But my nexus used akka.io/repository so I tried it with 1.0 and your sample applicationContext.xml

I got the same exception and the Actor started properly. Only my Unit Tests are unable to connect to the actor at the moment.


thanks :)

Martin

Peter Veentjer

unread,
Apr 13, 2011, 7:20:21 AM4/13/11
to akka...@googlegroups.com
Ok, good that it works.

How are you loading the actor(ref) in the test?

I'll make a ticket for the strange issue with unexpected reference to Akka-1.1-SNAPSHOT even though 1.0 is used.

Martin

unread,
Apr 13, 2011, 7:35:57 AM4/13/11
to akka...@googlegroups.com
So, the configuration is working, my actor is starting - but the port I specified is not opened. My config is as follows:

<akka:untyped-actor id="myActor"

            implementation="com.mycoop.server.Actor"
            scope="singleton" autostart="true" >
            <akka:remote host="myhost" port="12345" managed-by="server" service-name="keyvaluepersister-service"/>
</akka:untyped-actor>
If I look with netstat the port is not present and my client tests are failing. Do I have an error in my config?

Peter Veentjer

unread,
Apr 13, 2011, 9:45:46 AM4/13/11
to akka...@googlegroups.com
This is where my actor knowledge is failing (I'm mostly working on the STM stuff..)..

Is there someone who can see what is happening here?

--

√iktor Ҡlang

unread,
Apr 13, 2011, 11:15:20 AM4/13/11
to akka...@googlegroups.com

Search the ML, was asked within the last month. (Typing on phone)

Cheers

Martin

unread,
Apr 14, 2011, 4:43:25 AM4/14/11
to akka...@googlegroups.com
Hi,

I searched the ML for my problem and the only matching theme I found was "akka-spring, remote server not started".

But I don't found a solution for my problem in this conversation.

Regards,

Martin

√iktor Ҡlang

unread,
Apr 14, 2011, 8:36:49 AM4/14/11
to akka...@googlegroups.com

It will not start servers. It used to do that back when we allowed multiple servers.

Atleast that's what I remember from the last discussion of it on the ML. (On vacation so too bulky to find link and paste it in on the cellphone)

Hope this helps

Happy hAkking!

Bruce Mitchener

unread,
Apr 14, 2011, 8:52:23 AM4/14/11
to akka...@googlegroups.com

√iktor Ҡlang

unread,
Apr 14, 2011, 9:08:00 AM4/14/11
to akka...@googlegroups.com
Oh, thanks for the help Bruce, I managed to get myself to a computer, I think I'm referring this this one:

http://groups.google.com/group/akka-user/browse_thread/thread/1937e4a6c936e1cf/bb766f9aa9b880df?lnk=gst&q=spring+port%3D#bb766f9aa9b880df

Martin

unread,
Apr 18, 2011, 4:54:29 AM4/18/11
to akka...@googlegroups.com
Hi,

and thanks for the links you have provided. Both cover this topic - but how I actually have to start the server in my spring environment is not covered ;) (or maybe I just don't get it )

Cheers,
Martin

√iktor Ҡlang

unread,
Apr 18, 2011, 5:08:53 AM4/18/11
to akka...@googlegroups.com
On Mon, Apr 18, 2011 at 10:54 AM, Martin <darkes...@gmail.com> wrote:
Hi,

and thanks for the links you have provided. Both cover this topic - but how I actually have to start the server in my spring environment is not covered ;) (or maybe I just don't get it )

You do that in your akka.conf:

https://github.com/jboner/akka/blob/master/config/akka-reference.conf#L136

(Don't forget to enable "remote" in enabled-modules)  (This is if you're using the Microkernel.)
Otherwise you can create your own AkkaLoader, there's an example for Servlet Containers here:

https://github.com/jboner/akka-modules/blob/master/akka-kernel/src/main/scala/akka/servlet/Initializer.scala

Does that help?

Happy hAkking!
 

Cheers,

Martin

--
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.



--

Martin

unread,
Apr 19, 2011, 3:06:50 AM4/19/11
to akka...@googlegroups.com
Hi,

so, I got Akka starting (nice screen art btw) and the activator was also initialized.

But I cannot connect with a client to the server.

What have I done:
  • added remote to enabled-modules in akka.conf
  • added hostname and port in remote/server section
  • added the Initializer class as found on the link to my project and referenced it in my web.xml
Any hints for me?

Cheers,
Martin

√iktor Ҡlang

unread,
Apr 19, 2011, 3:46:59 AM4/19/11
to akka...@googlegroups.com
On Tue, Apr 19, 2011 at 9:06 AM, Martin <darkes...@gmail.com> wrote:
Hi,

so, I got Akka starting (nice screen art btw) and the activator was also initialized.

But I cannot connect with a client to the server.

Define "cannot" connect. And how are you attempting to connect. Have you've started remoting on the node you're trying to connect?
 

What have I done:
  • added remote to enabled-modules in akka.conf
  • added hostname and port in remote/server section
  • added the Initializer class as found on the link to my project and referenced it in my web.xml
Any hints for me?


Cheers,
Martin

--
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.

Martin

unread,
Apr 19, 2011, 5:02:00 AM4/19/11
to akka...@googlegroups.com
Hi,

I'll try to clarify the situation a bit =)

On client side we have a client class with some methods. The following are used to connect to the server and to send objects:

public static void setActorReferenceFrom (String host, Integer port) {
    Client.actorRef = Actors.remote().actorFor(Main.SERVICE_NAME, host, port);
}

public static Object sendRequest(Request request) {
[...]
    obj = Client.actorRef.sendRequestReply(request);
[...]
    return obj;
}

public static void sendObject(SpecialObject o) {
[...]
    Client.actorRef.sendOneWay(o);
[...]
}

The Actor class has the onReceive method:

public void onReceive(Object obj) throws Exception {
        System.err.println("Received something");
        if (obj instanceof SpecialObject) {
            RequestHandler.writeToStore((SpecialObject) obj);
        } else if (obj instanceof Request) {
            try {
                this.getContext()
                        .replyUnsafe(this.handleRequest((Request) obj));
            } catch (Exception e) {
                System.out.println("Actor onReceive(): " + e);
                this.getContext().replyUnsafe(new ErrorResponse(e));
            }
        }
    }

The Actor is bundled in an WebApplicationArchive with Spring. There we have a akka.conf  which is filled like you proposed it (enabled-modules, port, hostname).

In applicationContext.xml I provided the Actor as untyped-actor:
<akka:untyped-actor id="myActor"
    implementation="com.unister.semweb.keyvaluepersister.server.Actor"
    scope="singleton" autostart="true" >
    <akka:remote host="hostname" port="12345" managed-by="server" service-name="my-service"/>
</akka:untyped-actor>

As provided by your link I added the Initializer class

class Initializer extends ServletContextListener {
   lazy val loader = new AkkaLoader

   def contextDestroyed(e: ServletContextEvent): Unit =
     loader.shutdown

   def contextInitialized(e: ServletContextEvent): Unit =
     loader.boot(true, new BootableActorLoaderService with BootableRemoteActorService)
}

This class is started as listener-class in web.xml:
<listener>
    <listener-class>akka.servlet.Initializer</listener-class>
</listener>

With the Actor started and the running Akka-server (netstat shows the port, I can connect with telnet) I try to run a TestCase which looks like this:

Client.setActorReferenceFrom("hostname", 12345);
for(i=1...100){
    Client.actorRef.sendOneWay(new SpecialObject("a1b2c3"+i));
}
Object url = Client.sendRequest(new Request(
                        Request.Type.GET_URL, "a1b2c38"));

Nothing happens on the test at first, the loop runs fine without any exceptions but the onReceive method in the actor does not do anything (should give a sysout).

The request is initialized (The request object has a sysout also) but there is a huge stacktrace after 5 minutes "nothing"....

More Informations? ;)

√iktor Ҡlang

unread,
Apr 19, 2011, 5:05:54 AM4/19/11
to akka...@googlegroups.com
Have you've started the remote on the client?

--
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.

Martin

unread,
Apr 19, 2011, 5:37:15 AM4/19/11
to akka...@googlegroups.com
I don't know what you mean...

Adding remote-module to the akka.conf on client side?

√iktor Ҡlang

unread,
Apr 19, 2011, 5:41:54 AM4/19/11
to akka...@googlegroups.com
On Tue, Apr 19, 2011 at 11:37 AM, Martin <darkes...@gmail.com> wrote:
I don't know what you mean...

Adding remote-module to the akka.conf on client side?

remote.start("0.0.0.0", 666) if you're not running your client as a microkernel node.
 

--
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.

Martin

unread,
Apr 19, 2011, 6:03:17 AM4/19/11
to akka...@googlegroups.com
I added the start to the Client class:

public static void setActorReferenceFrom (String host, Integer port) {
        Actors.remote().start(host, port);

        Client.actorRef = Actors.remote().actorFor(Main.SERVICE_NAME, host, port);
}

but the tests still doing nothing....

√iktor Ҡlang

unread,
Apr 19, 2011, 6:06:24 AM4/19/11
to akka...@googlegroups.com

The remote.start is the local address you want to bind to, not the remote address.

Every Akka node has outbound connections and a host/port for inbound connections.

Does that help?
 

--
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.

Martin

unread,
Apr 19, 2011, 7:01:27 AM4/19/11
to akka...@googlegroups.com
Actor and Client are on the same machine, so it should be the same hostname I guess ?

√iktor Ҡlang

unread,
Apr 19, 2011, 7:16:55 AM4/19/11
to akka...@googlegroups.com

Yes, use 0.0.0.0 or localhost

On Apr 19, 2011 1:01 PM, "Martin" <darkes...@gmail.com> wrote:
> Actor and Client are on the same machine, so it should be the same hostname
> I guess ?
>

Martin

unread,
Apr 19, 2011, 7:44:33 AM4/19/11
to akka...@googlegroups.com
Still nothing happens. The testcase is terminating after 8 seconds with the following stacktrace:
java.lang.StackOverflowError
    at java.lang.System.getProperty(System.java:647)
    at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:67)
    at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:32)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.io.PrintWriter.<init>(PrintWriter.java:78)
    at java.io.PrintWriter.<init>(PrintWriter.java:62)
    at akka.AkkaException.toString(AkkaException.scala:28)
    at java.lang.String.valueOf(String.java:2826)
    at java.io.PrintWriter.println(PrintWriter.java:710)
    at java.lang.Throwable.printStackTrace(Throwable.java:509)
    at akka.AkkaException.toString(AkkaException.scala:28)
    at java.lang.String.valueOf(String.java:2826)
  
The last 4 lines are repeated several times...

√iktor Ҡlang

unread,
Apr 19, 2011, 7:51:07 AM4/19/11
to akka...@googlegroups.com

What version are you using? You might be bitten by a bug that is fixed in master.
However, it's just a symptom of another problem, but I recommend trying to use the current master and see if that gives you a better error message.

Does that help?
 

--
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.

Martin

unread,
Apr 19, 2011, 7:55:23 AM4/19/11
to akka...@googlegroups.com
Currently I use 1.1-M1... I'll try to check out the sc...

√iktor Ҡlang

unread,
Apr 19, 2011, 7:56:21 AM4/19/11
to akka...@googlegroups.com
On Tue, Apr 19, 2011 at 1:55 PM, Martin <darkes...@gmail.com> wrote:
Currently I use 1.1-M1... I'll try to check out the sc...

Great
 

--
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.

Martin

unread,
Apr 20, 2011, 4:13:37 AM4/20/11
to akka...@googlegroups.com
After struggeling a bit with SBT (hey, why not use maven? ;) ) I build the SNAPSHOT version and here the good news:

everything works like charme (after changing the service name from keyvaluepersister-service to the fully qualified class name of the actor). Maybe you guys could update the akka-spring documentation a bit and add a sample?

Thanks a lot for your help!

Cheers,
Martin

Peter Veentjer

unread,
Apr 20, 2011, 4:21:12 AM4/20/11
to akka...@googlegroups.com
On Wed, Apr 20, 2011 at 10:13 AM, Martin <darkes...@gmail.com> wrote:
After struggeling a bit with SBT (hey, why not use maven? ;) )

I hope this is a rhetorical question ;)
 
I build the SNAPSHOT version and here the good news:

everything works like charme (after changing the service name from keyvaluepersister-service to the fully qualified class name of the actor). Maybe you guys could update the akka-spring documentation a bit and add a sample?

Thanks a lot for your help!

Good to hear!
 

Cheers,
Martin
Reply all
Reply to author
Forward
0 new messages