users@glassfish.java.net

problems with Application Client Container and JAXB

From: <mark_at_javector.com>
Date: Wed, 25 Jan 2006 22:06:16 -0700

I'm getting an AccessControlException when I try to create a JAXBContext inside
a Main-Class executed within the Application Client Container.

Perhaps this is a bug? I saw some other access control related bugs related to
the appclient.

Trace and client code:

appclient-run:
    [exec] Jan 25, 2006 11:32:45 PM com.sun.enterprise.appclient.Main <init>
    [exec] WARNING: ACC003: Application threw an exception.
    [exec] java.security.AccessControlException: access denied
(java.lang.RuntimePermission accessDeclaredMembers)
    [exec] at
java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
    [exec] at
java.security.AccessController.checkPermission(AccessController.java:427)
    [exec] at
java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
    [exec] at
java.lang.SecurityManager.checkMemberAccess(SecurityManager.java:1662)
    [exec] at java.lang.Class.checkMemberAccess(Class.java:2125)
    [exec] at java.lang.Class.getDeclaredConstructor(Class.java:1952)
    [exec] at
com.sun.xml.bind.v2.model.nav.ReflectionNavigator.hasDefaultConstructor(ReflectionNavigator.java:417)
    [exec] at
com.sun.xml.bind.v2.model.nav.ReflectionNavigator.hasDefaultConstructor(ReflectionNavigator.java:22)
    [exec] at
com.sun.xml.bind.v2.model.impl.ClassInfoImpl.<init>(ClassInfoImpl.java:147)
    [exec] at
com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.<init>(RuntimeClassInfoImpl.java:52)
    [exec] at
com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(RuntimeModelBuilder.java:59)
    [exec] at
com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createClassInfo(RuntimeModelBuilder.java:41)
    [exec] at
com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:123)
    [exec] at
com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
    [exec] at
com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
    [exec] at
com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
    [exec] at
com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:204)
    [exec] at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:330)
    [exec] at
com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:199)
    [exec] at
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
    [exec] at
com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
    [exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [exec] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [exec] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [exec] at java.lang.reflect.Method.invoke(Method.java:585)
    [exec] at
javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:210)
    [exec] at javax.xml.bind.ContextFinder.find(ContextFinder.java:368)
    [exec] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:561)
    [exec] at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:508)
    [exec] at samples.Client.doTest(Client.java:64)
    [exec] at samples.Client.main(Client.java:27)
    [exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [exec] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    [exec] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    [exec] at java.lang.reflect.Method.invoke(Method.java:585)
    [exec] at
com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:232)
    [exec] at com.sun.enterprise.appclient.Main.<init>(Main.java:682)
    [exec] at com.sun.enterprise.appclient.Main.main(Main.java:173)
    [exec] [ERROR] Result: 1

--------------------------


 public static void main(String[] args) throws Exception {

    Client client = new Client();
    client.doTest(args);

  }

  public void doTest(String[] args) throws Exception {

    // ..... snip .....

    RequestOrderService service = new RequestOrderService(
        new URL("http://localhost:8080/oms/requestOrder?wsdl"),
        new QName("http://www.example.com/req", "RequestOrderService"));
    RequestOrderPort port = service.getRequestOrderPort();
    JAXBContext jc = JAXBContext.newInstance(OrderType.class,
OrderRequestType.class);
    Marshaller m = jc.createMarshaller();
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    OrderType order = port.requestOrder(orderRequest);
    JAXBElement<OrderType> orderElement = new JAXBElement<OrderType>(
        new QName("","order"), OrderType.class, order);
    m.marshal(orderElement, System.out);

  }