javanetbeans-8.2glassfish-5

Glasshfish jndi lookup failed


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


Solution

  • In your glassfish-resources.xml add:

    <resources>
        <jdbc-resource 
            enabled="true" 
            jndi-name="jdbc/jdbc_blogdb" 
            object-type="user" 
            pool-name="connectionPool">
            <description/>
        </jdbc-resource>
        <jdbc-connection-pool
    
            ...
    
        </jdbc-connection-pool>
    </resources>
    

    And be certain that you have your jdbc jar in place. In case you don't know if you have it. Put your mysql jdbc jar in glassfish-[VERSION]\glassfish\domains\domain1\lib\ext

    Usually glassfish creates a default domain as domain1 ... if you have changed that, use your domain where is "domain1"