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 Developer
Posts: 5
Registered: ‎01-21-2009
My Device: Not Specified

Push Registry - J2ME Polish

Hi,

 

Background:

I have gone through several threads on Push Registry implementation on BlackBerry on this forum and also the tutorials on the Developers Knowledge Base: 

 

1. Auto Registration  through JAD file

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800429/How_To_...

 

2. Dynamic 

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800429/How_To_...

 

I am able to invoke the midlet when it is developed through the BlackBerry JDE. Please note that I do come across various problems which are also listed by other developers; e.g:

http://supportforums.blackberry.com/rim/board/message?board.id=java_dev&message.id=4234&query.id=239...

 

However, I was able to launch/invoke the midlet (at least once)when an sms is received on a specific port while trying both the auto registration or the dynamic methods.

 

Question:

My main question is that, I have developed a midlet using J2ME Polish and the push registry seems to work fine with other handsets. I have ported the same application on BlackBerry and although the rest of the functionality is working properly, the problem is in the registration of a specific port for incoming sms (or data). 

 


try {
PushRegistry.registerConnection("sms://:5678", this.getClass().getName(), "*");
} catch (ClassNotFoundException e) {


and I have also tried

PushRegistry.registerAlarm(this.getClass().getName(),time);
} catch (ConnectionNotFoundException e) {

ClassNotFoundException is thrown in both cases:
Midlet '<name>' is not in current suite


The same code works if not using j2mepolish and developing directly on the blackberry's JDE

I have also tried the auto registration by entring the
MIDlet-Push-1 entry in the JAD file, without any luck. (This is probably because the blackberry tutorial itself mentions that the midlet has to be compiled again, once the modified JAD is added to the project and I can not figure out if it is possible recompile the midlet, while using J2ME Polish; I may be completely wrong in the assumption! )

 

 Any help would be greatly appreciated.  

 

Thanks, 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Push Registry - J2ME Polish

Please have a look at the link below.  The article is related to Eclipse and the error differs, but it may be related to what you are seeing.

 

Support - Application throws a verification error when launched 
Article Number: DB-00703

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/1407892/Support_-_App...

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 5
Registered: ‎01-21-2009
My Device: Not Specified

Re: Push Registry - J2ME Polish

Thanks Mark, but I don't think referencing the class is the problem.

 

When registering a PushRegistry connection, one of the attributes passed is the name of the class <"String"> which is to be registered and when the name of the class is passed:

 

java.lang.ClassNotFoundException: Midlet 'className' is not in current suite

 

is thrown

 

 

the following code is used in the constructor of the Midlet

 

connections = PushRegistry.listConnections(false);        
      
        if (connections.length == 0){
           try {
                PushRegistry.registerConnection("sms://:5678", this.class.getName(), "*");
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                System.out.println("ClassNotFoundException: " +e);
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                System.out.println("IOException: " + e);
                e.printStackTrace();
            }
        }

 

 

So, its not like I am trying to reference any other class. I am just passing the name of the Midlet class in the constructor of the Midlet(same class) and some how it can not find it in the Midlet suite. PS: I just have only one midlet.

 

Any help would be greatly appreciated. 

 

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Push Registry - J2ME Polish

The name used should contain the package name plus your class name.  Prefix the class name with your package and try the application again.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 5
Registered: ‎01-21-2009
My Device: Not Specified

Re: Push Registry - J2ME Polish

Mark,

 

The class name used is obtained by "this.getClass().getName();",  thus it already has the package name. 

 

PS: I used the same code and debugged it in BlackBerry JDE  and there are no exceptions.

 

The exception is thrown when I use J2ME Polish ((eclipse) ant build) to build the project.

And I know that the ClassNotFound Exception is thrown because after I build the project through J2ME Polish, I add the project file in the BlackBerry JDE workspace and debug the project. The output shows that this exception is thrown.

Every thing else in the project works properly when built through J2ME Polish's ant build.

 

Thanks for all your help!

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Push Registry - J2ME Polish

This is being caused by an issue with the BlackBerry JDE Plug-in for Eclipse.  It is triggererd by calling getClass().getName() within another method.  The work around is to call this method one line above, store the result in a String object and use that within the method.

 

Our development team is aware of this issue and it should be resolved in a future release.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 5
Registered: ‎01-21-2009
My Device: Not Specified

Re: Push Registry - J2ME Polish

Thanks for pointing that out Mark. But I have already tried:


             try {
                String className =  this.getClass().getName();
                System.out.println("className: " +className);
                PushRegistry.registerConnection("sms://:5678",className , "*");
            } catch (ClassNotFoundException e) {
                // TODO Auto-generated catch block
                System.out.println("ClassNotFoundException: " +e);
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                System.out.println("IOException: " + e);
                e.printStackTrace();
            }
        }

java.lang.ClassNotFoundException: Midlet '<packagename.classname>' is not in current suite is still thrown

I have also tried storing the name of the class along with the package name statically:

String className = "<packagename.classname>";
PushRegistry.registerConnection("sms://:5678",className , "*");

with the same result.

Note: Just an FYI ,  when I use an incorrect classname/package name the exception thrown is only:

"java.lang.ClassNotFoundException" is thrown (i.e.  without the Midlet not being in the same suite part)

 
Note: In Eclipse, I have tried placing the source code/packages directly in the root directory or under source/src

directory and then built the *.jdp file.


However, when I import the jdp file in the BlackBerry JDE, the source code/packages are under the folder "source"

in both the cases.

Also, the classes are in the "bin" folder in Eclipse and the images used in the project are in "resources" folder.
In BlackBerry JDE when the jdp file is imported, the resources are under folder "classes".

I was wondering if this had any thing to do with the problem I am facing.

I am still stuck at this issue and I deeply appreciate your help and responses.


Regards,

 

BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Push Registry - J2ME Polish

On the Eclipse side, your source files shouldn't show up in the root of the src folder (unless you don't have a package name).  They should show up under the package name for your application.  Try removing and re-adding the source Java files in the project.  The BlackBerry JDE isn't as strict in this area.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Developer
Posts: 5
Registered: ‎01-21-2009
My Device: Not Specified

Re: Push Registry - J2ME Polish

Sorry for not beling clear; but what I meant to ask was that since source folder names are different in BB JDE and in Eclipse (the package names are the same), can that somehow create a problem ?  (PS: The source files do show up under the package in both cases)

 

But I guess the names for the soure folders being different (in the different IDEs) doesnt make a difference at all.


My main question however, remains the same as stated in my previous message:

 

"

While trying to register sms port on the PushRegistry through Eclipse which is integrated with J2ME Polish by:

 

String className = "<packagename.classname>"

PushRegistry.registerConnection("sms://:5678",className , "*":smileywink:;

 

or

 

String className =  this.getClass().getName();
PushRegistry.registerConnection("sms://:5678",className , "*":smileywink:;

 

results in   "java.lang.ClassNotFoundException: Midlet '<packagename.classname>' is not in current suite" exception.

 

"

 

Thanks for all the help. 
BlackBerry Development Advisor
Posts: 15,784
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Push Registry - J2ME Polish

Have you tried using the BlackBerry JDE Plug-in for Eclipse?  I had asumed you were above.  If so, are you also seeing this when the application is built using it?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker