Hello,

In my first WO project, I need to connect to the db using the credentials that users provide on the login page. At most 10-20 users will be using it simultaneous so there won't be scalability problems (I hope).

Anyway I tried the following, storing the editing context on the session but for some reason the first try always fails with a NPE?? and the second succeeds?? I can leave it like that but don't feel comfortable with it. Am I on the wrong path here?

                        EOEditingContext editingContext = 
session().defaultEditingContext();
// A session was already created. Can I start with this EC?

                        NSMutableDictionary userLogin = new 
NSMutableDictionary();

                        userLogin.setObjectForKey(login, "username");
                        userLogin.setObjectForKey(password, "password");
                        try {
                                EOUtilities.connectWithModelNamed(editingContext, 
"Rima",
                                                userLogin);
                        } catch (JDBCAdaptorException e) {
                                // wrong password, server down , etc...
                                setMensagem(e.getMessage());
                                return null;
                        }
                        catch (Exception e1) {
                                //Why???
                                NSLog.out.appendln("First failed!!" + 
e1.getClass().getName());
                                try {
                                        EOUtilities.connectWithModelNamed(editingContext, 
"Rima",
                                                        userLogin);
                                } catch (Exception e2) {
                                        //this never happens !?!?
                                        NSLog.out.appendln("Second Exception!!" 
+ e2.getClass().getName());
                                }
                        }



Here is the output:

[2008-6-11 14:25:19 WEST] <WorkerThread12> Using JDBCPlugIn 'PostgresqlPlugIn' for [EMAIL PROTECTED] [2008-6-11 14:25:19 WEST] <WorkerThread12> connecting with dictionary: {plugin = "PostgresqlPlugIn"; username = "hmng"; driver = ""; password = "<password deleted for log>"; URL = "jdbc:postgresql:// server/db"; }
EC creation: First failed!!java.lang.NullPointerException
java.lang.RuntimeException: EC creation
        at XXXX.components.Main.doLogin(Main.java:78)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun .reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 39) at sun .reflect .DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 25)
        at java.lang.reflect.Method.invoke(Method.java:585)
at com.webobjects.foundation.NSKeyValueCoding$ValueAccessor $1.methodValue(NSKeyValueCoding.java:636) at com.webobjects.foundation.NSKeyValueCoding $_MethodBinding.valueInObject(NSKeyValueCoding.java:1134) at com.webobjects.foundation.NSKeyValueCoding $DefaultImplementation.valueForKey(NSKeyValueCoding.java:1293) at com.webobjects.appserver.WOComponent.valueForKey(WOComponent.java: 1686) at com.webobjects.foundation.NSKeyValueCoding $Utility.valueForKey(NSKeyValueCoding.java:447) at com.webobjects.foundation.NSKeyValueCodingAdditions $DefaultImplementation.valueForKeyPath(NSKeyValueCodingAdditions.java: 212) at com.webobjects.appserver.WOComponent.valueForKeyPath(WOComponent.java: 1754) at com .webobjects .appserver ._private .WOKeyValueAssociation.valueInComponent(WOKeyValueAssociation.java:50) at com.webobjects.appserver._private.WOForm.invokeAction(WOForm.java: 144) at com .webobjects .appserver ._private.WODynamicGroup.invokeChildrenAction(WODynamicGroup.java:105) at com .webobjects .appserver._private.WODynamicGroup.invokeAction(WODynamicGroup.java:115) at com.webobjects.appserver.WOComponent.invokeAction(WOComponent.java: 1078)
        at com.webobjects.appserver.WOSession.invokeAction(WOSession.java:1357)
at com.webobjects.appserver.WOApplication.invokeAction(WOApplication.java: 1736) at com .webobjects .appserver ._private .WOComponentRequestHandler ._dispatchWithPreparedPage(WOComponentRequestHandler.java:206) at com .webobjects .appserver ._private .WOComponentRequestHandler ._dispatchWithPreparedSession(WOComponentRequestHandler.java:298) at com .webobjects .appserver ._private .WOComponentRequestHandler ._dispatchWithPreparedApplication(WOComponentRequestHandler.java:332) at com .webobjects .appserver ._private .WOComponentRequestHandler ._handleRequest(WOComponentRequestHandler.java:369) at com .webobjects .appserver ._private .WOComponentRequestHandler .handleRequest(WOComponentRequestHandler.java:442) at com .webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java: 1678) at com .webobjects .appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:144) at com .webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java: 226)
        at java.lang.Thread.run(Thread.java:613)

[2008-6-11 14:25:23 WEST] <WorkerThread12> fetching JDBC Info with [EMAIL PROTECTED] [2008-6-11 14:25:23 WEST] <WorkerThread12> connecting with dictionary: {plugin = "PostgresqlPlugIn"; username = "hmng"; driver = ""; password = "<password deleted for log>"; URL = "jdbc:postgresql:// server/db"; } [2008-6-11 14:25:38 WEST] <WorkerThread12> === Begin Internal Transaction [2008-6-11 14:25:38 WEST] <WorkerThread12> evaluateExpression: <com.webobjects.jdbcadaptor.PostgresqlExpression: "SELECT ....
[2008-6-11 14:25:38 WEST] <WorkerThread12> 1 row(s) processed
[2008-6-11 14:25:38 WEST] <WorkerThread12> === Commit Internal Transaction

WO 5.4.1, Leopard, PostgresqlPlugiIn updated recently...


Best regards,

---
Henrique Gomes




_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to