I can not make my LoginModule to interact with database. When I try to access DataSource through JNDI, I get "object not bound" Exception. This is the code:
java.util.Properties prop = new java.util.Properties();
prop.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
prop.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
prop.put("java.naming.provider.url", "localhost:1099");
Context jndiCntx = new InitialContext(prop);
DataSource ds = (DataSource) jndiCntx.lookup("java:/MySqlDS");
(Just like in DatabaseServerLoginModule)
If I try to connect to database directly through DriverManager, I get ClassNotFoundException, although database driver jar file located in the proper default/lib directory.
Just can not not understand what I am doing wrong.
Has anyone expirienced the problem?
Looks like MySqlDS is not bound in java:/ in JNDI. Are you sure you have a *-ds.xml file in deploy that correctly defines your datasource?
Use JNDIView in jmx-console to verify your datasource object is bound.
http://localhost:8080/jmx-console/HtmlAdaptor
Mike