Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NetBeans - "sun-resources.xml" vs. "glassfish-resources.xml"

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

like image 963
Ebeneezer Avatar asked Jan 31 '15 20:01

Ebeneezer


2 Answers

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

like image 188
kolossus Avatar answered Nov 13 '22 19:11

kolossus


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.

like image 36
Bruno Sinou Avatar answered Nov 13 '22 20:11

Bruno Sinou