NetBeans - “sun-resources.xml” vs. “glassfish-resources.xml”

只谈情不闲聊 提交于 2019-12-01 16:33:44

问题


Do you know how Netbeans decides which filename to use for the application-scoped resources: sun-resources.xml or glassfish-resources.xml? Is this name configurable or hard-coded?

As far as I understand GlassFish supports sun-resources.xml for backward compatibility. But according to "Application Deployment Guide" preferred filename is glassfish-resources.xml.

I run relatively recent version of Netbeans - 8.0.2 with GlassFish 4.1, but I get generated sun-resources.xml file. This looks odd and confusing.

On the other hand I've seen people having troubles with glassfish-resources.xml: https://netbeans.org/bugzilla/show_bug.cgi?id=243034. And the recommended solution is to rename glassfish-resources.xml to sun-resources.xml - also contradicting with GlassFish recommendations.

Best Regards


回答1:


First, let's set the expectation that in the Netbeans source, Glassfish is supposed to be able to use both files. The server configuration is generally packaged in the CommonServerSupport class.

Also, it's not configurable.

From what I can see in the Netbeans source however, the glassfish-resource.xml file is never going to be used. Here's why:

  1. The default setting should be the glassfish-resource.xml, based on what I can infer from the deployResources() method. This method in turn depends on registerResourceDirs()

  2. The problem starts when succeeded is never updated to true to indicate that glassfish-resource.xml was successfully created and should be used.

  3. What then ends up happening is that deployResources() tries to use sun-resources.xml anyway, as a fallback:

    if (!usedNewName) {
       // try to use sun-resources.xml
       registerResourceDir(resourceDir,dm,"sun-resources"); // NOI18N
     }
    

I should mention that this bug was introduced in NB 8.0; 7.3 doesn't appear to have the same problem




回答2:


For the record, I bumped in the same problem while going through the AffableBean tutorial with NetBeans 8.2 and Glassfish 5.0.

It appears that the glashfish-resources.xml file has been by default created under the web/WEB-INF folder. It is then ignored by Glassfish during the deploy phase.

Moving the file under the /setup directory via the "Files" window solve the problem and the resource and pool are created after a deploy launched via NetBeans.



来源:https://stackoverflow.com/questions/28256428/netbeans-sun-resources-xml-vs-glassfish-resources-xml

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