JSLEE Discussions
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
java.lang.NoClassDefFoundError
Forum Index » JAIN SLEE Discussions
Author Message
craymond


Joined: 14/05/2009 12:20:49
Messages: 12
Offline

Hi,
I have an SBB that stores a value of an enum as a CMP field. The enum is defined in a separate file eg: State.java. When I try to deploy a service that composes this SBB, I get a java.lang.NoClassDefFoundError for the enum. The deployment jar and the sbb.jar files did not contain the enum class even though it was compiled properly. How can I let the Sbb-jar.xml/deployment-jar.xml know that it has to include the enum class as well. Is it possible to do such a thing? I assume it is, as I saw the ProxySbb do a similar thing using a ProxyRouter POJO. Could someone explain me how this can be achieved.

Thanks,
Cyril
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi Cyril,

You just need to include that .class inside the deployable jar and Rhino will then include it in the classloader of the component. Most likely the ant script is not including that .class.

Bruno

Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
craymond


Joined: 14/05/2009 12:20:49
Messages: 12
Offline

Thanks for the tip Bruno. Am trying to connect to a postgres db via spring and hibernate and hence have included the spring.jar & hibernate.jar files as part of my RootSbb.jar. In my application, one of the RootSbb's event handlers creates a Spring application context as below,

ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "applicationContext.xml", "classpath:dataContext.xml" });

When the above line gets executed, I get a java.lang.NoClassDefFoundError: org/springframework/context/support/ClassPathXmlApplicationContext. The RootSbb.jar contains the spring.jar which contains the class. But why does the class loader fail to locate this? Could you please provide some insight.

Thanks,
Cyril
craymond


Joined: 14/05/2009 12:20:49
Messages: 12
Offline

Hi Bruno,
I was able to fix the error. As mentioned in my earlier posting, the RootSbb's event handler creates an application context. This is a very inefficient model as every incoming INVITE would create a new RootSbb and the event handler would try to create a context for every call. Is there a way to create the context only once at service deployment time and allow all Sbb's to access it?
Was thinking of creating a separate service, which when deployed would create an SBB within which an application context would get created. The context should then be accessible by all other services deployed within the SLEE? Is this possible? Is there a way to create an SBB when a service is deployed?

Could you please guide me here.

Thanks,
Cyril
bsd

[Avatar]

Joined: 22/03/2008 00:37:15
Messages: 355
Location: Cambridge, UK
Offline

Hi Cyril,

So we can keep some records. The first problem was related with the ContextClassloader of the SBB object thread?

In what relates to your initial thoughts, if you don't want to have an additional service and that context applies to all SBB objects, you could minimize the context creating by moving it into sbbPostCreate and/or implement a singleton that returns that object. (Be careful with the caveats with singletons because you'll have an instance per JVM. As you know, Rhino or any other SLEE can be deployed in a cluster, that is in various JVMs.) Another pattern, but I'm not sure if it will be useful here, is to use the ServiceStartedEvent and store the state common to all SBB objects in a common place (eg, NullActivity bound to a known name).

Regarding your solution, yes this is possible. Have a look at the Registrar and Location SIP services included with the SDK. They have a behavior very similar to what you described. This is probably the most elegant solution.

Bruno


Bruno Duarte
Technical Consultant
OpenCloud
[Email] [WWW]
craymond


Joined: 14/05/2009 12:20:49
Messages: 12
Offline

Hi Bruno,
Thanks for the thoughts. The error was due to the external jars not being in the right place. And for the solution for my question, I used the ServiceStartedEvent to create my initial application-related context, created a NullActivity, obtained the ServiceACI from the NullActivity and set the app-related context to the ACI and finally bound the ACI to a JNDI var.

Thanks,
Cyril
 
Forum Index » JAIN SLEE Discussions
Go to:   
Powered by JForum 2.1.8 © JForum Team