This is a quite frustrating topic... All I needed was a small Java stored procedure to listen on UDP port 1813, after which I would do something useful with the data.
I did get that to work on Oracle 12c with Windows 8.1, but the exact same setup will not work on Oracle 12c with CentOS 6. And of course I needed CentOS, not Windows.
No idea why the OS makes any difference; it's not a firewall or SELinux issue, since disabling both doesn't make a difference. And any other kind of UDP traffic from and to the CentOS server (using e.g. SocketTest) works like a charm. But actually reaching the database? No way.
Most of the example below I found at http://www.java2s.com/Code/Java/Network-Protocol/ReceiveUDPpockets.htm
I did change it a bit to suit my needs, and added some essential steps (like restarting listener and database, finding that one took a few hours, grrr...).
The database schema I use in this example is ESB_OWNER, and I use UDP port 1813.
Restart database and Listener.
Note: Not sure if you can get away with only restarting the listener; you might.
Note: You can see the permissions have been granted using select * from dba_java_policy where grantee = 'ESB_OWNER'; but you have to restart for it to actually work. That took a few hours to figure out... thanks for the tip Henk!
And here you would expect to receive data, when sending some to the server using e.g. SocketTest
. And on Windows you will. Not on CentOS.
You can see in DBMS Output that the procedure reaches step 5, and there it stays stuck on the receive call.
Finally I just abandoned this approach, and went for the OS Level solution at the top of the page. I spent way too much time on this, and still have no real clues as to what the issue is.
Some Google results suggest it may have to do with the way CentOS (and other RedHat Linux flavors) configure network adapters. Maybe you'd have to force the Java program and/or the OS to listen on the correct socket or IP (something vague anyway, which Windows does automatically).
If you have a fix for this please let me know, I'd love to hear it. And I'll give you all the credit :-)