HttpsConnection: Classcastexception

Hello

I'm Classcastexception when I HttpsConnection.

Here is the code:

ConnectionFactory cf = new ConnectionFactory();
cf.setPreferredTransportTypes (preferredTransportTypes);

ConnectionDescriptor connd = cf.getConnection (url);
If (connd! = null) {}
Connection connection = connd.getConnection ();
httpsConnection = connection (HttpsConnection); / / This line make me Classcastexception

}

If I try to hit the same url in the BB browser opening properly

Thank you

and you open an https url?

Tags: BlackBerry Developers

Similar Questions

  • ClassCastException on Manager.createPlayer problem with DataSource

    I run the code BufferedPlayback (JDE 4.7.0) example loading a local file (LimitedRateStreamingSource to the source of data):

    final LimitedRateStreamingSource source = new LimitedRateStreamingSource("file:///store/home/user/test/test.wav");
    source.setContentType("audio/x-wav");
    final Player player = Manager.createPlayer(source);
    

    but when I create the player a ClassCastException is thrown.
    Search with google I found this method performs a cast to CommonDataSource, and this leads to the exception (http://discussion.forum.nokia.com/forum/showthread.php?t=113902).

    I can't figure out how to solve this problem... someone has any advice?

    LimitedRateStreamingSource in this example expects a HTTP URL.  When you use it with a file:/// URL a FileConnection is returned by the Connector.open call, which triggers a ClassCastException.

    You will need to modify the example to use a FileConnection instead of a ContentConnection.

  • JVM error 104 Eception: ClassCastException

    Hi all

    When I run an application on the Simulator, between start-up Simulator displays an error like below...

    JVM error 104

    Eception: ClassCastException

    Why it is so?

    Thank you and best regards.

    Hi Peter,.

    Sorry for the late reply. I just saw your message and tried to run my application after you have cleaned the Simulator. It worked fine for the moment.  Actually seeing the (especially this line ReliableTransmissionHelper. stack trace (ReliableTransmissionListener, String, TransmissionService) line: 105 ), I could not think that cleaning the simulator could be the solution...

    Thank you very much.

  • HttpsConnection.open method is slow for ssl

    Hi all

    I have a question related to the HttpsConnection. Our application wants to use the HttpsConnection class

    to make queries to a server https. Everything is going well, but we have had a few problems with the

    speed. After several readings, we discovered that the problem is with the method of Connector.open (url),

    Sometimes, it takes 8-11 seconds to connect to the server.

    Send/receive data is fast, but the open() method is really slow. Do you have any ideas why this method

    is so slow? Maybe the problem is with the ssl communication protocol took over? This may cause the problem? 3g

    network is fast, there is no problem with that.

    Interestingly, if I do 4 Please each after the other, then reduces the execution time of the open() - from 5 seconds to 1.3 seconds method. If I now wait 40 seconds and make another request, then the open method runs again for 5 to 8 seconds.

    For the URL, I added the EndToEndRequired parameter, and we are going through BIS.

    I'd appreciate any help for this problem.

    Thank you and best regards,

    -Ferenc

    I'm not an expert, but I can confirm that the treatment for a secure connection will be slow, because both ends must agree on a secure channel for the message.  According to the documentation I've read, this can swap between 5 and 8 messages.  If you expect a significant delay in treatment.  Not because of the amount of data, but only because of the latency involved to accommodate and respond to every message.

    Regarding your comment about time for shorted out later, I can only assume that if you open a second connection shortly after the first, the implementation of subsequent session is short.

    I hope this helps.

  • Problem with the post OFFICE when using HttpsConnection

    Hello community,

    my scenario:

    I have a piece of code that runs on a BB and a Servlet located on a Tomcat 6.0.18. The code on the BB uses POST to send data. When you use with HTTP POST, everything works like a charm, but I have trouble with the POST and HTTPS.

    It seems that the data is not transferred from BB on the server. The use of the debugger I discovered that the data is written to the output stream (side), but when the servlet calls getParameter() only null is returned.

    To ensure a correct installation, I tried a GET with HTTPS which works very well.

    The given code example is on the side of the unit

    connection = Connector.open(url);
    
    HttpsConnection https = (HttpsConnection)connection;
    
    https.setRequestMethod(HttpsConnection.POST);
    
    https.setRequestProperty(HEADER_CONTENTTYPE, CONTENTTYPE_FORMDATA);
    
    https.setRequestProperty(HEADER_CONTENTTYPE, String.valueOf(length));
    
    out = https.openOutputStream();out.write(PostMessage.getBytes());
    
    in = https.openInputStream();
    
    ResponseMessage = new byte[(int)https.getLength()];
    
    in.read(ResponseMessage);
    
    out.close();in.close();https.close();
    

    Any help is very appreciated!

    Thanks in advance.

    PS:

    Simulator: 8300

    MDS: 4.1.4

    JDE: 4.5.0

    Eclipse: Version: 3.4.1
    Build id: M20080911-1700

    Dear community,

    I managed to solve the problem by myself. Its a classic copy & paste error.

    Lets take a look at:

    https.setRequestProperty(HEADER_CONTENTTYPE, CONTENTTYPE_FORMDATA);
    
    https.setRequestProperty(HEADER_CONTENTTYPE, String.valueOf(length));
    

    As you can see I used two times HEADER_CONTENTTYPE. Its not so bad, but to indicate the length of a post, you need to use HEADER_CONTENTLENGTH:-D.

    I have to take a break...

    You can consider the issue as resolved.

  • ObjectChoiceField and ChoiceField$ ChangeOptionChoiceField classcastexception

    one line in fieldchangelistener of my ObjectChoiceField, I have this line:

    choice final int = (field) .getSelectedIndex ((ObjectChoiceField));

    but he gives this exception:

    ClassCastException: Cannot mount net.rim.device.api.ui.component.ChoiceField$ ChangeOptionChoiceField (id = 91958272) at net.rim.device.api.ui.component.ObjectChoiceField

    How can I me index newly selected of the ObjectChoiceField in the Interior of the listener?

    I tried to use a final ObjectChoiceField so I could access it just inside the listener, but it I still get the value of previous for the selected index.

    my code:

    final distance ObjectChoiceField = new ObjectChoiceField ("Menu choose:", menu list);

    If (menuList.length > 1) {}
    Dialog.Alert ("length =" + menuList.Length);
    Flash = Integer.ToString (menu list [Dialog.ask ("which menu?", menuList, 0 "")] .getValue ());
    Dialog.Alert ("Flash =" + Flash);
    distance.setChangeListener (new FieldChangeListener () {}
    ' Public Sub fieldChanged (field field, int context) {}
    choice final int = (field) .getSelectedIndex ((ObjectChoiceField));
    Dialog.Alert ("get next choice");
    final int choice = distance.getSelectedIndex ();
    Dialog.Alert ("location =" + choices);
    Field.Get
    final int ctx = context;
    New Thread() {}
    public void run() {}
    loadMenus (ctx, choice);
    }
    }. start();
    }
    });

    objectSymbol = new ObjectChoiceField ("", ARRAY, 0, Field.FIELD_LEFT)
    {
    protected void fieldChangeNotify (int context)
    {
    indexCurrency = getSelectedIndex();
    }
    };

  • HttpsConnection by BES

    Hello

    I am creating an application that uses httpsconnection but I want it to connect through BES, but I get an error on the device saying connection refused error I do not remember.

    And it works fine on the Simulator.

    The application is a MIDlet application.

    is there something I need to do to make this work through BES?

    Thank you

    I suggest that mark you this issue as resolved, since this isn't a problem of BES, and the invalid URL is problem continue you on this thread:

    java.io.IOExeption: invalid url parameter
    http://supportforums.BlackBerry.com/Rim/Board/message?board.ID=java_dev&thread.ID=65868

    Depth of the problem must be on this Thread.

  • ClassCastException JVM error 104 on A14 storing downloaded persisted data example

    Hello world

    I've been running examples of demonstration programs using Eclipse. I'm ok with A10 write your first application and UI A11, but on trying to run A13 storing persistent data, I get FMV 104 Eception ClassCastException error.

    The code is exaclty as in the downloaded example, so I can't imagine what the problem is.

    Someone else had a similar problem please.

    Thanks a lot for your help

    Roy

    I have actually used this particular article, but I didn't need to compile. Once I realized the syntax is relatively simple, in my humble opinion.

    Good luck with the rest of your development,

    ~ Dom

  • Avoiding the HttpsConnection security prompt

    Hey guys,.

    I am writing an application that will run in the context and the needs to connect to a web server to download recently entered data in order to keep the server up-to-date. It seems that if I use HttpsConnection (and probably of HttpConnection too), the user should click Yes to allow the connection.

    This application is intended for very inexperienced users technically, so it's very important hide this message. What are my options? Will sign the application to get rid of this message?

    It would be acceptable for the user to perform this authorization during the installation of the software (using OTA), but ideally, this should be a single click (or less).

    Thank you very much

    Pav

    a request for applicationpermissions could probably get rid of the popup "allow connection". You must take care of the certificate in addition to this.

    on a bes users have options ask your bes admin on the permissions of the application and how to manage https certificates.

    personally, I would opt for good documentation. even you can say very "technically-inexperienced users" to follow a few pictures.

    Apart from that, you will have to live with the concept of security of the blackberry.

  • How can I stop getActiveScreen to throw ClassCastException?

    If the current field is an instance of the screen, I can do the following:

    CoffeeCard cCard = (CoffeeCard) MyClient.getUiApplication().getActiveScreen();
    

    However, if a Menu or a dialog box is open, I get a ClassCastException in the statement foregoing, which makes sense.

    In addition to checking the returned value of getActiveScreen with the instanceof keyword, is there a better way to check if the active screen is a screen?

    Thank you.

    What is the problem with instanceof?

    for specific classes, you can use a model of the Inspector, but not for this.

  • HTTPSConnection - Message HTTP_PRECON_FAILED (status 412)

    Hello everyone

    I try to access a URL secured using HTTPSConnection and want to analyze the response. The URL contains query string parameters.

    The return status is HTTP_PRECON_FAILED (412).

    No idea why?

    Thank you

    Hello everyone

    I managed to solve the problem by using the following code:

    httpCon.setRequestProperty ("User-Agent", "0.2/MyUserAgent" ');

    Thank you

  • ApplicationMenuItem & Contact = > ClassCastException

    Hello

    As a first step, the code:

    class Demo extends UiApplication
    {
      public static void main(String[] args) {
        boolean autostart = false;
        for (int i=0; i>> DemoMenuItem::run");
    
          Logger.debug("Context : " + context.getClass().getName());
          Logger.debug("Context : " + context.toString());
    
          BlackBerryContact c = (BlackBerryContact) context;
    
          Logger.debug("<<< DemoMenuItem::run");
    
          return context;
        }
      }
    }
    

    So, I have two entrances: from the address book and icon. It works very well.

    But, the built context crash!

    And I don't understand why. I used samples of the RIM, to write this!

    The output of the event log:

    guid:0xBD0F38F00219F634 time:2009/05/13 15:07:23.0 severity:Debug Infotype:String app:Demo data:>>>   DemoMenuItem::run
    
    guid:0xBD0F38F00219F634 time:2009/05/13 15:07:23.0 severity:Debug Info type:String app:Demo data:Context : net.rim.blackberry.api.pdap.ContactImpl
    
    guid:0xBD0F38F00219F634 time:2009/05/13 15:07:23.0 severity:Debug Info type:String app:Demo data:Context : net.rim.blackberry.api.pdap.ContactImpl@7db7adad
    
    guid:0x9C3CD62E3320B498 time:2009/05/13 15:07:23.0 severity:Severe Error type:Exception app:Java data:tion data:
          ClassCastException
          No detail message
          Demo
           Demo$DemoMenuItem
           run
           0x1A5
          net_rim_bbapi_menuitem
           SdkProxyVerb
           invoke
           0x844
          net_rim_bb_framework_api-3
           ModelScreen
           invokeVerb
           0x65B
          net_rim_bb_addressbook_app-1
           ViewAddressCardScreen
           invokeVerb
           0x7C0B
          net_rim_bb_framework_api-2
           VerbMenuItem
           run
           0x7617
          net_rim_cldc-11
           Menu
           show
           0xA492
          net_rim_bb_framework_api-2
           SystemEnabledMenu
           show
           0x50AF
          net_rim_cldc-9
           Screen
           onMenu
           0x760F
          net_rim_cldc-9
           Screen
           keyCharUnhandled
           0x7339
          net_rim_cldc-13
           MainScreen
           keyCharUnhandled
           0x7721
          net_rim_cldc-9
           Screen
           dispatchKeyEvent
           0x6151
          net_rim_bb_framework_api-1
           AppsMainScreen
           dispatchKeyEvent
           0x2945
          net_rim_cldc-9
           Screen
           processKeyEvent
           0x8B73
          net_rim_cldc-10
           UiEngineImpl
           processMessage
           0x916C
          net_rim_cldc-6
           Application
           processNextMessage
           0x2207
          net_rim_cldc-7
           ModalEventThread
           run
           0x5B2C
    
    guid:0xDAA64EAD4E49C5D5 time:2009/05/13 15:07:28.0 severity:Always Logtype:String app:net.rim.usb.pwd data  :CbCn
    

    Where is my problem? and could you give me a solution?

    Thank you to

    Nicolas

    Hello

    I found my problem...

    I wrote:

    import net.rim.blackberry.api.pim.*;
    

    Instead of:

    import net.rim.blackberry.api.pdap.*;
    

    Sorry...

    Moreover, it is a hidden class 'net.rim.blackberry.api.pim '?

    I think that I found in your samples... but I can't remember where!

    Kind regards

    Nicolas

  • ClassCastException in MenuItem

    IM saving a MenuItem in an attribute of an object.

    When later I call the run method, I get a ClassCastException.

    Any solution?

    Thank you.

    Its a TextField$ TogglingMenuItem.

    Its very strange, but I was doing controller.getSureType () .run ();<-- this="">

    But if I do suretype MenuItem = controller.getSureType (); SureType.Run)<-- this="">

    Weird, no?

    Thank you!

  • ClassCastException on TextField

    Hello world!

    I have a problem with a class of mine who is from TextField. When I open the context Menu on MyTextField, you see the default options. If I choose "Display symbols", my program shows an error that says "ClassCastException. I thought that maybe I had done something wrong with my class, but then there has tried the same thing with a regular TextField and had the same problem. Anyone know how I can get this option to work?

    TextField is the base for BasicEditField and RichTextField class and cannot be instantiated directly.  How do you add the textfield on your screen?  Can you provide a code snippet that reproduces the exception?

    The version you gave is for the Simulation of BlackBerry tool itself.  What is the version of the software of BlackBerry device running in the tool?  You can see by going to Options (wrench), in the BlackBerry Simulator.

  • Eception exception java.lang.classcastexception blackBerry smartphones?

    Basically, I did an update on my phone. To the very last step (restore data to my bb) it came with an error message on my phone an the only option was to zero.

    Now, whenever I turn on my phone it gets past the stage of pin code then comes up with "eception java.lang.classcastexception exception" and it won't go away.

    When I try to connect it to my computer, the error message appears telling me to reset it.

    Sorry if this message is a little everywhere in the place but any advice would be appreciated!

    Hello

    Could you get

    http://supportforums.BlackBerry.com/T5/other-BlackBerry-smartphones-and/uncaught-exception-Java-lang...

Maybe you are looking for