Mobicents + SpringFramework

128 views
Skip to first unread message

David Salvador

unread,
Mar 28, 2014, 10:38:04 AM3/28/14
to mobicent...@googlegroups.com
Hi guys,

I'm having some problems with Mobicents and spring... and maybe you guys can help me. 

Ok here is the problem: 

I'm integrating Kurento Media Server (i need video support, and MMS still does not have video support) with my Mobicents AS, and i need some "bean injection" in order to get access to their api.  

I know this is not a direct problem of Mobicents, but maybe you guys can help me with Spring

If i do this in a standalone project, it works fine: 

final ClassPathXmlApplicationContext  mediaContext = new ClassPathXmlApplicationContext("kmf-media-config.xml");
MediaPipelineFactory mediaPipelineFactory = mediaContext.getBean(MediaPipelineFactory.class);

but when i run it inside an SBB, like as follows: 


public void setSbbContext(SbbContext context) { 
this.sbbContext = (SbbContextExt) context;
if(tracer==null)
{
tracer = sbbContext.getTracer(KurentoSbb.class.getSimpleName());
}
try {
final Context ctx = (Context) new InitialContext().lookup("java:comp/env");
sipActivityContextInterfaceFactory = (SipActivityContextInterfaceFactory) ctx.lookup("slee/resources/jainsip/1.2/acifactory");
sipProvider = (SleeSipProvider) ctx.lookup("slee/resources/jainsip/1.2/provider");
headerFactory = sipProvider.getHeaderFactory();
messageFactory = sipProvider.getMessageFactory();
addressFactory = sipProvider.getAddressFactory();
final ClassPathXmlApplicationContext  mediaContext = new ClassPathXmlApplicationContext("kmf-media-config.xml");
mediaPipelineFactory = mediaContext.getBean(MediaPipelineFactory.class);;
} catch (Throwable e) {
tracer.severe(e.getMessage());
}
}

i got the following error: 

2014-03-28 14:33:49,701 ERROR [javax.slee.SbbNotification[service=ServiceID[name=adverstisement-service,vendor=org.wit.software,version=1.0],sbb=SbbID[name=KurentoSbb,vendor=org.wit.software,version=1.0]].KurentoSbb] (Timer-24) deu erro
javax.naming.NameNotFoundException: resources not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
        at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
        at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
        at org.jnp.server.NamingServer.lookup(NamingServer.java:399)
        at org.jnp.server.NamingServer.lookup(NamingServer.java:399)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
        at org.wit.software.KurentoSbb.setSbbContext(KurentoSbb.java:57)
        at org.mobicents.slee.runtime.sbb.SbbObjectImpl.<init>(SbbObjectImpl.java:124)
        at org.mobicents.slee.runtime.sbb.SbbObjectPoolFactory.makeObject(SbbObjectPoolFactory.java:146)
        at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:1276)
        at org.apache.commons.pool.impl.GenericObjectPool.ensureMinIdle(GenericObjectPool.java:1254)
        at org.apache.commons.pool.impl.GenericObjectPool.access$100(GenericObjectPool.java:179)
        at org.apache.commons.pool.impl.GenericObjectPool$Evictor.run(GenericObjectPool.java:1346)
        at java.util.TimerThread.mainLoop(Timer.java:534)
        at java.util.TimerThread.run(Timer.java:484)


I have all the dependencies in the pom file... Not really sure what I'm doing wrong. 

Cheers,
David 


David Salvador

unread,
Mar 28, 2014, 12:21:53 PM3/28/14
to mobicent...@googlegroups.com
Soz... i printed here the wrong error: 

The correct error i get is : 

java.lang.NoClassDefFoundError: org/springframework/context/support/ClassPathXmlApplicationContext
        at org.wit.software.KurentoSbb.onServiceStartedEvent(KurentoSbb.java:52)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:616)
        at org.mobicents.slee.runtime.sbbentity.SbbEntityImpl.invokeEventHandler(SbbEntityImpl.java:481)
        at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.routeQueuedEvent(EventRoutingTaskImpl.java:379)
        at org.mobicents.slee.runtime.eventrouter.routingtask.EventRoutingTaskImpl.run(EventRoutingTaskImpl.java:126)
        at org.mobicents.slee.runtime.eventrouter.EventRouterExecutorImpl$EventRoutingTaskStatsCollector.run(EventRouterExecutorImpl.java:73)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassNotFoundException: org.springframework.context.support.ClassPathXmlApplicationContext
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at org.mobicents.slee.container.component.deployment.classloading.URLClassLoaderDomainImpl.findClassLocallyLocked(URLClassLoaderDomainImpl.java:215)
        at org.mobicents.slee.container.component.deployment.classloading.URLClassLoaderDomainImpl.findClass(URLClassLoaderDomainImpl.java:184)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at org.mobicents.slee.container.component.deployment.classloading.URLClassLoaderDomainImpl.loadClass(URLClassLoaderDomainImpl.java:154)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
        ... 12 more


Any help would be much apreciated,
David 


Oliver Jowett

unread,
Mar 28, 2014, 1:21:50 PM3/28/14
to mobicent...@googlegroups.com
On 28 March 2014 16:21, David Salvador <djcsa...@gmail.com> wrote:
java.lang.NoClassDefFoundError: org/springframework/context/support/ClassPathXmlApplicationContext

You have a packaging problem - you must make the Spring classes available to your SBB somehow (package it with your SBB, or add a dependency on a library jar that has it, etc)

Once you have that fixed, you may need to explicitly set the classloader that ClassPathXmlApplicationContext uses.
see e.g. https://developer.opencloud.com/forum/posts/list/1182.page#4853 (which is about a slightly different problem, but shows how to use ClassPathXmlApplicationContext with a specified classloader)

Oliver

Abdul Gafar

unread,
Mar 28, 2014, 2:01:46 PM3/28/14
to mobicent...@googlegroups.com
Hi

It's no goad for handle performance (high transaction in  TPS)

//Gafar




--
You received this message because you are subscribed to the Google Groups "mobicents-public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobicents-publ...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jean Deruelle

unread,
Mar 28, 2014, 4:59:59 PM3/28/14
to mobicents-public
If your intention is just to use SIP and HTTP. SIP Servlets may be a better fit and Spring integration will be probably much easier as it uses the standard war packaging

Jean

David Salvador

unread,
Mar 31, 2014, 5:47:40 AM3/31/14
to mobicent...@googlegroups.com
Hi guys,

Jean, yeah i would prefer to use Servlets, but is one of the requirements of my work is to use Jain Slee. 

Olive: 
You have a packaging problem - you must make the Spring classes available to your SBB somehow (package it with your SBB, or add a dependency on a library jar that has it, etc)

I add the dependencies for Kurento, and they have the dependencies for springframework (and they are downloaded when i make mvn clean install), thats why i don't know why i get this error.

Tnks,
David 

Oliver Jowett

unread,
Mar 31, 2014, 6:15:42 AM3/31/14
to mobicent...@googlegroups.com
On 31 March 2014 10:47, David Salvador <djcsa...@gmail.com> wrote:
 
Olive: 
You have a packaging problem - you must make the Spring classes available to your SBB somehow (package it with your SBB, or add a dependency on a library jar that has it, etc)

I add the dependencies for Kurento, and they have the dependencies for springframework (and they are downloaded when i make mvn clean install), thats why i don't know why i get this error.

Merely having the dependencies available at compile/build time doesn't mean that they're packaged correctly for deployment. The NoClassDefFoundError means that they're not available at runtime, for whatever reason.
Are you packaging the Spring framework with your SBB jar, or are you including it via a library-jar reference? Have you confirmed that the classes are actually present in the DU in the place you expect them to be in?

(I do not know how much of this you are delegating to the Maven build - perhaps the transitive dependencies are not being packaged as you expect?)

Oliver

David Salvador

unread,
Mar 31, 2014, 7:05:19 AM3/31/14
to mobicent...@googlegroups.com
Well... to be honest, i did not understood everything you said, (kind of noob in maven and all this technologies)... I'll try to do my best to explain:

the only thing i have is, in the SBB pom.xml:

    <dependency>
      <groupId>com.kurento.kmf</groupId>
      <artifactId>kmf-media-api</artifactId>
      <version>4.1.0</version>
    </dependency>

from the dependency hierarchy at eclipse i can see that this dependency has inside the Spring framework jars... however, i've also tried to add the dependencies to spring myself:

<dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>4.0.2.RELEASE</version>
      <scope>compile</scope>
    </dependency>
...

Isn't this supposed to package the Spring Framework with the jar ? 

"Have you confirmed that the classes are actually present in the DU in the place you expect them to be in?" - This is the part i did not understood very well, soz

David

Oliver Jowett

unread,
Mar 31, 2014, 7:21:33 AM3/31/14
to mobicent...@googlegroups.com
The output of the build process will be a deployable unit (DU) jar that you will deploy into the SLEE.
Within that deployable unit is a SBB jar that contains your classes and a deployment descriptor describing the SBB, its events, etc.
That SBB jar also needs to contain any (transitive) dependencies that your classes have, except for things that are provided by the SLEE itself or provided by a dependency declared in your SBB's deployment descriptor.

I'm not familiar enough with Maven to specifically help you with how to achieve that, but it is probably a combination of the right maven packaging plugin plus the right <scope> settings on your dependencies.
(compile scope is probably not sufficient)

Oliver

David Salvador

unread,
Mar 31, 2014, 7:32:17 AM3/31/14
to mobicent...@googlegroups.com
Tnks for the help... I'll try a few things to see if i'm "lucky" 

David
Reply all
Reply to author
Forward
0 new messages