tomcat v5.5.2 doesn't read ResourceParams ?

2004-09-16 Thread Torgeir Veimo
Hi, 

I've been trying out tomcat v5.5.2alpha since yesterday, and from my
findings, it appears that it doesn't read the content of the
ResourceParams. At least when I look at the datasource with the admin
webapp, it has empty url, driverClassname etc.

Have anyone seen similar results? I've added a copy of what I've put in
conf/server.xml.


  GlobalNamingResources

Resource name=Repository auth=Container 
type=javax.sql.DataSource
description=repository datasource definition /
ResourceParams name=Repository
parameter
namefactory/name

valueorg.apache.commons.dbcp.BasicDataSourceFactory/value
/parameter
parameter
namemaxActive/name
value100/value
/parameter
parameter
namemaxIdle/name
value30/value
/parameter
parameter
namemaxWait/name
value1/value
/parameter

parameter
nameusername/name
valuetorgeir/value
/parameter
parameter
namepassword/name
value/value
/parameter
parameter
namedriverClassName/name
valuecom.mysql.jdbc.Driver/value
/parameter
parameter
nameurl/name
valuejdbc:mysql://localhost/repository/value
/parameter
/ResourceParams
  /GlobalNamingResources

-- 
Torgeir Veimo [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: tomcat v5.5.2 doesn't read ResourceParams ?

2004-09-16 Thread Torgeir Veimo
On Thu, 2004-09-16 at 10:59 -0400, Shapira, Yoav wrote:
 Hi,
 ResourceParams are gone.  See the updated docs:
 http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples
 -howto.html.

Aha, thanx!

I think this should be put in big red letters somewhere

-- 
Torgeir Veimo [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Tomcat Problems - Any help is appreciated

2004-09-16 Thread Torgeir Veimo
On Thu, 2004-09-16 at 10:44 -0500, Wilson, Allen wrote:
 Hello...
 
 I am running 4.1.18 and I suddenly started having problems with Tomcat.
 Here is the information that is in the catalina.out file (as added it as
 an attachment)...if someone can point me in the right direction to fix
 this...I would appreciate it
 
 Thanks you

[...]
 org.xml.sax.SAXParseException: Document root element web-app, must
 match DOCTYPE root null.
[...]
 [ERROR] Digester - -Parse Error at line 1 column 10: Document is
 invalid: no grammar found. org.xml.sax.SAXParseException: Document is
 invalid: no grammar found.

It cannot find any dtd to validate the web.xml file against. Do you have
something like 

!DOCTYPE web-app
PUBLIC -//Sun Microsystems, Inc.//DTD Web Application 2.3//EN
http://java.sun.com/dtd/web-app_2_3.dtd;

in web.xml? Tomcat should have a local copy of this file, but it might
have been corrupted.

-- 
Torgeir Veimo [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



debugging of jsp's

2001-05-23 Thread Torgeir Veimo

Just dreaming load here;

How would it be possible to write a debugger for jsp's that interpreted
a jsp page, and made the content of the pageContext available with a
nice gui? I know this is all possible to retrieve by attaching a
debugger to tomcat, but this gives me a strickly servlet view, not a jsp
page view. 

Being able to toggle between the jsp and the generated code at debug
time would also be nice..

-- 
- Torgeir



using xerces in addition to crimson in webapp

2001-05-22 Thread Torgeir Veimo

I'm trying to use jdom in a webapp under tomcat-4.0beta. jdom requires a
DOM Level 2 and SAX 2.0 compliant parser, thus I want to use the latest
xerces. 

Option 1: How can I configure so that xerces.jar is before crimson.jar
in the servlet container claspath?

Option 2: How can I make shure that crimson.jar is not before xerces.jar
in the classpath when putting xerces.jar in WEB-INF/lib in my web-app?

Option 3: Is it possible to rip out crimson from catalina, replacing it
with xerces?
-- 
- Torgeir



problems with jdom tomcat4.0dev (24. april)

2001-05-21 Thread Torgeir Veimo

I'm having problems using jdom in a servlet with the following code;

SAXBuilder builder = new SAXBuilder();

builder.setErrorHandler (new org.xml.sax.ErrorHandler () {
public void warning (org.xml.sax.SAXParseException e) {
cat.warn (e.getMessage ()); }
public void error (org.xml.sax.SAXParseException e) {
cat.error (e.getMessage ()); }
public void fatalError (org.xml.sax.SAXParseException e) throws
org.xml.sax.SAXException {
cat.error (e.getMessage ()); throw e; }
});

builder.setValidation(false);
doc = builder.build(configURL);

This results in a java.lang.NosuchMethodError. I'm using jdom-beta6. It
appears that the xml parser that it retrieves in not whan jdom expects. 

Could someone explain exactly which parsers are included with tomcat
4.0?

-- 
- Torgeir



getResource() for files such as /WEB-INF/app.properties?

2001-05-07 Thread Torgeir Veimo

In the J2EE blueprint, there is an example of a configuration file
residing in the /WEB-INF/ directory which is loaded using getResource(),
see eg. http://java.sun.com/j2ee/blueprints/sample_application/qanda/

excerpt;

Here is some sample code that gets a configuration file from the
WEB-INF/ directory and parses it as XML.

URL myURL = null;
try {
myURL = context.getResource(/WEB-INF/mysettings.xml);
} catch (java.net.MalformedURLException ex) {
System.out.println(Malformed URL exception:  + ex);
}

...

However, when doing this in tomcat 4.0dev (April 24th snapshot), the
getResource() method only returns null.

Is this supported in tomcat, or does getResource() only return things
that are in the classpath?

I there any other nice way of loading a property / xml / other file
from the WEb-INF directory?


-- 
- Torgeir



using ant for web-app deployment

2001-04-17 Thread Torgeir Veimo

I want to use Ant for deployment of a web-app into a tomcat 4.0 instance
that initially doesn't know about the web-app, thus there is not Context
section for that web-app in server.xml. Thus it's not enough to simply
create / copy a web-application directory under
jakarta-tomcat-4.0/webapps. 

Does anyone have any working example of how to automatically alter the
server.xml file to include a newly added web-application? 

-- 
- Torgeir



Re: Authentication with JDBC but without JDBCRealms

2001-04-17 Thread Torgeir Veimo

Joo Folha wrote:
 
 Hi there, i need some inspiration here.
 I want my application to be independent of JDBCRealms, any example.
 
 I dont know how to protect the resources from de web.xml file.

You mean you want to use container based authentication, ie. a *Realm,
but to specify the details in the web.xml file?

This is not supported, the Realm can only specified in the server.xml
file, and be shared among all Context's.

-- 
- Torgeir



taglib for preferences?

2001-04-10 Thread Torgeir Veimo

I need to insert strings and other small bits in my JSP's which I would
like to have defined in eg. xml files.

Is there any taglib around that can do this?

-- 
- Torgeir



server.xml DTD

2001-04-06 Thread Torgeir Veimo

I cannot find any DTD for the server.xml file. Is there such a thing?

-- 
- Torgeir



Re: XSLT vs. JSP

2001-04-06 Thread Torgeir Veimo

See www.oreilly.com. 
-- 
- Torgeir



Context Realm

2001-04-05 Thread Torgeir Veimo

I'm trying to use Realms on a per Context / web-app basis. I am able to
specify a Realm outside of a Context/Context, but if I put a
Realm/Realm inside a context, it is ignored. 

I'm using tomcat 4.0beta3. Is this supported in this release?

Also, I could live with having a singleton Realm, if I could get the
configured Realm name as defined in the web.xml file for each web-app in
the authenticate() method of the realm, but this seems to be available
only when doing digest authentication. Is there a good reason for this?

-- 
- Torgeir



pause after tomcat startup script runs?

2001-04-03 Thread Torgeir Veimo

Is it possible to insert a "pause" command into the tomcat startup
script, so that any exceptions that occur that prevents catalina from
starting are readable?

I tried putting pause into the catalina.bat file, but it didn't work.
-- 
- Torgeir



resource factories?

2001-03-29 Thread Torgeir Veimo

I'm struggling a bit with setting up a resource factory for
DirContext's. 

I have a ContextPool class that has an empty constructor and setter
methods for the params I want to set.

I preferrably want to use this resource factory on a per-web-application
level. Can I do that? The reason is that different web applications uses
different providerURL's, and this leads to connections to different LDAP
servers.

If I set this up on a web application level; Should I use
resource-ref-env or resource-ref? And why can't I use init-param to set
the parameters? 

If I need to set this up in the server.xml file, is there still a way of
defining this on a Context level? What syntax do I use to specify a
resource factory in the server.xml file?

Lastly; is there no way of using initCtx.lookup("java:comp/env/blabla")
in a realm class?

-- 
- Torgeir



Re: resource factories?

2001-03-29 Thread Torgeir Veimo

I'm using tomcat4.0beta1 btw. 


-- 
- Torgeir



LdapRealm

2001-03-28 Thread Torgeir Veimo

Is there any impl of this somewhere allready?

-- 
- Torgeir



PLEASE fix mailing list bounces!

2001-03-28 Thread Torgeir Veimo

Could somebody PLEASE fix this mailing list so that bouncing messages
doesn't go back to the poster!

This is VERY ANNOYING!

-- 
- Torgeir



Re: LdapRealm

2001-03-28 Thread Torgeir Veimo

GOMEZ Henri wrote:
 
 I may try to do something to TC 3.3 if nobody volunteer

I allready have some initial code. I don't handle digest authentication,
and don't search for group membership to determine roles yet, but it's a
start. I'm working with 4.0beta.

I would be very happy for feedback on this code.

-- 
- Torgeir

package com.ecomda.ldap;

import java.beans.*;
import java.security.Principal;
import java.io.*;
import java.util.*;
import org.apache.catalina.Container;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.util.*;
import org.apache.catalina.util.xml.*;
import org.xml.sax.AttributeList;
import javax.naming.*;
import javax.naming.directory.*;

import org.apache.catalina.realm.*;

import com.ecomda.ldap.security.*;

public class LdapRealm extends RealmBase {

protected static final String info = "ecomda.ldap.LdapRealm/1.0";
protected static final String name = "LdapRealm";

private Container   container = null;
private HashMap principals = new HashMap();
private static  StringManager sm = StringManager.getManager(Constants.Package);
private boolean started = false;

protected StringsearchBase;
protected StringproviderURL;
protected StringauthMechanism;

public String getInfo() { return info; }
public String getName() { return name; }

public LdapRealm() { authMechanism = "simple"; }

public void setProviderURL(String providerURL) {
if (debug  1)
System.out.println("setting providerURL: " + providerURL);
this.providerURL = providerURL;
}

public void setSearchBase(String searchBase) {
if (debug  1)
System.out.println("setting searchBase: " + searchBase);
this.searchBase = searchBase;
}

public void setAuthMechanism(String authMechanism) {
if (debug  1)
System.out.println("setting authMechanism: " + authMechanism);
this.authMechanism = authMechanism;
}

public Principal authenticate(String username, String credentials) {

String dn = "uid="+ username + ", " + searchBase;

// First check if we have cached info on this user.
LdapRealmPrincipal principal = (LdapRealmPrincipal) principals.get(username);
if ((principal != null)  principal.checkCredentials(dn, credentials)) {  
  
if (debug  1)
log(sm.getString("ldapRealm.authenticateSuccess", username));
return (principal);
} 

// FIX! How do we age and remove old cached principals? Maybe use soft 
references?.

// If not, try authenticate to LDAP server.
try {
if (debug  1)
System.out.println("trying to authenticate with dn: " + dn + ", to 
URL: " + providerURL);

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, 
"com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, providerURL);
env.put(Context.SECURITY_AUTHENTICATION, authMechanism);
env.put(Context.SECURITY_PRINCIPAL, dn);
env.put(Context.SECURITY_CREDENTIALS, credentials);

DirContext ctx = new InitialDirContext(env);
ctx.lookup(dn);

if (debug  1)
log(sm.getString("ldapRealm.authenticateSuccess", username));

principal = new LdapRealmPrincipal(dn, credentials);
principals.put(username, principal);

return principal;

} catch (NamingException ne) {
if (debug  1)
log(sm.getString("ldapRealm.authenticateFailure", username));
}
return null;
}

protected String getPassword(String username) { return null; }

public boolean hasRole(Principal principal, String role) {

// FIX! should we really define this static role?
if (role.equalsIgnoreCase("authenticated")) 
return true;

if ((principal == null) || (role == null) || !(principal instanceof 
LdapRealmPrincipal))
return (false);

boolean result = ((LdapRealmPrincipal) principal).hasRole(role);
if (debug  1) {
String name = principal.getName();
if (result)
log(sm.getString("ldapRealm.hasRoleSuccess", name, role));
else
log(sm.getString("ldapRealm.hasRoleFailure", name, role));
}
return (result);
}


void addUser(String username, String password, String roles) {
LdapRealmPrincipal principal = new LdapRealmPrincipal(username, password);
principals.put(username, principal);

roles += ",";

while (true) {
int comma = roles.indexOf(",");
if (comma  0)
break;
String role = roles.substring(0, comma).trim();

Re: PLEASE fix mailing list bounces!

2001-03-28 Thread Torgeir Veimo

Randy Layman wrote:
 
 The problem is that neither are directly subscribed to the list -
 they are the result of mail forwards (I've already asked Craig about this).
 The only way to find the bad addresses would be to send an email to every
 address separately and determine which outgoing message produced the
 failure.

And it IS possible to do just that without interfering with normal
operation; just add a random character (to a header field which get
replied) for each normal ML message which is different for each
recipient. 

-- 
- Torgeir



realm resource factories

2001-03-28 Thread Torgeir Veimo

We use a realm implementation that will use a resource factory in the
same way as a servlet uses it.

Since the realm is specified on an engine level, and not on a web
application level, we need to use an indirection to get to the correct
resource factory based on which web application the realm is currently
authenticating for. (We do this because we reuse connections on a per
web application basis).

I don't know the best way of doing this. 

Can I get some information from the container that can allow me to do
jndi style resource factory lookup automagically, without knowing what
web application the realm is currently authenticating for?


-- 
- Torgeir



Re: Compressing Tomcat output.

2001-03-27 Thread Torgeir Veimo

I think this can most easily be done by apache using a gzip module that
automatically compresses all responses if accepted by the client. 

-- 
- Torgeir



JaasRealm / LdapRealm

2001-03-26 Thread Torgeir Veimo

I tried to find info on any possible implementation of one of these in
the ML archive, but didn't find anything except a pointer to Interceptor
sources from a wrox book example.

Are there anyone currently working on this?

-- 
- Torgeir