Skip to main content

Using profiles in sbb's

9 replies [Last post]
luis_teixeira
Offline
Joined: 2005-04-04

Hi,

So far I have two problems I havent't been able to mitigate. The first problem is about modifying attributes in a given profile. I can successfully deploy a profile specification, create a profile table and a sample profile. But when I try to modify the attributes initialized in the profile management abstract class, for that sample profile, I always get the exception:

javax.management.InstanceNotFoundException: slee:profileTableName= is not registered.
org.jboss.mx.server.registry.BasicMBeanRegistry.get(BasicMBeanRegistry.java:463)
org.jboss.mx.server.MBeanServerImpl.getMBeanInfo(MBeanServerImpl.java:478)
org.jboss.jmx.adaptor.control.Server.setAttributes(Server.java:151)
org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.updateAttributes(HtmlAdaptorServlet.java:215)
org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.processRequest(HtmlAdaptorServlet.java:77)
org.jboss.jmx.adaptor.html.HtmlAdaptorServlet.doPost(HtmlAdaptorServlet.java:61)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)

The ProfileWriteable MBean attribute is set to true and the attributes I intend to modify have write permission.

The second problem is about attempting to retrieve the attributes of these profiles from within an SBB. In my service I created this method to get a reference to the service profile:

public AsteriskServiceProfileCMP getUserProfile(int clientID) {
try {
ProfileFacility pf;
String profileTableName = (String) myEnv.lookup("ProfileTableName");
System.out.println("Profile table name: " + profileTableName);
pf = getProfileFacility();
ProfileID profile_id = pf.getProfileByIndexedAttribute(profileTableName,
"ClientID", new Integer(clientID));
if (profile_id == null) return null;
AsteriskServiceProfileCMP profile = getAsteriskServiceProfileCMP(profile_id);

return profile;
} catch (Exception e) {
//trace(Level.WARNING, "error looking up profile for " + address, e);
e.printStackTrace();

return null;
}
}

but using the ClientID field to lookup the profile apparently is trouble, as whenever that code is reached, the following exception comes up:

javax.slee.profile.AttributeTypeMismatchException: indexed attribute is of type java.lang.Integer and attribute value is of type java.lang.Integer

- wich is a very interesting one :)

Is there any evidence of what might be wrong?

Luis Teixeira

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mranga
Offline
Joined: 2003-06-06

Hi Luis,

I cant tell what the issue can be off hand. Can you look at the code ( ie. grep through the source code) where the error is generated and set a break point there. It would be great if you can lend a hand debugging it. If you cant do that, any chance you can make a small Service to illustrate the problem as a test case. If you can do this we can use this as a code snippet for our best practices section.

Ranga

luis_teixeira
Offline
Joined: 2005-04-04

Ok, I get the error in the following line, which is in the getUserProfile() method shown in my earlier post:

ProfileID profile_id = pf.getProfileByIndexedAttribute(profileTableName,
"ClientID", new Integer(clientID));

The entire exception is:

10:26:30,328 INFO [STDOUT] javax.slee.profile.AttributeTypeMismatchException: indexed attribute is of type java.lang.Integer and attribute value is of type java.lang.Integer
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.container.profile.SleeProfileManagerImpl.getProfilesByIndexedAttribute(SleeProfileManagerImpl.java:971)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.facilities.ProfileFacilityImpl.getProfileByIndexedAttribute(ProfileFacilityImpl.java:191)
10:26:30,328 INFO [STDOUT] at ptin.asterisk.service.DepositSbb.getUserProfile(DepositSbb.java:241)
10:26:30,328 INFO [STDOUT] at ptin.asterisk.service.DepositSbb.setSbbContext(DepositSbb.java:69)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.SbbObject.setSbbContext(SbbObject.java:183)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.SbbObjectPoolFactory.makeObject(SbbObjectPoolFactory.java:107)
10:26:30,328 INFO [STDOUT] at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:771)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.SbbEntity.assignSbbObject(SbbEntity.java:1257)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.SbbEntity.(SbbEntity.java:307)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.SbbEntityFactory.getSbbEntity(SbbEntityFactory.java:177)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.EventRouterImpl.routeTheEvent(EventRouterImpl.java:714)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.EventRouterImpl.access$1(EventRouterImpl.java:599)
10:26:30,328 INFO [STDOUT] at org.mobicents.slee.runtime.EventRouterImpl$EventExecutor.run(EventRouterImpl.java:102)
10:26:30,328 INFO [STDOUT] at EDU.oswego.cs.dl.util.concurrent.QueuedExecutor$RunLoop.run(QueuedExecutor.java:88)
10:26:30,328 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)

The clientID variable contains the value 0, which is set upon deployment of the service profile. I use it as a key for the profile. profileTableName contains the name of the profile table holding the profile I wish to retrieve, and its name is successfully retrieved from JNDI.

Luis.

alexandrem
Offline
Joined: 2005-10-19

Hey!

I've been working on this error, I got to the line where the exception is thrown (SleeProfileManager.java:1434):

[b]if (!ClassUtils.getPrimitiveTypeFromClass( attributeValue.getClass().getName()).equals(classType))[/b]

I guess the error is that a Class (e.g. Integer) is being compared with the primitive type of the attribute, and that will never be true.. It will always fail because Integer != int, Boolean != boolean, etc... Since getProfileByIndexedAttribute requires an Object, values like int can't be passed as attributeValue.

My question is: Is it supposed to be like this? Why?

I got a quick-fix to this issue, by replacing it by:

[b]if ( !ClassUtils.getPrimitiveTypeFromClass( attributeValue.getClass().getName()).equals( ClassUtils.getPrimitiveTypeFromClass( classType ) ) )[/b]

Seems to make more sense to me, since we're now comparing the primitive types of both, instead of one primitive type vs one Class. I don't think this will have any collateral damages, but I'm not sure. Since Jean, Ivelin and M. Ranganathan are the authors of this class, I'd like to hear from you.

BTW: I've ran the TCK tests on this change and it works "fine"... "fine" because I'm having problems with the ProfileSecurityTest, running several consecutive tests, sometimes it passes, sometimes it doesn't... even with the unmodified version. Is there any special configuration for it?

Stack Trace:
com.opencloud.sleetck.lib.TCKTestErrorException: Unexpected roll back. event=TCKResourceEvent: type=com.opencloud.sleetck.lib.resource.events.TCKResourceEventX.X1,oid=44,message=com.opencloud.sleetck.lib.resource.events.TCKResourceEventX.X1,activity=TCKActivity: id=TCKActivityID: name=com.opencloud.sleetck.lib.testsuite.profiles.profilesbbsecurity.ProfileSbbSecurityTest, object-id=26;aci=org.mobicents.slee.runtime.ActivityContextInterfaceImpl@15458df at
com.opencloud.sleetck.lib.sbbutils.BaseTCKSbb.sbbRolledBack(Unknown Source) at
org.mobicents.slee.runtime.SbbObject.sbbRolledBack(SbbObject.java:462) at
org.mobicents.slee.runtime.EventRouterImpl.handleSbbRolledBack(EventRouterImpl.java:855) at
org.mobicents.slee.runtime.EventRouterImpl.routeTheEvent(EventRouterImpl.java:1383) at
org.mobicents.slee.runtime.EventRouterImpl.access$100(EventRouterImpl.java:81) at
org.mobicents.slee.runtime.EventRouterImpl$EventExecutor.run(EventRouterImpl.java:176) at
EDU.oswego.cs.dl.util.concurrent.QueuedExecutor$RunLoop.run(QueuedExecutor.java:88) at
java.lang.Thread.run(Thread.java:534)

Best Regards,
Alexandre Mendonça

mranga
Offline
Joined: 2003-06-06

Hi

Your fix makes sense, if Jean does not have comments, please commit it.

Yes the TCK tests for profiles are flaky. There are some race conditions which cause the test to fail intermittently. If you can investigate this, we can post a challenge to the TCK.

Ranga

deruelle_jean
Offline
Joined: 2003-06-24

Hi,

It looks like a bug indeed. You can commit your fix.

Jean

alexandrem
Offline
Joined: 2005-10-19

Hi,

Ok. Just waiting to get developer status so I can submit it.

Best regards,
Alexandre Mendonça

ivelin
Offline
Joined: 2003-07-13

Alex, did you try to commit? I haven't seen a notification yet.

Ivelin

alexandrem
Offline
Joined: 2005-10-19

Hello Ivelin.

Yes, I've commited it to CVS... I guess. The versions I'm getting now include it, at least.

Alexandre Mendonça

ivelin
Offline
Joined: 2003-07-13

Thank you, Alex. I missed it somehow.

Ivelin