PDA

View Full Version : DatabaseWithJDBC Problem



Kev
11-10-2010, 06:05 PM
Hi Everyone,

Going through this example, and I'm having a problem when TestDatabasePlugin's init method is called. This is the error in the ES5 logs:

2010-Nov-10 08:20:50:457 [pool-1-thread-6] ERROR com.electrotank.electroserver5.entities.BaseBridge - Error occured calling extension code - Extension: DatabaseWithJDBC - Name: TestDatabaseJDBCPlugin - Handle: TestDatabaseJDBCPlugin
java.lang.RuntimeException: Unable to find a server level plugin named 'DatabaseJDBCPlugin' from extension 'DatabaseWithJDBC'
at com.electrotank.electroserver5.extensions.api.Elec troServerApiImpl.getServerPlugin(ElectroServerApiI mpl.java:1080

The Extension loads OK when the server starts - it shows up in ESAdmin, and I'm using the Extensions.xml that came with the sample - just changed the mysql connection string. I also just compiled the source and copied the classes folder over. So, it's looking for the other plugins in the Extension, but can't find them.

Here is the AS3 code that creates the plugin:
var ple:PluginListEntry = new PluginListEntry();
var ple1:PluginListEntry = new PluginListEntry();
ple.extensionName = "HelloWorldExtension";
ple.pluginHandle = "HelloWorldExtension";
ple.pluginName = "HelloWorldExtension";
ple1.extensionName = "DatabaseWithJDBC";
ple1.pluginHandle = "TestDatabaseJDBCPlugin";
ple1.pluginName = "TestDatabaseJDBCPlugin";

crr.plugins = [ple, ple1];
es.engine.send(crr);

I've tried it without the HelloWorldExtension, and tried to create a plugin for DatabaseJDBCPlugin, with no success. I know the docs say this has to be server level, so does this mean I don't create a room level extension? I don't see how I'd send to it otherwise, but I'm still on the learning curve.

Thanks for help/advice,

Kevin

tcarr
11-10-2010, 06:17 PM
That example was designed so that the database was accessed using a server level plugin named DatabaseJDBCPlugin. Don't make TestDatabasePlugin a server level component unless you make DatabaseJDBCPlugin server level first. Clients can send plugin messages to any plugin (room level or server level) if that plugin has overrides/implements the request method. You can make TestDatabasePlugin a room level plugin if you like, but DatabaseJDBCPlugin should be server level. See the ServerPluginRequest example for how a client can send a message to a server level plugin.

Please be warned that if you have a plugin that has a request method similar to TestDatabasePlugin that allows a client to send a String of SQL, and you don't check that string, your database is wide open to SQL injection attacks.

Plugins that connect to a database can be room level. There are LOTS of ways to implement this type of thing. However, if one plugin is trying to communicate with another, the way to communicate with the other plugin varies depending on whether it is server level or room level. There is a single instance of each server level plugin on ES5, even if there are no rooms. A room level plugin might have 1000 instances on the ES5, if there are 1000 rooms each with that plugin attached.

Kev
11-10-2010, 11:28 PM
Thanks Teresa. And I've been through that example, for Pete's sake. I am aware of the SQL Injection risk, this is just to get a feel for how this works. I'm getting there - I created Server-Level Components for ManagedConnectionPool and DatabaseJDBCPlugin in ESAdmin. Then created the room level TestDatabaseJDBCPlugin with a CreateRoomRequest. Now, I can see the test query fire successfully when the room plugin is created. However, I'm still getting PluginNotFound when I send a plugin message. Must have a typo or something on my end.

Kevin

tcarr
11-10-2010, 11:40 PM
If you send a plugin message from the client to a room level TestDatabaseJDBCPlugin, then you have to specify the roomId and zoneId of the room that has it attached. If you aren't in the same room, it may have been destroyed already. If you are doing all that, give me the code you are using to create the room with plugin, and the code for sending the plugin request and I'll see if I can spot the problem.

Kev
11-11-2010, 12:03 AM
Teresa,

As I thought, it was a typo. I had the Plugin handle as TestDatabaseJDBCPlugin, while the class name is TestDatabasePlugin.

Doh!

Thanks,

Kevin