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
Developer
Ketzusaka
Posts: 24
Registered: ‎04-28-2009
My Device: Not Specified

Interprocess Communication issue: Can't find entry point (More of a build issue; using Eclipse)

Hello,

 

I'm building a GPS application that will run in the background. It has no user interface attached to it as I want to build a couple different applications that can make use of its features. Sometimes the user will want to turn off the GPS, turn it on, or various other things, so I need to get some interprocess communication going. I've already done this with a Log for it using a simple vector, but I don't think that fits for the request/response portion of the communication (such as turning the GPS off).

 

To accomplish this I created a class called Communicator following the singleton resource found at: http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/832062/How_to_...

 

 To get access to the Communicator class I added the GPS project to the build path (Project Properties->Java Build Path->Projects

 

 However, when attempting to start the application I get the following error:

 

 Error starting GPSInterface: Can't find entry point

 

 

I'm not sure if thats the best way to get that done or not. Maybe making the GPS itself a library and a separate program that starts it would be better; not sure.

 

Thanks in advance!

~James

Please use plain text.
Developer
Ketzusaka
Posts: 24
Registered: ‎04-28-2009
My Device: Not Specified

Re: Interprocess Communication issue: Can't find entry point (More of a build issue; using Eclipse)

Hi again,

 

I'm still unable to get this working. I've made a bit of progress I think. I moved the code that obtains the singleton into a different class file, but now when I call MySingleton.getInstance() I get a NoClassDefFoundError exception and the application does not even start. :/

 

Please use plain text.
New Developer
darryl_parker
Posts: 14
Registered: ‎08-07-2009
My Device: Not Specified

Re: Interprocess Communication issue: Can't find entry point (More of a build issue; using Eclipse)

Hi Ketzusaka,

 

I'm having the same problem.  I have a background thread listening for events, and a seperate UiApplication.  This KB article refers to this as "the recommended method" for IPC.

 

Initially I just put my background project into the build path of the UiApplication project so I could reference the types, but I got the same "Can't find entry point" error.  This is in spite of my UiApplication clearly having a public static void main(String[] args) method.

 

Some searching led me to this KB article, which describes taking the .jar out of your background project, and putting it into a new project with the application type of "Library", and then referencing that. I'm using the Eclipse plugin rather than the JDE, so the step-by-step process is a little different, but I'm pretty sure I have it set up as the KB article intends.

 

Everything builds and deploys to the simulator fine, but I still get the "Can't find entry point" error when trying to invoke the UiApplication.

 

Did you ever resolve this issue?  In spite of this being "the recommended solution", I seem to be having problems implementing it.

 

Thanks for any assistance you can provide.

 

Darryl.

Please use plain text.
New Developer
darryl_parker
Posts: 14
Registered: ‎08-07-2009
My Device: Not Specified

Re: Interprocess Communication issue: Can't find entry point (More of a build issue; using Eclipse)

More good fun:

 

So, I've come up with two solutions, each of which fix 1/2 my problem. Unfortunately, I don't know how to combine them to solve the whole thing.

 

Quick recap: I have an ExampleListener which is an autostart system module, and an ExampleInterface, which is a standard UiApplication.  I want the ExampleInterface to use the RuntimeStore to get a reference to the running ExampleListener. They are two separate applications.

 

Half Solution Number 1

 

I simply changed the ExampleListener from a CLDC Application to a Library application. I added the ExampleListener to the build path of the ExampleInterface. 

 

The Good: On starting the simulator , the ExampleInterface will open fine.  It gets the ExampleListener out of the RuntimeStore and operated correctly.

 

The Bad: The ExampleListener no longer runs (because it's a Library Application). It does not respond to the events it is supposed to.

 

Half Solution Number 2

 

I copied the .java files for the ExampleListener over into a new project called ExampleLibrary. This NEW project was marked as type Library, leaving both the other main packages as CLDC apps. I add the new ExampleLibrary project to the buildpath of my ExampleInterface project.

 

The Good: The ExampleListener background thread runs normally.

 

The Bad: I now get a java.lang.ClassCastExeption when I call RuntimeStore.getRuntimeStore().get() and try to cast from com.example.background.ExampleListener to com.example.background.ExampleListener. I guess that makes sense, because the RuntimeStore is returning the com.example.background.ExampleListener built from the ExampleListener project, whereas I am trying to cast it to the local com.example.background.ExampleListener built from the ExampleLibrary project.

 

I need the Listener running as in Solution 2, but I also need the correct type casting from Solution 1. Does anyone have a working example of the original KB article titled How To - Implement a Background Push Listener and UI Component for an Application? How do I get around these type referencing issues in the Eclipse Plugin development world?

 

Thanks for your attention,

 

Darryl.

Please use plain text.
Developer
Ketzusaka
Posts: 24
Registered: ‎04-28-2009
My Device: Not Specified

Re: Interprocess Communication issue: Can't find entry point (More of a build issue; using Eclipse)

Hi Darryl,

 

While not exactly what I was doing I did find a solution that worked

 

I'm currently using global events. When my listener application starts it registers global events to listen to, then the ui app sends those global events with data and my listener picks it up. You can send global events with the ApplicationManager and register them through the Application class.

 

I also have my ui listening for events so the listener can talk back.

 

Maybe this will work for you as well?

Please use plain text.
New Developer
darryl_parker
Posts: 14
Registered: ‎08-07-2009
My Device: Not Specified

Re: Interprocess Communication issue: Can't find entry point (More of a build issue; using Eclipse)

Hey Ketzusaka, thanks for dropping back into this thread.

 

Global events won't work for me.  In my scenario, the UiApplication isn't running at all while the Listener thread is running. If that listener fires off a global event, no one is there to hear it.

 

In the constructor to the UiApplication, I want to get a reference to the Listener and interrogate it for status. Based on the status, I choose which screen to push.

 

I've thought about persistant data stores as an option, and I'll start going down that road if it really turns out that it's impossible to do IPC via the method outlined in How To - Implement a Background Push Listener and UI Component for an Application. But the KB article seems to be pretty clear that this is supposed to work.

 

I've read other people in the forms abandoning the method in that KB article for global events.  Is there anyone out there who has gotten it to work?  Is this something that only the JDE can do?

 

Thanks again,

 

Darryl.

Please use plain text.
New Developer
darryl_parker
Posts: 14
Registered: ‎08-07-2009
My Device: Not Specified

Re: Interprocess Communication issue: Can't find entry point (More of a build issue; using Eclipse)

Ok, I have now successfully implemented the KB article. I'll record some notes here for the next person who comes along searching the forums.

 

It turns out I almost had the right idea with my Solution #2 above. I copied the .java files over into the Library project, but then I still maintained 2 separate copies of the code.  That was stupid.

 

My solution:

 

  1. Create three projects:
    1. A Library project to hold your Listener object
    2. An auto-start and system-module project to start your listener when the device turns on
      1. Add the Library project to your build path
    3. A standard CLDC project for your GUI
      1. Add the Library project to your build path
  2. Make your Listener Object a singleton by making the contructor private and implementing a waitForSingleton() method as described in the KB.
  3. In your auto-start project, the class which contains the main() method will not itself be an Application or a UiApplication.
  4. In the main() method of your auto-start project, call the Listener.waitForSingleton() to start it up when the device is turned on.
  5. Create a new UiApplication, and in the constructor get a local reference to the same listener object by calling the waitForSingleton() method.

 

And that's it: You can have the UiApplication wiith a reference to a long-running listener when it starts.

 

I'm off and runnning...  See y'all in the App World!

 

Darryl Parker

Please use plain text.