วันอังคารที่ 18 พฤษภาคม พ.ศ. 2553

ปัญหาเรื่อง Sun Java™ System Application Server Platform Edition 8.2 เกิด Error "org.apache.commons.discovery.jdk.JDKHooks."

ปัญหาเรื่อง Sun Java™ System Application Server Platform Edition 8.2 เกิด Error "org.apache.commons.discovery.jdk.JDKHooks." ตามข้างล่าง เกิดจาก App server ไม่สามารถเข้าถึง เป็นปัญหาเรื่อง permission ของ JDK
Environment:
-JDK 1.4_2
-SunAppServer 8.2

[#|2010-05-18T13:25:50.546+0700|SEVERE|sun-appserver-pe8.2|javax.enterprise.system.container.web|_ThreadID=20;|StandardWrapperValve[action]: Servlet.service() for servlet action threw exception
java.lang.ExceptionInInitializerError
at org.apache.commons.discovery.jdk.JDKHooks.(JDKHooks.java:75)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:412)
at org.apache.commons.discovery.tools.DiscoverSingleton.find(DiscoverSingleton.java:378)
at org.apache.axis.components.logger.LogFactory$1.run(LogFactory.java:45)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
at org.apache.axis.components.logger.LogFactory.(LogFactory.java:33)
at org.apache.axis.handlers.BasicHandler.(BasicHandler.java:43)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.(Service.java:113)
at com.mfec.web.ws.WebService.verifyCreditCardProcess(WebService.java:38)
at com.mfec.web.struts.action.CreditCardInputAction.execute(CreditCardInputAction.java:347)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:767)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:860)
at sun.reflect.GeneratedMethodAccessor117.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604)
at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475)
at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371)
at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264)
at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281)
at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:269)
at java.security.AccessController.checkPermission(AccessController.java:401)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
at java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:586)
at java.lang.ClassLoader.(ClassLoader.java:210)
at org.apache.commons.discovery.jdk.PsuedoSystemClassLoader.(PsuedoSystemClassLoader.java:73)
at org.apache.commons.discovery.jdk.JDK12Hooks.findSystemClassLoader(JDK12Hooks.java:215)
at org.apache.commons.discovery.jdk.JDK12Hooks.(JDK12Hooks.java:73)
... 48 more
|#]

วิธีแก้ปัญหา: ให้ทำการแก้ไข permision ของ "java.policy"
path : C:\Program Files\Java\j2sdk1.4.2_04\jre\lib\security ให้ทำการ grant permision โดยเพิ่ม data เข้าไปดังนี้
.....
// start add by pradoem 20100518 sun app 8.2
permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "getClassLoader";
permission java.util.PropertyPermission "org.apache.commons.discovery.log.level", "read";
permission java.util.PropertyPermission "axis.EngineConfigFactory","read";
permission java.util.PropertyPermission "org.apache.axis.EngineConfigurationFactory" ,"read";
permission java.util.PropertyPermission "axis.ClientConfigFile","read";
permission java.util.PropertyPermission "axis.ServerConfigFile","read";
permission java.util.PropertyPermission "axis.xml.reuseParsers","read";
permission java.util.PropertyPermission "axis.attachments.implementation","read";
//end
.........
จากนั้นทำการ Restart Application Server ครับก็จะไม่เกิด Errors ดังกว่าแล้วครับ