Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

DB Object getting JNDI connection doesnt work #1115

Closed
btd opened this Issue Sep 17, 2011 · 4 comments

Comments

Projects
None yet
4 participants

btd commented Sep 17, 2011

Hello. I try to use Lift 2.4-M4 Scala 2.9.1.

In Boot.scala i add such code:

DefaultConnectionIdentifier.jndiName = "jdbc/db"
logger.warn("JNDI connection available (manyally) ? " + (((new
InitialContext).lookup("java:/comp/env/jdbc/
db").asInstanceOf[DataSource]) != null))
logger.warn("JNDI connection available (lift) ? " +
DB.jndiJdbcConnAvailable_?)

And in logs i see:

10:56:55.531 [main] WARN bootstrap.liftweb.Boot - JNDI connection
available (manyally) ? true
10:56:55.546 [main] WARN bootstrap.liftweb.Boot - JNDI connection
available (lift) ? false
10:56:55.718 [ForkJoinPool-1-worker-2] INFO
o.a.sshd.common.util.SecurityUtils - BouncyCastle not registered,
using the default JCE provider
2011-09-12 10:56:55.953:INFO:oejs.AbstractConnector:Started
SelectChannelConnector@0.0.0.0:8080 STARTING

Therefore i cannot use jndi with DB object. Can anyone suggest
workaround or said where i can be wrong?

For me problems in two methods:

def jndiJdbcConnAvailable_? : Boolean = {
try {
((new InitialContext).lookup("java:/comp/
env").asInstanceOf[Context].lookup(DefaultConnectionIdentifier.jndiName).asInstanceOf[DataSource].getConnection) !
= null
} catch {
case e => false
}
}

And

private def newConnection(name: ConnectionIdentifier): SuperConnection
= {
...
val conn = (new InitialContext).lookup("java:/comp/
env").asInstanceOf[Context].lookup(name.jndiName).asInstanceOf[DataSource].getConnection
....
ret.setAutoCommit(false)
ret
}

Forgot to add that i use xsbt 0.10.1 and Jetty 8 from Eclipse. I test
JNDI with java web application and it works.

I test application on Oracle Application Server 11g and get such logs:

JNDI connection available (lift) ? true
JNDI connection available (manyally) ? true

With glassfish 3.1 i get such results:

JNDI connection available (manyally) ? - instead of this i got exception

JNDI connection available (lift) ? false

For glassfish need to lookup in such way:

Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("jdbc/sample");

Owner

dpp commented Sep 17, 2011

Please discuss issue on the Lift google group before opening tickets.

btd commented Sep 17, 2011

I am sorry.
First of all i wrote a post in google group, but noone see it. Then i wrote in github to indrajitr but he didnt answer. Then i create pull request with fix of this error (btd/framework@f0097d8) and jeppenejsum said that i need to create ticket and i create.

Owner

jeppenejsum commented Nov 8, 2011

(In [[r:d9c6e7c10b44c7581792419e99360f4007ee02b0]]) Added more methods for looking up a connection using JNDI, compatible with Glassfish.
Added diagnostic logging related to connections.

Closes #1115

Branch: master

@jeppenejsum jeppenejsum was assigned Mar 1, 2012

@etorreborre etorreborre pushed a commit to etorreborre/framework that referenced this issue Dec 3, 2014

@jeppenejsum jeppenejsum Added more methods for looking up a connection using JNDI, compatible…
… with Glassfish.

Added diagnostic logging related to connections.

Closes #1115
d9c6e7c

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment