简体   繁体   中英

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

您需要在代码中使用此子上下文来查找-

java:comp/env/jdbc/jdbc_blogdb

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM