Equinox Hibernate Spring GlassFish

Jerome has an interesting entry about using Spring and Hibernate on GlassFish.

I looked at the entry that Matt Raible posted, and decided to see if I could help him....

I assume that Matt was trying to get Equinox to run on GlassFish. So, I tried to deploy and run it, myself.

Well, I can see why Matt had so much trouble. The installation instructions were very sketchy, but I was able to get things to work. Here is what I did:

  1. Get PostgreSQL installed and configured on my Mac... [That was a whole 'nother story].
  2. Downloaded Equinox
  3. Extracted it into /Volumes/300gb/equinox.
  4. Edited build.properties, to add the following
      server.home=/Volumes/300gb/glassfish
      
  5. Ran 'ant new -Dapp.name=test3'.
    This created a directory /Volumes/300gb/test3
  6. `cd /Volumes/300gb/test3`
  7. Ran 'ant test-all'
    The tomcat tests failed, but I pressed onward...
  8. Ran 'ant deploy'
    This created an new directory and content under /Volumes/300gb/glassfish/webapps/test3. I check it out and it looked like a web-app, so it was all good.
  9. I started up GlassFish.
  10. I ran 'asadmin deploydir /Volumes/300gb/glassfish/webapps/test3'.
    At this point, I saw exceptions just like Matt's. I took a deep breath and said to myself, "Don't panic, you can beat this. It is just a web-app!"
  11. I added the following lines to the server.policy file for the domain.
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/hibernate-3.1.jar" {
              permission java.util.PropertyPermission "\*", "read,write";
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/spring-1.2.6.jar" {
              permission java.util.PropertyPermission "\*", "read,write";
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/cglib-2.1_3.jar" {
              permission java.security.AllPermission;
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/commons-validator-1.1.3.jar" {
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
      grant codeBase "file:/Volumes/300gb/glassfish/webapps/test3/WEB-INF/lib/springmodules-validator-0.1.jar" {
              permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
      };
      
    Note: I did have to iterate (start the server, read the log, stop the server, change the server.policy file) a couple times to come up with this list.
  12. Once the server started up "clean", I went to "http://localhost:8080/test3" and things looked good.

    Until I pressed the "View Demonstration" button. That is when I got the error discussed in this thread.
  13. I used the Admin Console to change the server's classpath a bit...
  14. At this point, I was able to go through the demo without any problems (AFAICT).
One thing to remember, THIS IS ALL A HACK... I don't recommend that you change your server.policy file without good reason. If running Equinox is a "good reason", then I hope this entry helps you.

I would have used NetBeans 5.0 RC2 to do this, if I had needed to actually look at real code.

Comments:

Post a Comment:
Comments are closed for this entry.
About


Vince Kraemer writes the entries in this blog.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today
News
Blogroll

No bookmarks in folder

automarks