Applet and JavaWebService on Apache-Axis (SOAP)
Hello!
I have build a java-applet - it works fine.
Then I have installed tomcat with axis and I developed a very easy JavaWebService.
For better understanding: I saved the class:
publicclass test
{
publicdouble testMethode( String job,double x )
{
if("Quadrat".equalsIgnoreCase( job ) )
return x * x;
if("Sqrt".equalsIgnoreCase( job ) )
return Math.sqrt( x );
return 0.;
}
}
in my apache-tomcat-(with axis)-directory as ../apache-tomcat/webapps/axis/test.jws. I do all the things I describe here on my "localhost".
Then I appended the following code to my applet:
Object webservicereturn=null;
try{
String wsEndpoint ="http://localhost:8080/axis/test.jws";
String wsMethod="testMethode";
**** Service service=new Service(); *********************************************
Callcall= (Call)service.createCall();
call.setTargetEndpointAddress(new URL( wsEndpoint ) );
call.setOperationName( wsMethod );
call.addParameter("job", Constants.XSD_STRING, ParameterMode.IN );
call.addParameter("x",Constants.XSD_DOUBLE, ParameterMode.IN );
call.setReturnType( Constants.XSD_DOUBLE );
webservicereturn = call.invoke(new Object[]{"Sqrt",new Double("12.7" )} );
}
catch(Exception ex){}
JOptionPane.showMessageDialog(webservicereturn.toString() ... );
When I start the applet as a java-application the JOptionPane contains the expected value.
THE PROBLEM:
When I start the applet as an applet in my firefox there is no JOptionPane but a beautiful security-exception:
Java Plug-in 1.6.0
Verwendung der JRE-Version 1.6.0 Java HotSpot(TM) Client VM
....
java.lang.ExceptionInInitializerError
at org.apache.commons.discovery.jdk.JDKHooks.<clinit>(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.<clinit>(LogFactory.java:33)
at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:43)
at org.apache.axis.client.Service.getAxisClient(Service.java:104)
at org.apache.axis.client.Service.<init>(Service.java:113)
*****at LNdW_Applet.init(LNdW_Applet.java:35) *************************************
at sun.applet.AppletPanel.run(AppletPanel.java:417)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.security.AccessControlException: access denied (java.lang.RuntimePermission createClassLoader)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkCreateClassLoader(SecurityManager.java:594)
at java.lang.ClassLoader.<init>(ClassLoader.java:225)
at org.apache.commons.discovery.jdk.PsuedoSystemClassLoader.<init>(PsuedoSystemClassLoader.java:73)
at org.apache.commons.discovery.jdk.JDK12Hooks.findSystemClassLoader(JDK12Hooks.java:215)
at org.apache.commons.discovery.jdk.JDK12Hooks.<clinit>(JDK12Hooks.java:73)
... 13 more
(The **** are corresponding in this code-block with the **** in the previous code-block.)
I thought that my applet can connect to the same server where it comes from (in this case my localhost).
I am wondering about why the exception is just caused by the instruction "new Service();".
What must I type in my code that also the applet can use the local web-service "test" ? What is wrong?
Thanks for answering ...
Markus

