Glassfish Server Error when deploy .war: Error occurred during deployment: Exception while preparing the app : Invalid resource

守給你的承諾、 提交于 2019-12-05 05:53:53

Now I have the solution. I forgot the JDBC Resource: Open the Glassfish-Server Webinterface and navigate to Resources -> JDBC -> JDBC Resources and create a new one with the right Connection Pool. If the Resource and the Connection Pool are missing, the deployment will fail!!! It worked for me without java:app/webservice...

I had this same issue and it manifested in a great holabaloo of various strange exceptions that had absolutely nothing to do with my actual issue.

What's happened?

For some reason the resource for jdbc/[your resource name] has not been created in GlassFish and it throws you a jdbc/[your resource name]__[generated thing, like "pm"] as the source.

What to do?

One way (the one I used) to fix this is to manually go into your GlassFish admin console in the browser at localhost:4848 and in the menu to the left go to Resources and follow the tree inside it: JDBC > JDBC resources. In the JDBC Resources tab you create a new resource and name it jdbc/[your resource name] the __[generated thing, like "pm"] is not necessary.

BUT THAT DIDN'T WORK SO NOW WHAT DO I DO?!

This is exactly what happened to me and this is where I started getting the weird exceptions, like how it suddenly couldn't find my DB driver, even though I was staring at it in my dependencies folder.

How do I fix that then?

Restart NetBeans, refresh GlassFish and restart it if you have to. Run project and it should deploy.

(I found the source of my problem from an exception about a MDB and when I removed it, it suddenly worked with my added resource, and then I could re-name it to whatever I wanted as long as there was a matching resource in GlassFish. You may need to have a lookover of your MDB JNDI settings in GlassFish as well and manually create a resource for them)

Extra tip:

NetBeans will autocomplete existing resources when you're writing the <jta-data-source> tag. If it doesn't autocomplete, it probably doesn't exist.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!