[Ecm-checkins] r31453 - sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.platform.rcp/src/org/nuxeo/ecm/rcp

bstefanescu svn at nuxeo.com
Fri Apr 11 14:08:46 CEST 2008


Author: bstefanescu
Date: Fri Apr 11 14:06:51 2008
New Revision: 31453

Log:
APG-120: java.lang.reflect.UndeclaredThrowableException when login

Modified:
   sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.platform.rcp/src/org/nuxeo/ecm/rcp/Repository.java

Modified: sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.platform.rcp/src/org/nuxeo/ecm/rcp/Repository.java
==============================================================================
--- sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.platform.rcp/src/org/nuxeo/ecm/rcp/Repository.java	(original)
+++ sandbox/Apogee/trunk/plugins/org.nuxeo.ecm.platform.rcp/src/org/nuxeo/ecm/rcp/Repository.java	Fri Apr 11 14:06:51 2008
@@ -14,6 +14,9 @@
 
 package org.nuxeo.ecm.rcp;
 
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.UndeclaredThrowableException;
+
 import javax.ejb.EJBAccessException;
 import javax.security.auth.login.LoginException;
 
@@ -61,20 +64,18 @@
             try {
                 docMgr = new CachingRepositoryInstanceHandler(descriptor).getProxy();
                 sid = docMgr.getSessionId();
+            } catch (UndeclaredThrowableException e) {
+            	Throwable t = e.getUndeclaredThrowable();
+            	if (t instanceof InvocationTargetException) {
+            		if (((InvocationTargetException)t).getTargetException() instanceof EJBAccessException) {
+            			return loginFailed();
+            		}
+            	} else if (t instanceof EJBAccessException) {
+            		return loginFailed();
+            	}
+        		throw e;
             } catch (EJBAccessException e) {
-            	docMgr = null;
-                Application app = Application.getInstance();
-                if (app == null) {
-                    throw new RuntimeException(Messages.Repository_errorLoginNullConnection);
-                }
-                try {
-                    if (!app.getLoginHandler().retryLogin()) {
-                    	throw new ApplicationLoginException("Login Failed");
-                    }
-                } catch (LoginException e1) {
-                    throw new RuntimeException("LoginError", e1);
-                }
-                return getDocumentManager();
+            	return loginFailed();
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
@@ -82,6 +83,22 @@
         return docMgr;
     }
 
+    private CoreSession loginFailed() {
+    	docMgr = null;
+        Application app = Application.getInstance();
+        if (app == null) {
+            throw new RuntimeException(Messages.Repository_errorLoginNullConnection);
+        }
+        try {
+            if (!app.getLoginHandler().retryLogin()) {
+            	throw new ApplicationLoginException("Login Failed");
+            }
+        } catch (LoginException e1) {
+            throw new RuntimeException("LoginError", e1);
+        }
+        return getDocumentManager();
+    }
+
     public String getSessionId() {
     	return sid;
     }


About

This page is a mailing archive for one of the Nuxeo projects.

Project News

[2008/11/18] Nuxeo 5.2.M3 and Nuxeo WebEngine 1.0.RC released![2008/11/13] First Nuxeo Developer Day (1st Dec. 2008) - Still a few seats available[2008/11/13] First Nuxeo Survey[2008/10/08] Nuxeo 5.1.6 Released

Corporate News

[2008/11/20] Nuxeo secures 2 million Euros and strengthens its board of directors and corporate governance[2008/11/17] Nuxeo joins OASIS[2008/10/23] IFRA Expo 2008 Amsterdam, October 27th to 30th, Booth 9363, Hall 9[2008/10/08] Nuxeo announces the appointment of Carina Rimoli as Indirect Sales Manager