Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
laksmi07
Posts: 6
Registered: ‎10-18-2011
My Device: Blackberry Curve 9360
My Carrier: Singtel

Re: Listener belongs to another application module

Yes it is signed with the NFCR key

Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Listener belongs to another application module

if you get the message "Listener belongs to another application module" with this Exception it would seem you have hit this problem and must upgrade your hand held software.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
New Contributor
laksmi07
Posts: 6
Registered: ‎10-18-2011
My Device: Blackberry Curve 9360
My Carrier: Singtel

Re: Listener belongs to another application module

Is there any other workaround?
Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Listener belongs to another application module

Not that I am aware of.

 

Can you post your full source code here please? I'll take a look.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
New Contributor
laksmi07
Posts: 6
Registered: ‎10-18-2011
My Device: Blackberry Curve 9360
My Carrier: Singtel

Re: Listener belongs to another application module

public class TransactionMidlet extends MIDlet implements TransactionListener {

    private com.sun.lwuit.Command backCommand = new com.sun.lwuit.Command("Close");
    String testString = "";
    private SecureElement secureElement;
    private SecureElementManager secureElementManager;

    public void startApp() {
        Display.init(this);
        Form f = new Form("Tranaction Listener");
        f.setBackCommand(backCommand);
        f.addCommand(backCommand);
        f.addCommandListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
                try {
                    destroyApp(true);
                } catch (MIDletStateChangeException ex) {
                    testString += "MIDletStateChangeException: " + ex.getMessage();
                }
            }
        });

        TextArea textArea = new TextArea();
        try {
            secureElementManager = SecureElementManager.getInstance();

            secureElement = secureElementManager.getSecureElement(SecureElement.EMBEDDED);
            registerTranasctionListener();

        } catch (NFCException ex) {
            testString += "NFCException: " + ex.getMessage();
        } catch (ControlledAccessException ex) {
            testString += "\nControlledAccessException: " + ex.getMessage();
        }
        textArea.setText(testString);
        f.addComponent(textArea);
        f.show();
    }

    private void registerTranasctionListener() throws NFCException {
        if (secureElement != null) {
            secureElement.addTransactionListener(this);
        }
    }

    public void onTransactionDetected(byte[][] bytes) {
        testString += ("\nTransactionDetected: " + HexUtil.convertByteArrayToHexString(bytes[0]));
    }

    protected void pauseApp() {
    }

    protected void destroyApp(boolean bln) throws MIDletStateChangeException {
        notifyDestroyed();
    }
}

This is my code... The MIDlet doesnt do anything other than registering and listening to any transaction

Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Listener belongs to another application module

Hi

 

I believe the problem is that you are trying to use the EMBEDDED secure element. NFCR does not allow access to this secure element.You need to request a special signing key direct from your RIM business/account representative for this to be discussed. The key is called RESE.

Without signing with this special key you will get a ControlledAccessException.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
New Contributor
laksmi07
Posts: 6
Registered: ‎10-18-2011
My Device: Blackberry Curve 9360
My Carrier: Singtel

Re: Listener belongs to another application module

Hi

Okay so also an applet that can perform transactions needs to be installed in the secure element to trigger the TransactionListener? Form the API that is waht I understood
Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Listener belongs to another application module

Yes that's correct.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.
New Contributor
laksmi07
Posts: 6
Registered: ‎10-18-2011
My Device: Blackberry Curve 9360
My Carrier: Singtel

Re: Listener belongs to another application module

Thanks for the help :smileyhappy:
Please use plain text.
BlackBerry Development Advisor (Retired)
mwoolley
Posts: 571
Registered: ‎06-25-2010
My Device: Z10
My Carrier: Vodafone

Re: Listener belongs to another application module

[ Edited ]

You're very welcome :-)

 

For others experiencing difficulties, let's summarise:

 

1. To access the EMBEDDED secure element, your application must be signed with the special signing key RESE available on a restricted basis on application from your RIM representative

2. To access the SIM secure element, your application must be signed with the special signing key NFCR available on a restricted basis on application from your RIM representative

3. There's a known issue which is fixed at 7.0.0.337, bundle 1603 (9900) or 7.0.0.360, bundle 1699 (9360) which may cause ControlledAccessException with the message "Listener belongs to another application module" when your application gets split into multiple sibling cod files. A possible workaround is to implement your listener interface (e.g. TrabsactionListener or DetectionListener)  in your UiApplication sub-class.

 

Look out for further NFC development articles in the resource centre by the way. The first "primer" for those who are new to NFC is here: http://supportforums.blackberry.com/t5/Java-Development/NFC-Primer-for-Developers/ta-p/1334857 and it includes a section on code signing requirements.

--------------------------------------------------------------------------------------------
Feel free to press the like button on the right side if you liked my attempts to help :-)
And please mark posts as solved if you think I found the solution or set you on its path. Thanks!
Follow me on Twitter: @mdwrim
Please use plain text.