woensdag 10 oktober 2007

Spring and Sun Application server 8.2

I'm currently working on a project that must run on a Sun Application Server version 8.2. While setting up the webflow and template jsp pages I got the following exception:

java.lang.IllegalStateException: Unexpected reflection exception - java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)
at org.springframework.util.ReflectionUtils.handleReflectionException(ReflectionUtils.java:136)
at org.springframework.core.ReflectiveVisitorHelper.invokeVisit(ReflectiveVisitorHelper.java:100)
at org.springframework.core.style.DefaultValueStyler.style(DefaultValueStyler.java:56)
at org.springframework.core.style.StylerUtils.style(StylerUtils.java:47)
at org.springframework.webflow.engine.TransitionableState.getRequiredTransition(TransitionableState.java:80)
at org.springframework.webflow.engine.TransitionableState.onEvent(TransitionableState.java:107)
at org.springframework.webflow.engine.Flow.onEvent(Flow.java:534)

Ouch
! So, I tested the same ear on a JBoss instance, and that worked without a problem. After doing some research I figured out that the sun application server is starting up with the following system property:

-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy

And yes, that is causing the AccessControlException, because the spring framework isn't allowed to do reflection. So how can we solve this?

Solution one: In the domain.xml file put the following line in comments
-Djava.security.policy=${com.sun.aas.instanceRoot}/config/server.policy

Solution two: Start editing the server.policy file for the domain. This is the most secure solution, but as solution one is much easier, I would pick that one. Also because the customer will be responsible for his own server in production.

Geen opmerkingen: