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

BlackBerry Push Development

Reply
Contributor
vvenu88
Posts: 24
Registered: ‎06-16-2011
My Device: Blackberry Z10
Accepted Solution

java.lang.IllegalStateException: no application instance during push registration

Hi,

When I am trying to register for Push through the following code I am getting the exception

"java.lang.IllegalStateException: no application instance".

I am calling the new PushAgent().register(); method from a class which extends UIApplication and implements PushApplication.


 

public class PushAgent {

	private static final String CLASS_NAME = "PushAgent";
	private static final String BPAS_URL = "http://pushapi.eval.blackberry.com";
	private static final String APP_ID = "566777777777777777777777777";	
	private static final byte SERVER_TYPE = PushApplicationDescriptor.SERVER_TYPE_BPAS;
	private static final int CLIENT_PORT = 29993 ;// 4242
	
	public PushAgent(){
		
	}
	
	public void register() {
		try {
			
			ApplicationDescriptor appDescriptor = ApplicationDescriptor.currentApplicationDescriptor();
			
			PushApplicationDescriptor registeredDescriptor = new PushApplicationDescriptor(APP_ID,CLIENT_PORT, BPAS_URL,SERVER_TYPE ,appDescriptor);
			
			PushApplicationStatus pushApplicationStatus = PushApplicationRegistry.getStatus(registeredDescriptor);
			byte status= pushApplicationStatus.getStatus();
			
			Logger.debug(CLASS_NAME, "status "+status );
			
			if(!(status == PushApplicationStatus.STATUS_ACTIVE) ){
				Logger.debug(CLASS_NAME, "requesting for registering the Application for Push " );
				PushApplicationRegistry.registerApplication(registeredDescriptor);
			}else {
				Logger.debug(CLASS_NAME, "Application already registered for push" );
			}
			
		} catch (Exception e) {
			System.out.println("Exception on register() " + e + " " + e.getMessage());
			e.printStackTrace();
		}
	}
}

 Can any one help me where I ma wrong


 

Contributor
vvenu88
Posts: 24
Registered: ‎06-16-2011
My Device: Blackberry Z10

Re: java.lang.IllegalStateException: no application instance during push registration

Can any one help me!

I got struck in the middle and could not proceed.

Contributor
vvenu88
Posts: 24
Registered: ‎06-16-2011
My Device: Blackberry Z10

Re: java.lang.IllegalStateException: no application instance during push registration

solved the issue!!

Actually you need to have BIS plan activated.

Getting the BIS plan solved the issue.

You should not use WIFI connection for registering

Contributor
herahadi
Posts: 27
Registered: ‎02-20-2013
My Device: 9900

Re: java.lang.IllegalStateException: no application instance during push registration

after register success, how do we call the push message reader class? how if i want to show the push message as dialog alert?

 

please help me

New Member
jodimello
Posts: 1
Registered: ‎06-07-2013
My Device: BB Torch

Re: java.lang.IllegalStateException: no application instance during push registration

Thank you for this. I'm a new app developer myself and this same issue kept me stagnant for quite a while now.

Retired
mdandrea
Posts: 311
Registered: ‎08-08-2012
My Device: BlackBerry Z10

Re: java.lang.IllegalStateException: no application instance during push registration

Hi,

 

There is quite a good developer guide for developing push applications in Java for BlackBerry 7 and lower here that you might want to take a look at if you haven't already:

http://developer.blackberry.com/java/documentation/developing_push_enabled_app.html

 

Also, if your questions are not specific to push, you could ask them here:

http://supportforums.blackberry.com/t5/Java-Development/bd-p/java_dev

 

Thanks,

 

Matt