RestComm / jss7

RestComm Java SS7 Stack and Services
http://www.restcomm.com/
GNU Affero General Public License v3.0
181 stars 218 forks source link

lookup from standalone remote client does not work #129

Closed vetss closed 6 years ago

vetss commented 8 years ago

This is report from community:

Hi guys, I've faced with the issue: I've tried to lookup CAP and MAP providers from standalone app (JNDI names were moved to global namespace), but I got NullPointerException when tried to add listeners to the providers. The fact is that all provider's fields are transient and are not serialized. May be I missed something, can you explain me how I can lookup providers? Thanks.

here is my code snapshot: capProvider = (CAPProvider)ctx.lookup("restcomm/ss7/cap"); if (capProvider != null) { logger.info("!!!NOT NULL"); CAPParameterFactory factory = capProvider.getCAPParameterFactory(); if (factory != null) { logger.debug("FACTORY NOT NULL"); factory.createAChChargingAddress(1); } else { logger.debug("FACTORY NULL"); } } else { logger.info("!!!NULL"); } In logs I see: !!!NOT NULL FACTORY NULL

I've tried to avoid "serialization" issues by removing transient modifier from providers fields(CAP, MAP, TCAP). Now I can add listener to CAP and MAP providers, but operation sending still fails due to some TCAP provider fields, like the scheduled task executor, are not serializable, and when TCAP dialog tries to use executor NullPointerException are thrown. I believe this can not be, that lookup from standalone remote client does not work, otherwise the same issue would have been raised by someone earlier.

I cannot event send a message. May be there is some misunderstanding, because I'm not able to instantiate providers correctly: in guide it is mentioned, that I can lookup providers and it ready to use, but I cannot undastand why it may be ready for use, while all important provider fields are transient and cannot be serialized. Thus when I lookup the provider, all fields like a lists of listeners, dialogs, stack are null and they cannot be used. For example, I lookup CAPProvider and ther add a listener via addDialogListener(): I get NullPointerException here, because list of the listeners are transient and it is null in lookuped object. Before this, I used standalone initializing of jSS7 stack and all were fine, but now I would like to use JBoss and JNDI, and I do not understand how it can be done.

satanatoly commented 6 years ago

For JBoss and JNDI solution for usage example you can refer to code from jain-slee.ss7 ResourceAdaptor Here is example for CAP https://github.com/RestComm/jain-slee.ss7/blob/087ed637ad11765a4763cfc3a8670a229922827c/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPResourceAdaptor.java#L323 note that JNDI lookup name in this case is "java:/restcomm/ss7/cap"