Sun Application Server 8.2 + Hibernate Gotchas!

For Hibernate to work in Sun Application Server 8.2, we need to change Sun App’s server.policy. Here is what we have to add:

grant {
  // Permission for cglib part of Hibernate framework
  permission java.lang.RuntimePermission "getProtectionDomain";
  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";

In Sun Application Server 8.2 Platform Edition, this server.policy file is located at [Sun App Install Path]/domains/[domain-name]/config folder. After applying this modification, the server needs to be restarted.

In Sun Application Server 8.2 Enterprise Edition, server.policy files exist in the domain and in each node-agents. Any alterations to configuration files, such as server.policy need to be made in the domain, rather than the node agent. If they are made in the node agent, then they will be overwritten the next time that the server instance is restarted. For making a change to a config file the approach would be:
1. stop the server instances
2. stop the node agent
3. stop the domain
4. change the config file(s) in the domain
5. start the domain
6. start the node agent (The node agent will start the server instances.)

If changes in the domain’s server.policy doesn’ get replicated in the node agents, you can use the ‘touch’ command on the file in the domain and restart the instance. ‘touch’ command updates the timestamp on the file. The node agent uses the timestamp on the file to work out whether it’s newer than in the server instance.

Failing to make changes in the server.policy will cause
java.lang.NoClassDefFoundError (without any detail which library it’s missing)