10/22/2010

glassfish-web.xml and sun-web.xml examples

The following glassfish-web.xml and sun-web.xml have the same content. glassfish-web.xml (the new name for sun-web.xml) is the file for specifying additional web app (WAR) configuration in GlassFish 3.1.

sun-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app>
<context-root>different-name</context-root>

<security-role-mapping>
<role-name>admin</role-name>
<principal-name>js</principal-name>
<group-name>manager</group-name>
</security-role-mapping>

<ejb-ref>
<ejb-ref-name>ejb/helloBean</ejb-ref-name>
<jndi-name>HelloBean</jndi-name>
</ejb-ref>

<resource-ref>
<res-ref-name>jdbc/dataSource</res-ref-name>
<jndi-name>jdbc/__default</jndi-name>
<default-resource-principal>
<name>guest</name>
<password>guest</password>
</default-resource-principal>
</resource-ref>
<class-loader delegate="true"/>
</sun-web-app>
glassfish-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<context-root>different-name</context-root>

<security-role-mapping>
<role-name>admin</role-name>
<principal-name>js</principal-name>
<group-name>manager</group-name>
</security-role-mapping>

<ejb-ref>
<ejb-ref-name>ejb/helloBean</ejb-ref-name>
<jndi-name>HelloBean</jndi-name>
</ejb-ref>

<resource-ref>
<res-ref-name>jdbc/dataSource</res-ref-name>
<jndi-name>jdbc/__default</jndi-name>
<default-resource-principal>
<name>myname</name>
<password>password</password>
</default-resource-principal>
</resource-ref>
<class-loader delegate="true"/>
</glassfish-web-app>