Glasshfish jndi lookup failed

Marcin picture Marcin · Apr 9, 2018 · Viewed 8.8k times · Source

I am new on stack, this is my first post, so sorry if I did something wrong. I'm trying to connect my glassfish 5 server with my MySQL database in NetBeans 8.2, but every time time I try to deploy my web application, glassfish console gives me

Exception while deploying the app [appname]: JNDI lookup failed for the resource: Name: [appnamePU], Lookup: [java:app/jdbc_blogdb], Type: [javax.sql.DataSource]


I have tried to reconfigure JDBC connection pools at glassfish admin panel, but after restarting the server it always returns this exception. I'm pasting screenshots of glassfish admin panel with JDBC resources and glassfish-resources.xml file as well. Do you have any idea, why glassfish doesn't want to cooperate with my database?

glassfish-resources.xml

JDBC Connection Pools

JDBC Resource

Full error from netbeans

[edit]
I forgot to add, that this error is shown only when i try to run and deploy my web application

Answer

Alok Sinha picture Alok Sinha · Apr 9, 2018

You would need to use this sub-context in the code for looking up-

java:comp/env/jdbc/jdbc_blogdb