sam08
Posts: 5
Joined: Sat Jul 19, 2014 6:09 pm

HTTP Protocol Permission error

Mon Oct 20, 2014 3:34 pm

Im trying to send data from the raspberry pi to my website, where i can then process the data using php and place the data into a database. Im doing it this way to offload some of the work onto the server, rather than doing it all on the PI. I keep running into Connector.open permission error. I have tried adding the HTTP Protocol permission into the API Permissions but I am struggling to get this to work

Here is the code which is causing it:

Code: Select all

HttpConnection connection = (HttpConnection) Connector.open(url);
Error messsage:

Code: Select all

java.security.AccessControlException: 
 - com/oracle/meep/security/AccessControllerInternal.checkPermission(), bci=128
 - java/security/AccessController.checkPermission(), bci=1
 - com/sun/midp/io/j2me/http/BasicHttpProtocol.checkForPermission(), bci=32
 - com/sun/midp/io/j2me/http/BasicHttpProtocol.openPrim(), bci=2
 - javax/microedition/io/Connector.open(), bci=77
 - javax/microedition/io/Connector.open(), bci=6
 - javax/microedition/io/Connector.open(), bci=3
 - co/uk/samueldown/gps/GpsDevice.sendGPSData(GpsDevice.java:61)
 - co/uk/samueldown/gps/GpsDevice.<init>(GpsDevice.java:41)
 - co/uk/samueldown/gpio/Button.valueChanged(Button.java:37)
 - com/oracle/deviceaccess/gpio/impl/GPIOPinEventHandler.processEvent(), bci=26
 - com/oracle/deviceaccess/gpio/impl/GPIOPinEventHandler.processEvent(), bci=7
 - com/oracle/deviceaccess/gpio/impl/GPIOEventHandler.process(), bci=62
 - com/sun/midp/events/EventQueue.run(), bci=129
 - java/lang/Thread.run(), bci=5
Can someone point me in the right direction to fix this please. Iv been trawling through google and can't find much on it.

User avatar
aTao
Posts: 1093
Joined: Wed Dec 12, 2012 10:41 am
Location: Howlin Eigg

Re: HTTP Protocol Permission error

Mon Oct 20, 2014 4:37 pm

Lets start with some code, yours that is, what is "Connector" ?

Also, is this really the way you want to go?, Java has great database access classes.
>)))'><'(((<

sam08
Posts: 5
Joined: Sat Jul 19, 2014 6:09 pm

Re: HTTP Protocol Permission error

Tue Oct 21, 2014 4:19 pm

I would prefer to do it this way as I will be connecting to the internet using a 3g dongle. So am trying to reduce the number of connections where possible.

Here is the code:

Code: Select all

         HttpConnection connection = (HttpConnection) Connector.open(url);
            connection.setRequestMethod(HttpConnection.POST);
            connection.setRequestProperty("User-Agent", "Profile/MIDP-1.0 Configuration/CLDC-1.0");
            connection.setRequestProperty("Accept_Language", "en-US");
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            OutputStream outputStream = connection.openOutputStream();
            outputStream.write(data.getBytes());
            System.out.println("Connection to website success!");
            outputStream.close();
            connection.close();
       
        } catch (IOException ex) {
            System.out.println("Connection to website failed!");
        }

Return to “Java”