Custom realm in Sun AS 8.2 throws com.sun.enterprise.InvocationException

Hi,

I have written a database security realm for Sun AS 8.2. In this realm, I look up a datasource that I configured in my domain, but I'm getting the following error:

[#|2007-04-18T12:55:25.712-0400|WARNING|sun-appserver-pe8.2|javax.enterprise.system.container.web|_ThreadID=11;|Web login failed:

Login failed: javax.security.auth.login.LoginException: com.sun.enterprise.InvocationException

at com.sun.enterprise.resource.ResourceManagerImpl.getTransaction(ResourceManagerImpl.java:41)

at com.sun.enterprise.resource.PoolManagerImpl.getResource(PoolManagerImpl.java:143)

at com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:276)

at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:145)

at com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:121)

at com.sun.gjc.spi.DataSource.getConnection(DataSource.java:70)

at xxx.xxx.realm.MyRealm.getConnection(MyRealm.java:276)

The below is the jdbc configuration and the method that throws the exception.

-- from domain.xml. I've read some postings that said to suffix my resource with '__pm', but it doesn't seem to be working either.

<jdbc-resource enabled="true" jndi-name="jdbc/mydb" object-type="user" pool-name="MyDBConnectionPool"/>

<jdbc-resource enabled="true" jndi-name="jdbc/mydb__pm" object-type="user" pool-name="MyDBConnectionPool"/>

-- In the realm, I have this method that looks up the datasource and get connection.

private Connection getConnection()throws LoginException

{

Connection connection =null;

try{

Context ctx=new InitialContext();

DataSource ds = (DataSource)ctx.lookup("jdbc/mydb__pm");

if (ds ==null)

{

thrownew LoginException("could not get DataSource " + ds);

}

connection = ds.getConnection();

if (connection ==null)

{

thrownew LoginException("could not create Connection");

}

}catch (NamingException e){

thrownew LoginException("Login failed due to an exception: " + e.getMessage());

}catch (SQLException e){

thrownew LoginException("Login failed due to an exception: " + e.getMessage());

}

return connection;

}

Could you please help me resolve this problem?

Thanks,

seanj

[3774 byte] By [seanja] at [2007-11-27 1:30:24]
# 1

can you post the build of appserver

ASINSTALL_ROOT/bin/asadmin version --verbose

Also, you can try using "getNonTxConnection()" of com.sun.appserv.jdbc.DataSource instead of getConnection()

you can cast the datasource that you lookup to "com.sun.appserv.jdbc.DataSource"

and then use "getNonTxConnection()".

Jagadish.Prasatha at 2007-7-12 0:31:36 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...