To run the tutorial examples in NetBeans IDE, you must register your GlassFish Server installation as a NetBeans Server Instance. Follow these instructions to register the GlassFish Server in NetBeans IDE.
Select Tools -> Server Manager to open the Servers dialog.
Click Add Server.
Under Server, select GlassFish v3 and click Next.
Under Platform Location, browse to or enter the location of your GlassFish Server installation.
Under Domain, use the drop-down list to select an existing domain, type in the path to the domain directly in the field, or type the name of a new domain to create.