RE: How to start a Realm from a servlet or a filter
Realm is not accessible to servlet or filter. In anther word, you can't do what you are trying to do. Let's suppose for a second that your code could work, then I can write a servlet to replace your realm or any realm tomcat is using. And image what could happen if the tomcat manager interface is using that realm? Thanks Daniel -Original Message- From: Zsolt Koppany [mailto:[EMAIL PROTECTED] Sent: Friday, April 09, 2004 1:49 AM To: Tomcat Users List Subject: How to start a Realm from a servlet or a filter Hi, because of technical reasons I want to start a Realm class during run-time, thus I cannot just configure Realm via Realm When I try to start MemoryRealm I get a null pointer exception, because the container of Realm is not set. The application does work (because I catch the exception) but I would like to start Realm correctly. What is wrong in my example? Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup(java:comp/env); Object realm_instance = envCtx.lookup(realm/RealmFactory); log.info(Realm class: + realm_instance.getClass().getName()); Realm rlm = (Realm)realm_instance; if (rlm instanceof Lifecycle) { try { // rlm.setContainer(...); Is that the problem ((Lifecycle) rlm).start(); } catch (Exception e) { log.error(LifecycleException (start): + e.getMessage(), e); } Here is my web-application configuration file: Context path=/cb docBase=cb debug=0 reloadable=true Resources className=org.apache.naming.resources.FileDirContext allowLinking=false / Resource name=realm/RealmFactory auth=Container type=org.apache.catalina.realm.MemoryRealm/ ResourceParams name=realm/RealmFactory parameter namefactory/name valueorg.apache.naming.factory.BeanFactory/value /parameter parameter namedebug/name value99/value /parameter parameter namepathname/name valueconf/tomcat-users.xml/value /parameter /ResourceParams /Context Zsolt Koppany Phone: +49-711-722 1874 -- Intland Software GmbH, Schulze-Delitzsch-Strasse 16 D-70565 Stuttgart, Germany Phone: +49-711-722 1873, e-mail:[EMAIL PROTECTED] Fax: +49-711-722 1835 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to start a Realm from a servlet or a filter
Hi, Realm is not accessible to servlet or filter. In anther word, you can't do what you are trying to do. How authoritative and conclusive. And wrong. Realms and all other tomcat internals are accessible to any code you write. You just have to mark your webapp as privileged and in some instances (depending on your code) place portions of your code in the common rather than your webapp's classloader. Yoav This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to start a Realm from a servlet or a filter
Hi Yoav, How authoritative and conclusive. And wrong. Realms and all other tomcat internals are accessible to any code you write. You just have to mark your webapp as privileged and in some instances (depending on your code) place portions of your code in the common rather than your webapp's classloader. And how can I access or start a Realm? Zsolt This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to start a Realm from a servlet or a filter
Hi, And how can I access or start a Realm? What is up with this list? Do people don't know how to read JavaDocs, or do they simply not care? Sigh... Server server = ServerFactory.getServer(); Service service = server.findService(Catalina); Container serviceContainer = service.getContainer(); Realm serviceRealm = serviceContainer.getRealm(); // May be null You would/can continue to drill down from the service using findChildren to locate Engine/Host/Context elements and their associated Realms, if any. As to how to start one: look at the tomcat startup code, that's why it's open-source. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How to start a Realm from a servlet or a filter
Yoav, I have written this code, but srv is always an empty array. I use tomcat-5.0.19 Server server = ServerFactory.getServer(); Service service = server.findService(Catalina); Service[] srv = server.findServices(); for (int i = 0; i srv.length; i++) { Service s = srv[i]; log.debug(SERVICE: + s.getName()); } Zsolt -Original Message- From: Shapira, Yoav [mailto:[EMAIL PROTECTED] Sent: Friday, April 09, 2004 7:00 PM To: Tomcat Users List Subject: RE: How to start a Realm from a servlet or a filter Hi, And how can I access or start a Realm? What is up with this list? Do people don't know how to read JavaDocs, or do they simply not care? Sigh... Server server = ServerFactory.getServer(); Service service = server.findService(Catalina); Container serviceContainer = service.getContainer(); Realm serviceRealm = serviceContainer.getRealm(); // May be null You would/can continue to drill down from the service using findChildren to locate Engine/Host/Context elements and their associated Realms, if any. As to how to start one: look at the tomcat startup code, that's why it's open-source. Yoav Shapira This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]