Glassfish MySQL JNDI Lookup fails -
on glassfish 4.1.1 admin interface have setup jdbc resource named jdbc/mysql linked jdbc connection pool named mysql (modified domain.xml manually first). ping on connection pool successful. far good.
i modified web.xml , added:
<resource-ref> <description>db connection</description> <res-ref-name>jdbc/mysql</res-ref-name> <res-type>javax.sql.datasource</res-type> <res-sharing-scope>shareable</res-sharing-scope> </resource-ref> and glassfish-web.xml:
<resource-ref> <res-ref-name>jdbc/mysql</res-ref-name> <jndi-name>jdbc/mysql</jndi-name> </resource-ref> but in j2ee war, when do:
initialcontext ctx; datasource ds; ctx = new initialcontext(); ds = (datasource) ctx.lookup("java:comp/env/jdbc/mysql"); the result lookup failed.
removing java:comp/env/ did not help.
any hint appreciated! thank you.
regards john
ok, got work. resource enabled , modification in web.xml , glassfish-web.xml not needed, did in many attempts fix it.
but know reason was? slash in jndi name. found out today when pressed save button in admin panel of resource , got error 'resource jndi%2fmysql not exist'. took hint , name resource 'mysql'. fixed :) can confirm on glassfish 4.1.1.?
due bug in admin panel adding new resources, had insert domain.xml manually in beginning. maybe reason? default resources saved slash...
btw. lookup now:
ctx.lookup("mysql");
Comments
Post a Comment