Markus Karg | 1 Feb 11:07 2011
Picon

Can we get rid of duplicate <at> Path?

We currently have the following code, which is prototypical for a POST / GET combination. POST is implemented by the root resource, and must return a location header pointing to the created sub resource. Then, a client can use that URI to GET a sub resource, implemented by a second class:

 

<at> Path("myroot") public class RootResource {

  <at> POST public post() {

   …create in database and request id from it…

    URI location = UriBuilder.fromResource(SubResource.class).build(…id from database…);

    return Response.created(location).build();

  }

  <at> Path("{id}") public SubResource getSubResource() {

    return new SubResource();

  }

}

 

<at> Path("{id}") public class SubResource {

  <at> GET public String get() {

    return … ;

  }

}

 

That works pretty well, but it is not smart that <at> Path is needed at both, the getSubResource() method AND the SubResource class.

 

I wonder if we can get rid of one of those, as the information provided by both actually is the same.

 

Thanks!

Markus

Paul Sandoz | 1 Feb 12:59 2011
Picon

Re: Can we get rid of duplicate <at> Path?


On Feb 1, 2011, at 11:07 AM, Markus Karg wrote:

> We currently have the following code, which is prototypical for a  
> POST / GET combination. POST is implemented by the root resource,  
> and must return a location header pointing to the created sub  
> resource. Then, a client can use that URI to GET a sub resource,  
> implemented by a second class:
>
>  <at> Path("myroot") public class RootResource {
>    <at> POST public post() {
>    …create in database and request id from it…
>     URI location = UriBuilder.fromResource(SubResource.class).build(… 
> id from database…);
>     return Response.created(location).build();
>   }
>    <at> Path("{id}") public SubResource getSubResource() {
>     return new SubResource();
>   }
> }
>
>  <at> Path("{id}") public class SubResource {
>    <at> GET public String get() {
>     return … ;
>   }
> }
>
> That works pretty well, but it is not smart that  <at> Path is needed at  
> both, the getSubResource() method AND the SubResource class.
>
> I wonder if we can get rid of one of those, as the information  
> provided by both actually is the same.
>

Is it intended that SubResource also be a root resource? i.e. /myroot  
and /{id} are valid paths, in addition to /myroot/{id}

If not you don't need  <at> Path on SubResource.

Paul.

Paul Sandoz | 1 Feb 13:06 2011
Picon

Re: Can we get rid of duplicate <at> Path?


On Feb 1, 2011, at 12:59 PM, Paul Sandoz wrote:

>
> On Feb 1, 2011, at 11:07 AM, Markus Karg wrote:
>
>> We currently have the following code, which is prototypical for a  
>> POST / GET combination. POST is implemented by the root resource,  
>> and must return a location header pointing to the created sub  
>> resource. Then, a client can use that URI to GET a sub resource,  
>> implemented by a second class:
>>
>>  <at> Path("myroot") public class RootResource {
>>   <at> POST public post() {
>>   …create in database and request id from it…
>>    URI location = UriBuilder.fromResource(SubResource.class).build(… 
>> id from database…);

In my haste i did not see the above. You definitely don't want to  
declare SubResource as a root resource.

   UriInfo ui = ...
   Method m = ...
   ui.getRequestUriBuilder().path(m).build(…id from database…);

it ain't ideal because it is a PITA to reference methods in Java.

Otherwise declare the "{id}" as a string constant and refer to that in  
the builder and the  <at> Path annotation on getSubResource method:

   UriBuilder.fromPath(ID_PATH).build(…id from database…);

Paul.

>>    return Response.created(location).build();
>>  }
>>   <at> Path("{id}") public SubResource getSubResource() {
>>    return new SubResource();
>>  }
>> }
>>
>>  <at> Path("{id}") public class SubResource {
>>   <at> GET public String get() {
>>    return … ;
>>  }
>> }
>>
>> That works pretty well, but it is not smart that  <at> Path is needed at  
>> both, the getSubResource() method AND the SubResource class.
>>
>> I wonder if we can get rid of one of those, as the information  
>> provided by both actually is the same.
>>
>
> Is it intended that SubResource also be a root resource? i.e. / 
> myroot and /{id} are valid paths, in addition to /myroot/{id}
>
> If not you don't need  <at> Path on SubResource.
>
> Paul.

Pavel Bucek | 1 Feb 13:49 2011
Picon

Re: JSON natural on GF 3.1 b40

Hello,

ah, my fault, sorry! I should realize sooner that api jar needs to go to endorsed dir.. it's good that you figured it out :)

we don't run tests on web profile because Jersey (or to be more precise, JSR311) is NOT part of web profile, see [1]. Nevertheless Jersey is contained in it because glassfish can't be started without jersey AFAIK (jersey is used in admin console component).. so your current setup with glassfish will work but don't be surprised if you will switch to another javaee6 web profile compliant appserver and something breaks..

Pavel

[1] http://www.oracle.com/technetwork/java/javaee/downloads/javaee6-standards-jsp-141130.html

On 01/31/2011 11:56 PM, jmilkiewicz wrote:
Hi

I managed to run it on full GF 3.1 b40 and everything works.
Next, I have copied jaxb jars you mentioned above to the following
locations (as in GF 3.1 full)
jaxb-api-osgi.jar to modules/endorsed
jaxb-osgi to modules

from now everything works as a charm.

regards

Jakub Milkiewicz

2011/1/31 [hidden email] <[hidden email]>:

> Hi Pavel
>
> Thanks for a fast answer but unfortunately it still does not work.
>
> 1 - adding jaxb-api-osgi-2.2.2.jar and jaxb-osgi-2.2.3-1.jar to GF 3.1
> modules folder
>    blows out glassfish: my application and admin console are not
> deployed/reachable.
> In my log file i can see:
>
> SEVERE: Exception while loading the app : java.lang.RuntimeException:
> java.lang.NullPointerException
> com.google.common.collect.ComputationException:
> java.lang.RuntimeException: java.lang.NullPointerException
>        at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)
>        at com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
>        at com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
>        at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:183)
>        at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:96)
>        at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:133)
>        at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:192)
>        at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:364)
>        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
>        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
>        at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:262)
>        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
>        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
>        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:354)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:369)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1080)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1260)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1248)
>        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:453)
>        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:220)
>        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
>        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
>        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
>        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
>        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
>        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
>        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
>        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
>        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
>        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
>        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
>        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
>        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
>        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
>        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
>        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.RuntimeException: java.lang.NullPointerException
>        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:71)
>        at org.jboss.weld.util.reflection.SecureReflections.getDeclaredFields(SecureReflections.java:111)
>        at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:163)
>        at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:124)
>        at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:54)
>        at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:42)
>        at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
>        ... 38 more
> Caused by: java.lang.NullPointerException
>        at org.apache.felix.framework.resolver.ResolverImpl.permutateIfNeeded(ResolverImpl.java:1140)
>        at org.apache.felix.framework.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1066)
>        at org.apache.felix.framework.resolver.ResolverImpl.resolve(ResolverImpl.java:176)
>        at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:4066)
>        at org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1412)
>        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:734)
>        at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>        at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
>        at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1604)
>        at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:904)
>        at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3$1.run(OSGiModuleImpl.java:399)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3.loadClass(OSGiModuleImpl.java:395)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>        at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:188)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
>        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
>        at java.lang.Class.getDeclaredFields0(Native Method)
>        at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
>        at java.lang.Class.getDeclaredFields(Class.java:1743)
>        at org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:116)
>        at org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:112)
>        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
>        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:67)
>        ... 44 more
>
> When comparing GF 3.0.1 b22 with GF 3.1 b40 i noticed that
> beside the latter having jaxb jars removed from modules folder i think
> there are some changes in felix config.properties file. Maybe i need
> to investigate it further...
>
>
> 2. adding  jaxb-osgi-2.2.3-1.jar  to WEB-INF/lib and setting
> class-loader delegate to false does not work either.
>
> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
> found. For the recent builds to get this working correctly, you need
> even at least JAXB version 2.1.12. Please add it to your classpath!
> SEVERE: The provider class, class
> pl.assetwell.demo.infrastructure.MyJAXBContextResolver, could not be
> instantiated. Processing will continue but the class will not be
> utilized
> java.lang.RuntimeException: NATURAL JSON notation configured, but JAXB
> RI 2.1.10 not found. For the recent builds to get this working
> correctly, you need even at least JAXB version 2.1.12. Please add it
> to your classpath!
>        at com.sun.jersey.api.json.JSONConfiguration.natural(JSONConfiguration.java:447)
>        at pl.assetwell.demo.infrastructure.MyJAXBContextResolver.<init>(MyJAXBContextResolver.java:25)
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>
>
> This time i think i know why it can't work:
> I understand that class-loader delegate=false forces application (war)
>  to first load classes itself before delegation to parent (server)
> classloader (PARENT-LAST).
> If my understanding is correct than this approach can not work since
> it is not class within my application is trying to load JAXB RI
> 2.1.12.  According to stacktrace (above) JSONConfiguration tries to
> check if proper version of JAXB is
> present by execution of:
> Class.forName("com.sun.xml.bind.annotation.OverrideAnnotationOf");
>
> Since JSONConfiguration is bundled in jersey-json.jar withing GF
> modules it will use it is own classloader or any other
> parent(server)/OSGI classloader to find  OverrideAnnotationOf class.
> None of these classloaders will have access to application
> classloader. Am i right on this ?
>
> I can imagine i could copy some jersey-jars along with jaxb jars to
> WEB-INF/lib  and then specify class-loader delegate=false  but this is
> not what i would like to do...
>
> I will try to  check it with full GF 3.1 b40 or another/new build.
>
>
> regards
> Jakub Milkiewicz
>
>
> 2011/1/31 Pavel Bucek-2 [via Jersey]
> <[hidden email]>:
>> Hello Jakub,
>>
>> generally - update your java runtime; unfortunately, we currently
>> available jdk versions don't have that recent jaxb version, so ..
>>
>> I guess putting jaxb-api-osgi.jar [1] and jaxb-osgi.jar [2] into
>> glassfish/modules should work that out. Or you can upgrade to full
>> profile, which provides newer jaxb implementation.
>>
>> Or, if you don't want to update your local glassfish installation, you
>> could be able to package jaxb-osgi.jar into war and deploy it with your
>> application; you might need to set classloader delegation to false
>> (sun-web.xml: <class-loader delegate="false"/>).
>>
>> Regards,
>> Pavel
>>
>> [1]
>> http://download.java.net/maven/2/javax/xml/bind/jaxb-api-osgi/2.2.2/jaxb-api-osgi-2.2.2.jar
>> [2]
>> http://download.java.net/maven/2/com/sun/xml/bind/jaxb-osgi/2.2.3-1/jaxb-osgi-2.2.3-1.jar
>>
>> On 01/31/2011 03:45 PM, [hidden email] wrote:
>>> Hi
>>>
>>> I am not sure if this mail should not be sent to glassfish user group
>>> but i hope i can find some help here:
>>>
>>> I am trying to use JSON natural notation
>>>
>>> JAXBContext context = new
>>> JSONJAXBContext(JSONConfiguration.natural().build()...
>>>
>>> The application worked as a charm on GF 3.0.1 but on GF 3.1. b40  web
>>> profile (current the latest one as of yesterday) i got a nasty
>>> exception with following header message:
>>>
>>> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
>>> found. For the recent builds to get this working correctly, you need
>>> even at least JAXB version 2.1.12. Please add it to your classpath!
>>> SEVERE: The provider class, class foo.bar.MyJAXBContextResolver, could
>>> not be instantiated. Processing will continue but the class will not
>>> be utilized
>>>
>>> Generally ,how to upgrade to JAXB 2.1 provided that JAXB 2 classes are
>>> already bundled within JDK?
>>>
>>>
>>> How to make an upgrade on GF 3.1 which does not have any of JAXB api/
>>> JAXB impl osgified versions at all ( GF 3.0.1 indeed had jaxb-api-osgi
>>> and jaxb-osgi.jar )  ?
>>>
>>> regards Jakub Milkiewicz
>>>
>>>
>>
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://jersey.576304.n2.nabble.com/JSON-natural-on-GF-3-1-b40-tp5977358p5977495.html
>> To start a new topic under Jersey, email
>> [hidden email]
>> To unsubscribe from Jersey, click here.
>

View this message in context: Re: JSON natural on GF 3.1 b40
Sent from the Jersey mailing list archive at Nabble.com.

Markus Karg | 1 Feb 14:00 2011
Picon

Re: Can we get rid of duplicate <at> Path?

Paul,

>> We currently have the following code, which is prototypical for a  
>> POST / GET combination. POST is implemented by the root resource,  
>> and must return a location header pointing to the created sub  
>> resource. Then, a client can use that URI to GET a sub resource,  
>> implemented by a second class:
>>  <at> Path("myroot") public class RootResource {
>>   <at> POST public post() {
>>   ...create in database and request id from it...
>>    URI location =
UriBuilder.fromResource(SubResource.class).build(... 
>> id from database...);
>   UriInfo ui = ...
>   Method m = ...
>   ui.getRequestUriBuilder().path(m).build(...id from database...);
> it ain't ideal because it is a PITA to reference methods in Java.
> Otherwise declare the "{id}" as a string constant and refer to that in

> the builder and the  <at> Path annotation on getSubResource method:
> UriBuilder.fromPath(ID_PATH).build(...id from database...);

thanks for sharing your ideas.

We had used both solutions before, but just thought there might be
something we missed in the spec. It seems, we didn't.

Sad but true that there is no UriBuilder.fromMethod(Class cls, String
method), because that would remove the need to fiddle with additional
UriInfo and Method, which both spoils the code a bit. It could be
implemented just like UriBuilder.fromPath("").path(Method) (which is
what we will use finally) -- I should file an RFE for JAX-RS 2.0. ;-)

Regards
Markus

jmilkiewicz | 1 Feb 14:16 2011
Picon

Re: JSON natural on GF 3.1 b40

Hi Pavel

Figuring it out took me some time but at least it works...
I didn't know that JAX-RS is not part of web profile. It's a big surprise to me.
Thx for an info.

regards
Jakub Milkiewicz


2011/2/1 Pavel Bucek-2 [via Jersey]
<[hidden email]>:


> Hello,
>
> ah, my fault, sorry! I should realize sooner that api jar needs to go to
> endorsed dir.. it's good that you figured it out :)
>
> we don't run tests on web profile because Jersey (or to be more precise,
> JSR311) is NOT part of web profile, see [1]. Nevertheless Jersey is
> contained in it because glassfish can't be started without jersey AFAIK
> (jersey is used in admin console component).. so your current setup with
> glassfish will work but don't be surprised if you will switch to another
> javaee6 web profile compliant appserver and something breaks..
>
> Pavel
>
> [1]
> http://www.oracle.com/technetwork/java/javaee/downloads/javaee6-standards-jsp-141130.html
>
> On 01/31/2011 11:56 PM, jmilkiewicz wrote:
>
> Hi
>
> I managed to run it on full GF 3.1 b40 and everything works.
> Next, I have copied jaxb jars you mentioned above to the following
> locations (as in GF 3.1 full)
> jaxb-api-osgi.jar to modules/endorsed
> jaxb-osgi to modules
>
> from now everything works as a charm.
>
> regards
>
> Jakub Milkiewicz
>
> 2011/1/31 [hidden email] <[hidden email]>:
>> Hi Pavel
>>
>> Thanks for a fast answer but unfortunately it still does not work.
>>
>> 1 - adding jaxb-api-osgi-2.2.2.jar and jaxb-osgi-2.2.3-1.jar to GF 3.1
>> modules folder
>>    blows out glassfish: my application and admin console are not
>> deployed/reachable.
>> In my log file i can see:
>>
>> SEVERE: Exception while loading the app : java.lang.RuntimeException:
>> java.lang.NullPointerException
>> com.google.common.collect.ComputationException:
>> java.lang.RuntimeException: java.lang.NullPointerException
>>        at
>> com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)
>>        at
>> com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
>>        at
>> com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
>>        at
>> org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:183)
>>        at
>> org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:96)
>>        at
>> org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:133)
>>        at
>> org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:192)
>>        at
>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:364)
>>        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
>>        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
>>        at
>> org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:262)
>>        at
>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
>>        at
>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
>>        at
>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:354)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:369)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1080)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1260)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1248)
>>        at
>> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:453)
>>        at
>> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:220)
>>        at
>> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
>>        at
>> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
>>        at
>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
>>        at
>> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
>>        at
>> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
>>        at
>> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
>>        at
>> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
>>        at
>> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
>>        at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
>>        at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
>>        at
>> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
>>        at
>> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
>>        at
>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
>>        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
>>        at
>> com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
>>        at
>> com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
>>        at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.RuntimeException: java.lang.NullPointerException
>>        at
>> org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:71)
>>        at
>> org.jboss.weld.util.reflection.SecureReflections.getDeclaredFields(SecureReflections.java:111)
>>        at
>> org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:163)
>>        at
>> org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:124)
>>        at
>> org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:54)
>>        at
>> org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:42)
>>        at
>> com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
>>        ... 38 more
>> Caused by: java.lang.NullPointerException
>>        at
>> org.apache.felix.framework.resolver.ResolverImpl.permutateIfNeeded(ResolverImpl.java:1140)
>>        at
>> org.apache.felix.framework.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1066)
>>        at
>> org.apache.felix.framework.resolver.ResolverImpl.resolve(ResolverImpl.java:176)
>>        at
>> org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:4066)
>>        at
>> org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1412)
>>        at
>> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:734)
>>        at
>> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>>        at
>> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>        at
>> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
>>        at
>> org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1604)
>>        at
>> org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:904)
>>        at
>> org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3$1.run(OSGiModuleImpl.java:399)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at
>> org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3.loadClass(OSGiModuleImpl.java:395)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>        at
>> com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:188)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>        at
>> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
>>        at
>> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
>>        at java.lang.Class.getDeclaredFields0(Native Method)
>>        at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
>>        at java.lang.Class.getDeclaredFields(Class.java:1743)
>>        at
>> org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:116)
>>        at
>> org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:112)
>>        at
>> org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
>>        at
>> org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:67)
>>        ... 44 more
>>
>> When comparing GF 3.0.1 b22 with GF 3.1 b40 i noticed that
>> beside the latter having jaxb jars removed from modules folder i think
>> there are some changes in felix config.properties file. Maybe i need
>> to investigate it further...
>>
>>
>> 2. adding  jaxb-osgi-2.2.3-1.jar  to WEB-INF/lib and setting
>> class-loader delegate to false does not work either.
>>
>> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
>> found. For the recent builds to get this working correctly, you need
>> even at least JAXB version 2.1.12. Please add it to your classpath!
>> SEVERE: The provider class, class
>> pl.assetwell.demo.infrastructure.MyJAXBContextResolver, could not be
>> instantiated. Processing will continue but the class will not be
>> utilized
>> java.lang.RuntimeException: NATURAL JSON notation configured, but JAXB
>> RI 2.1.10 not found. For the recent builds to get this working
>> correctly, you need even at least JAXB version 2.1.12. Please add it
>> to your classpath!
>>        at
>> com.sun.jersey.api.json.JSONConfiguration.natural(JSONConfiguration.java:447)
>>        at
>> pl.assetwell.demo.infrastructure.MyJAXBContextResolver.<init>(MyJAXBContextResolver.java:25)
>>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>>        at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>
>>
>> This time i think i know why it can't work:
>> I understand that class-loader delegate=false forces application (war)
>>  to first load classes itself before delegation to parent (server)
>> classloader (PARENT-LAST).
>> If my understanding is correct than this approach can not work since
>> it is not class within my application is trying to load JAXB RI
>> 2.1.12.  According to stacktrace (above) JSONConfiguration tries to
>> check if proper version of JAXB is
>> present by execution of:
>> Class.forName("com.sun.xml.bind.annotation.OverrideAnnotationOf");
>>
>> Since JSONConfiguration is bundled in jersey-json.jar withing GF
>> modules it will use it is own classloader or any other
>> parent(server)/OSGI classloader to find  OverrideAnnotationOf class.
>> None of these classloaders will have access to application
>> classloader. Am i right on this ?
>>
>> I can imagine i could copy some jersey-jars along with jaxb jars to
>> WEB-INF/lib  and then specify class-loader delegate=false  but this is
>> not what i would like to do...
>>
>> I will try to  check it with full GF 3.1 b40 or another/new build.
>>
>>
>> regards
>> Jakub Milkiewicz
>>
>>
>> 2011/1/31 Pavel Bucek-2 [via Jersey]
>> <[hidden email]>:
>>> Hello Jakub,
>>>
>>> generally - update your java runtime; unfortunately, we currently
>>> available jdk versions don't have that recent jaxb version, so ..
>>>
>>> I guess putting jaxb-api-osgi.jar [1] and jaxb-osgi.jar [2] into
>>> glassfish/modules should work that out. Or you can upgrade to full
>>> profile, which provides newer jaxb implementation.
>>>
>>> Or, if you don't want to update your local glassfish installation, you
>>> could be able to package jaxb-osgi.jar into war and deploy it with your
>>> application; you might need to set classloader delegation to false
>>> (sun-web.xml: <class-loader delegate="false"/>).
>>>
>>> Regards,
>>> Pavel
>>>
>>> [1]
>>>
>>> http://download.java.net/maven/2/javax/xml/bind/jaxb-api-osgi/2.2.2/jaxb-api-osgi-2.2.2.jar
>>> [2]
>>>
>>> http://download.java.net/maven/2/com/sun/xml/bind/jaxb-osgi/2.2.3-1/jaxb-osgi-2.2.3-1.jar
>>>
>>> On 01/31/2011 03:45 PM, [hidden email] wrote:
>>>> Hi
>>>>
>>>> I am not sure if this mail should not be sent to glassfish user group
>>>> but i hope i can find some help here:
>>>>
>>>> I am trying to use JSON natural notation
>>>>
>>>> JAXBContext context = new
>>>> JSONJAXBContext(JSONConfiguration.natural().build()...
>>>>
>>>> The application worked as a charm on GF 3.0.1 but on GF 3.1. b40  web
>>>> profile (current the latest one as of yesterday) i got a nasty
>>>> exception with following header message:
>>>>
>>>> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
>>>> found. For the recent builds to get this working correctly, you need
>>>> even at least JAXB version 2.1.12. Please add it to your classpath!
>>>> SEVERE: The provider class, class foo.bar.MyJAXBContextResolver, could
>>>> not be instantiated. Processing will continue but the class will not
>>>> be utilized
>>>>
>>>> Generally ,how to upgrade to JAXB 2.1 provided that JAXB 2 classes are
>>>> already bundled within JDK?
>>>>
>>>>
>>>> How to make an upgrade on GF 3.1 which does not have any of JAXB api/
>>>> JAXB impl osgified versions at all ( GF 3.0.1 indeed had jaxb-api-osgi
>>>> and jaxb-osgi.jar )  ?
>>>>
>>>> regards Jakub Milkiewicz
>>>>
>>>>
>>>
>>>
>>> ________________________________
>>> If you reply to this email, your message will be added to the discussion
>>> below:
>>>
>>> http://jersey.576304.n2.nabble.com/JSON-natural-on-GF-3-1-b40-tp5977358p5977495.html
>>> To start a new topic under Jersey, email
>>> [hidden email]
>>> To unsubscribe from Jersey, click here.
>>
>
> ________________________________
> View this message in context: Re: JSON natural on GF 3.1 b40
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://jersey.576304.n2.nabble.com/JSON-natural-on-GF-3-1-b40-tp5977358p5980808.html
> To start a new topic under Jersey, email
> [hidden email]
> To unsubscribe from Jersey, click here.

View this message in context: Re: JSON natural on GF 3.1 b40
Sent from the Jersey mailing list archive at Nabble.com.
Paul Sandoz | 1 Feb 14:22 2011
Picon

Re: JSON natural on GF 3.1 b40


On Feb 1, 2011, at 1:49 PM, Pavel Bucek wrote:

Hello,

ah, my fault, sorry! I should realize sooner that api jar needs to go to endorsed dir.. it's good that you figured it out :)

we don't run tests on web profile because Jersey (or to be more precise, JSR311) is NOT part of web profile, see [1]. Nevertheless Jersey is contained in it because glassfish can't be started without jersey AFAIK (jersey is used in admin console component)..

Although JAX-RS is not included it was always the plan to bundle Jersey with the GF distribution of the EE web profile so developers could use JAX-RS/Jersey.

I suspect most other EE vendors are likely to do the same.

Paul.

so your current setup with glassfish will work but don't be surprised if you will switch to another javaee6 web profile compliant appserver and something breaks..

Pavel

[1] http://www.oracle.com/technetwork/java/javaee/downloads/javaee6-standards-jsp-141130.html

On 01/31/2011 11:56 PM, jmilkiewicz wrote:
Hi

I managed to run it on full GF 3.1 b40 and everything works.
Next, I have copied jaxb jars you mentioned above to the following
locations (as in GF 3.1 full)
jaxb-api-osgi.jar to modules/endorsed
jaxb-osgi to modules

from now everything works as a charm.

regards

Jakub Milkiewicz

2011/1/31 [hidden email] <[hidden email]>:

> Hi Pavel
>
> Thanks for a fast answer but unfortunately it still does not work.
>
> 1 - adding jaxb-api-osgi-2.2.2.jar and jaxb-osgi-2.2.3-1.jar to GF 3.1
> modules folder
>    blows out glassfish: my application and admin console are not
> deployed/reachable.
> In my log file i can see:
>
> SEVERE: Exception while loading the app : java.lang.RuntimeException:
> java.lang.NullPointerException
> com.google.common.collect.ComputationException:
> java.lang.RuntimeException: java.lang.NullPointerException
>        at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)
>        at com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
>        at com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
>        at org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:183)
>        at org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:96)
>        at org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:133)
>        at org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:192)
>        at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:364)
>        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
>        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
>        at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:262)
>        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
>        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
>        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:354)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:369)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1080)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1260)
>        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1248)
>        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:453)
>        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:220)
>        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
>        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
>        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
>        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
>        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
>        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
>        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
>        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
>        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
>        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
>        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
>        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
>        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
>        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
>        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
>        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
>        at java.lang.Thread.run(Thread.java:619)
> Caused by: java.lang.RuntimeException: java.lang.NullPointerException
>        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:71)
>        at org.jboss.weld.util.reflection.SecureReflections.getDeclaredFields(SecureReflections.java:111)
>        at org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:163)
>        at org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:124)
>        at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:54)
>        at org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:42)
>        at com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
>        ... 38 more
> Caused by: java.lang.NullPointerException
>        at org.apache.felix.framework.resolver.ResolverImpl.permutateIfNeeded(ResolverImpl.java:1140)
>        at org.apache.felix.framework.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1066)
>        at org.apache.felix.framework.resolver.ResolverImpl.resolve(ResolverImpl.java:176)
>        at org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:4066)
>        at org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1412)
>        at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:734)
>        at org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>        at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>        at org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
>        at org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1604)
>        at org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:904)
>        at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3$1.run(OSGiModuleImpl.java:399)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3.loadClass(OSGiModuleImpl.java:395)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>        at com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:188)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
>        at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
>        at java.lang.Class.getDeclaredFields0(Native Method)
>        at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
>        at java.lang.Class.getDeclaredFields(Class.java:1743)
>        at org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:116)
>        at org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:112)
>        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
>        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:67)
>        ... 44 more
>
> When comparing GF 3.0.1 b22 with GF 3.1 b40 i noticed that
> beside the latter having jaxb jars removed from modules folder i think
> there are some changes in felix config.properties file. Maybe i need
> to investigate it further...
>
>
> 2. adding  jaxb-osgi-2.2.3-1.jar  to WEB-INF/lib and setting
> class-loader delegate to false does not work either.
>
> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
> found. For the recent builds to get this working correctly, you need
> even at least JAXB version 2.1.12. Please add it to your classpath!
> SEVERE: The provider class, class
> pl.assetwell.demo.infrastructure.MyJAXBContextResolver, could not be
> instantiated. Processing will continue but the class will not be
> utilized
> java.lang.RuntimeException: NATURAL JSON notation configured, but JAXB
> RI 2.1.10 not found. For the recent builds to get this working
> correctly, you need even at least JAXB version 2.1.12. Please add it
> to your classpath!
>        at com.sun.jersey.api.json.JSONConfiguration.natural(JSONConfiguration.java:447)
>        at pl.assetwell.demo.infrastructure.MyJAXBContextResolver.<init>(MyJAXBContextResolver.java:25)
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>
>
> This time i think i know why it can't work:
> I understand that class-loader delegate=false forces application (war)
>  to first load classes itself before delegation to parent (server)
> classloader (PARENT-LAST).
> If my understanding is correct than this approach can not work since
> it is not class within my application is trying to load JAXB RI
> 2.1.12.  According to stacktrace (above) JSONConfiguration tries to
> check if proper version of JAXB is
> present by execution of:
> Class.forName("com.sun.xml.bind.annotation.OverrideAnnotationOf");
>
> Since JSONConfiguration is bundled in jersey-json.jar withing GF
> modules it will use it is own classloader or any other
> parent(server)/OSGI classloader to find  OverrideAnnotationOf class.
> None of these classloaders will have access to application
> classloader. Am i right on this ?
>
> I can imagine i could copy some jersey-jars along with jaxb jars to
> WEB-INF/lib  and then specify class-loader delegate=false  but this is
> not what i would like to do...
>
> I will try to  check it with full GF 3.1 b40 or another/new build.
>
>
> regards
> Jakub Milkiewicz
>
>
> 2011/1/31 Pavel Bucek-2 [via Jersey]
> <[hidden email]>:
>> Hello Jakub,
>>
>> generally - update your java runtime; unfortunately, we currently
>> available jdk versions don't have that recent jaxb version, so ..
>>
>> I guess putting jaxb-api-osgi.jar [1] and jaxb-osgi.jar [2] into
>> glassfish/modules should work that out. Or you can upgrade to full
>> profile, which provides newer jaxb implementation.
>>
>> Or, if you don't want to update your local glassfish installation, you
>> could be able to package jaxb-osgi.jar into war and deploy it with your
>> application; you might need to set classloader delegation to false
>> (sun-web.xml: <class-loader delegate="false"/>).
>>
>> Regards,
>> Pavel
>>
>> [1]
>> http://download.java.net/maven/2/javax/xml/bind/jaxb-api-osgi/2.2.2/jaxb-api-osgi-2.2.2.jar
>> [2]
>> http://download.java.net/maven/2/com/sun/xml/bind/jaxb-osgi/2.2.3-1/jaxb-osgi-2.2.3-1.jar
>>
>> On 01/31/2011 03:45 PM, [hidden email] wrote:
>>> Hi
>>>
>>> I am not sure if this mail should not be sent to glassfish user group
>>> but i hope i can find some help here:
>>>
>>> I am trying to use JSON natural notation
>>>
>>> JAXBContext context = new
>>> JSONJAXBContext(JSONConfiguration.natural().build()...
>>>
>>> The application worked as a charm on GF 3.0.1 but on GF 3.1. b40  web
>>> profile (current the latest one as of yesterday) i got a nasty
>>> exception with following header message:
>>>
>>> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
>>> found. For the recent builds to get this working correctly, you need
>>> even at least JAXB version 2.1.12. Please add it to your classpath!
>>> SEVERE: The provider class, class foo.bar.MyJAXBContextResolver, could
>>> not be instantiated. Processing will continue but the class will not
>>> be utilized
>>>
>>> Generally ,how to upgrade to JAXB 2.1 provided that JAXB 2 classes are
>>> already bundled within JDK?
>>>
>>>
>>> How to make an upgrade on GF 3.1 which does not have any of JAXB api/
>>> JAXB impl osgified versions at all ( GF 3.0.1 indeed had jaxb-api-osgi
>>> and jaxb-osgi.jar )  ?
>>>
>>> regards Jakub Milkiewicz
>>>
>>>
>>
>>
>> ________________________________
>> If you reply to this email, your message will be added to the discussion
>> below:
>> http://jersey.576304.n2.nabble.com/JSON-natural-on-GF-3-1-b40-tp5977358p5977495.html
>> To start a new topic under Jersey, email
>> [hidden email]
>> To unsubscribe from Jersey, click here.
>

View this message in context: Re: JSON natural on GF 3.1 b40
Sent from the Jersey mailing list archive at Nabble.com.


jmilkiewicz | 1 Feb 14:40 2011
Picon

Re: JSON natural on GF 3.1 b40

Hi

Thanks Paul for a reply but I am still at the state of evaluating
various platforms for my new project and at least for the time being i
am more into embracing standards. As my problem shown it is still
safer and less time consuming to  comply with standards than making
any assumption what different vendors provide as extensions.

regards,

Jakub Milkewicz

2011/2/1 Paul Sandoz-2 [via Jersey]
<[hidden email]>:


>
> On Feb 1, 2011, at 1:49 PM, Pavel Bucek wrote:
>
> Hello,
>
> ah, my fault, sorry! I should realize sooner that api jar needs to go to
> endorsed dir.. it's good that you figured it out :)
>
> we don't run tests on web profile because Jersey (or to be more precise,
> JSR311) is NOT part of web profile, see [1]. Nevertheless Jersey is
> contained in it because glassfish can't be started without jersey AFAIK
> (jersey is used in admin console component)..
>
> Although JAX-RS is not included it was always the plan to bundle Jersey with
> the GF distribution of the EE web profile so developers could use
> JAX-RS/Jersey.
> I suspect most other EE vendors are likely to do the same.
> Paul.
>
> so your current setup with glassfish will work but don't be surprised if you
> will switch to another javaee6 web profile compliant appserver and something
> breaks..
>
> Pavel
>
> [1]
> http://www.oracle.com/technetwork/java/javaee/downloads/javaee6-standards-jsp-141130.html
>
> On 01/31/2011 11:56 PM, jmilkiewicz wrote:
>
> Hi
>
> I managed to run it on full GF 3.1 b40 and everything works.
> Next, I have copied jaxb jars you mentioned above to the following
> locations (as in GF 3.1 full)
> jaxb-api-osgi.jar to modules/endorsed
> jaxb-osgi to modules
>
> from now everything works as a charm.
>
> regards
>
> Jakub Milkiewicz
>
> 2011/1/31 [hidden email] <[hidden email]>:
>> Hi Pavel
>>
>> Thanks for a fast answer but unfortunately it still does not work.
>>
>> 1 - adding jaxb-api-osgi-2.2.2.jar and jaxb-osgi-2.2.3-1.jar to GF 3.1
>> modules folder
>>    blows out glassfish: my application and admin console are not
>> deployed/reachable.
>> In my log file i can see:
>>
>> SEVERE: Exception while loading the app : java.lang.RuntimeException:
>> java.lang.NullPointerException
>> com.google.common.collect.ComputationException:
>> java.lang.RuntimeException: java.lang.NullPointerException
>>        at
>> com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:218)
>>        at
>> com.google.common.collect.ComputingConcurrentHashMap.apply(ComputingConcurrentHashMap.java:100)
>>        at
>> com.google.common.collect.MapMaker$ComputingMapAdapter.get(MapMaker.java:515)
>>        at
>> org.jboss.weld.resources.ClassTransformer.loadClass(ClassTransformer.java:183)
>>        at
>> org.jboss.weld.bootstrap.BeanDeployer.addClass(BeanDeployer.java:96)
>>        at
>> org.jboss.weld.bootstrap.BeanDeployer.addClasses(BeanDeployer.java:133)
>>        at
>> org.jboss.weld.bootstrap.BeanDeployment.deployBeans(BeanDeployment.java:192)
>>        at
>> org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:364)
>>        at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:170)
>>        at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:128)
>>        at
>> org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:262)
>>        at
>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
>>        at
>> com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
>>        at
>> org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:354)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:369)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1080)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1260)
>>        at
>> com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1248)
>>        at
>> com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:453)
>>        at
>> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:220)
>>        at
>> com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
>>        at
>> com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
>>        at
>> com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:234)
>>        at
>> com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
>>        at
>> com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
>>        at
>> com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
>>        at
>> com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
>>        at
>> com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
>>        at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
>>        at
>> com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
>>        at
>> com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
>>        at
>> com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
>>        at
>> com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
>>        at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
>>        at
>> com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
>>        at
>> com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
>>        at java.lang.Thread.run(Thread.java:619)
>> Caused by: java.lang.RuntimeException: java.lang.NullPointerException
>>        at
>> org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:71)
>>        at
>> org.jboss.weld.util.reflection.SecureReflections.getDeclaredFields(SecureReflections.java:111)
>>        at
>> org.jboss.weld.introspector.jlr.WeldClassImpl.<init>(WeldClassImpl.java:163)
>>        at
>> org.jboss.weld.introspector.jlr.WeldClassImpl.of(WeldClassImpl.java:124)
>>        at
>> org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:54)
>>        at
>> org.jboss.weld.resources.ClassTransformer$TransformTypeToWeldClass.apply(ClassTransformer.java:42)
>>        at
>> com.google.common.collect.ComputingConcurrentHashMap.compute(ComputingConcurrentHashMap.java:206)
>>        ... 38 more
>> Caused by: java.lang.NullPointerException
>>        at
>> org.apache.felix.framework.resolver.ResolverImpl.permutateIfNeeded(ResolverImpl.java:1140)
>>        at
>> org.apache.felix.framework.resolver.ResolverImpl.checkPackageSpaceConsistency(ResolverImpl.java:1066)
>>        at
>> org.apache.felix.framework.resolver.ResolverImpl.resolve(ResolverImpl.java:176)
>>        at
>> org.apache.felix.framework.Felix$FelixResolver.resolve(Felix.java:4066)
>>        at
>> org.apache.felix.framework.ModuleImpl.searchDynamicImports(ModuleImpl.java:1412)
>>        at
>> org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:734)
>>        at
>> org.apache.felix.framework.ModuleImpl.access$400(ModuleImpl.java:71)
>>        at
>> org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1768)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>        at
>> org.apache.felix.framework.ModuleImpl.getClassByDelegation(ModuleImpl.java:645)
>>        at
>> org.apache.felix.framework.Felix.loadBundleClass(Felix.java:1604)
>>        at
>> org.apache.felix.framework.BundleImpl.loadClass(BundleImpl.java:904)
>>        at
>> org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3$1.run(OSGiModuleImpl.java:399)
>>        at java.security.AccessController.doPrivileged(Native Method)
>>        at
>> org.jvnet.hk2.osgiadapter.OSGiModuleImpl$3.loadClass(OSGiModuleImpl.java:395)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>        at
>> com.sun.enterprise.v3.server.APIClassLoaderServiceImpl$APIClassLoader.loadClass(APIClassLoaderServiceImpl.java:188)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:296)
>>        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
>>        at
>> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1465)
>>        at
>> org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1368)
>>        at java.lang.Class.getDeclaredFields0(Native Method)
>>        at java.lang.Class.privateGetDeclaredFields(Class.java:2291)
>>        at java.lang.Class.getDeclaredFields(Class.java:1743)
>>        at
>> org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:116)
>>        at
>> org.jboss.weld.util.reflection.SecureReflections$4.work(SecureReflections.java:112)
>>        at
>> org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
>>        at
>> org.jboss.weld.util.reflection.SecureReflectionAccess.runAndWrap(SecureReflectionAccess.java:67)
>>        ... 44 more
>>
>> When comparing GF 3.0.1 b22 with GF 3.1 b40 i noticed that
>> beside the latter having jaxb jars removed from modules folder i think
>> there are some changes in felix config.properties file. Maybe i need
>> to investigate it further...
>>
>>
>> 2. adding  jaxb-osgi-2.2.3-1.jar  to WEB-INF/lib and setting
>> class-loader delegate to false does not work either.
>>
>> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
>> found. For the recent builds to get this working correctly, you need
>> even at least JAXB version 2.1.12. Please add it to your classpath!
>> SEVERE: The provider class, class
>> pl.assetwell.demo.infrastructure.MyJAXBContextResolver, could not be
>> instantiated. Processing will continue but the class will not be
>> utilized
>> java.lang.RuntimeException: NATURAL JSON notation configured, but JAXB
>> RI 2.1.10 not found. For the recent builds to get this working
>> correctly, you need even at least JAXB version 2.1.12. Please add it
>> to your classpath!
>>        at
>> com.sun.jersey.api.json.JSONConfiguration.natural(JSONConfiguration.java:447)
>>        at
>> pl.assetwell.demo.infrastructure.MyJAXBContextResolver.<init>(MyJAXBContextResolver.java:25)
>>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
>> Method)
>>        at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>>        at
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>
>>
>> This time i think i know why it can't work:
>> I understand that class-loader delegate=false forces application (war)
>>  to first load classes itself before delegation to parent (server)
>> classloader (PARENT-LAST).
>> If my understanding is correct than this approach can not work since
>> it is not class within my application is trying to load JAXB RI
>> 2.1.12.  According to stacktrace (above) JSONConfiguration tries to
>> check if proper version of JAXB is
>> present by execution of:
>> Class.forName("com.sun.xml.bind.annotation.OverrideAnnotationOf");
>>
>> Since JSONConfiguration is bundled in jersey-json.jar withing GF
>> modules it will use it is own classloader or any other
>> parent(server)/OSGI classloader to find  OverrideAnnotationOf class.
>> None of these classloaders will have access to application
>> classloader. Am i right on this ?
>>
>> I can imagine i could copy some jersey-jars along with jaxb jars to
>> WEB-INF/lib  and then specify class-loader delegate=false  but this is
>> not what i would like to do...
>>
>> I will try to  check it with full GF 3.1 b40 or another/new build.
>>
>>
>> regards
>> Jakub Milkiewicz
>>
>>
>> 2011/1/31 Pavel Bucek-2 [via Jersey]
>> <[hidden email]>:
>>> Hello Jakub,
>>>
>>> generally - update your java runtime; unfortunately, we currently
>>> available jdk versions don't have that recent jaxb version, so ..
>>>
>>> I guess putting jaxb-api-osgi.jar [1] and jaxb-osgi.jar [2] into
>>> glassfish/modules should work that out. Or you can upgrade to full
>>> profile, which provides newer jaxb implementation.
>>>
>>> Or, if you don't want to update your local glassfish installation, you
>>> could be able to package jaxb-osgi.jar into war and deploy it with your
>>> application; you might need to set classloader delegation to false
>>> (sun-web.xml: <class-loader delegate="false"/>).
>>>
>>> Regards,
>>> Pavel
>>>
>>> [1]
>>>
>>> http://download.java.net/maven/2/javax/xml/bind/jaxb-api-osgi/2.2.2/jaxb-api-osgi-2.2.2.jar
>>> [2]
>>>
>>> http://download.java.net/maven/2/com/sun/xml/bind/jaxb-osgi/2.2.3-1/jaxb-osgi-2.2.3-1.jar
>>>
>>> On 01/31/2011 03:45 PM, [hidden email] wrote:
>>>> Hi
>>>>
>>>> I am not sure if this mail should not be sent to glassfish user group
>>>> but i hope i can find some help here:
>>>>
>>>> I am trying to use JSON natural notation
>>>>
>>>> JAXBContext context = new
>>>> JSONJAXBContext(JSONConfiguration.natural().build()...
>>>>
>>>> The application worked as a charm on GF 3.0.1 but on GF 3.1. b40  web
>>>> profile (current the latest one as of yesterday) i got a nasty
>>>> exception with following header message:
>>>>
>>>> SEVERE: NATURAL JSON notation configured, but JAXB RI 2.1.10 not
>>>> found. For the recent builds to get this working correctly, you need
>>>> even at least JAXB version 2.1.12. Please add it to your classpath!
>>>> SEVERE: The provider class, class foo.bar.MyJAXBContextResolver, could
>>>> not be instantiated. Processing will continue but the class will not
>>>> be utilized
>>>>
>>>> Generally ,how to upgrade to JAXB 2.1 provided that JAXB 2 classes are
>>>> already bundled within JDK?
>>>>
>>>>
>>>> How to make an upgrade on GF 3.1 which does not have any of JAXB api/
>>>> JAXB impl osgified versions at all ( GF 3.0.1 indeed had jaxb-api-osgi
>>>> and jaxb-osgi.jar )  ?
>>>>
>>>> regards Jakub Milkiewicz
>>>>
>>>>
>>>
>>>
>>> ________________________________
>>> If you reply to this email, your message will be added to the discussion
>>> below:
>>>
>>> http://jersey.576304.n2.nabble.com/JSON-natural-on-GF-3-1-b40-tp5977358p5977495.html
>>> To start a new topic under Jersey, email
>>> [hidden email]
>>> To unsubscribe from Jersey, click here.
>>
>
> ________________________________
> View this message in context: Re: JSON natural on GF 3.1 b40
> Sent from the Jersey mailing list archive at Nabble.com.
>
>
>
>
> ________________________________
> If you reply to this email, your message will be added to the discussion
> below:
> http://jersey.576304.n2.nabble.com/JSON-natural-on-GF-3-1-b40-tp5977358p5980930.html
> To start a new topic under Jersey, email
> [hidden email]
> To unsubscribe from Jersey, click here.

View this message in context: Re: JSON natural on GF 3.1 b40
Sent from the Jersey mailing list archive at Nabble.com.
ManiKanta G | 2 Feb 10:03 2011
Picon

Jersey truncating the slashes from the uploaded file name


Hi,

While uploading files from IE, Jersey resource is getting the file path without any slashes (as IE' behavior for file uploads is different from the other browsers in that it sends the complete file path of the user' system as  the file name). Is there any way  to stop this default behavior of Jersey of truncating the slashes from path. 

The code I m using is no different from the one the documentation suggest:

<at> Path("upload")
<at> POST
<at> Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
<at> Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
         <at> FormDataParam("file") FormDataContentDisposition disposition , 
         <at> FormDataParam("file") FormDataBodyPart part) {
    String fileName = disposition.getFileName();

    // some code to save the file with the user uploaded file name
}


Or in general, is there any place I can hook some code in place or before the actual parameters were set in the resource class. I m actually interested to know where all the resource class annotation processing will be done.

Thanks,
ManiKanta G
twitter.com/ManiKantaG
Paul Sandoz | 2 Feb 10:20 2011
Picon

Re: Jersey truncating the slashes from the uploaded file name

Hi,

I am not precisely sure what "file path" you are referring to, is it the value of the file name obtained from the content disposition?

Could you send an example e.g. from logging or from snooping on the HTTP port?

Paul.

On Feb 2, 2011, at 10:03 AM, ManiKanta G wrote:


Hi,

While uploading files from IE, Jersey resource is getting the file path without any slashes (as IE' behavior for file uploads is different from the other browsers in that it sends the complete file path of the user' system as  the file name). Is there any way  to stop this default behavior of Jersey of truncating the slashes from path. 

The code I m using is no different from the one the documentation suggest:

<at> Path("upload")
<at> POST
<at> Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
<at> Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
         <at> FormDataParam("file") FormDataContentDisposition disposition , 
         <at> FormDataParam("file") FormDataBodyPart part) {
    String fileName = disposition.getFileName();

    // some code to save the file with the user uploaded file name
}


Or in general, is there any place I can hook some code in place or before the actual parameters were set in the resource class. I m actually interested to know where all the resource class annotation processing will be done.

Thanks,
ManiKanta G
twitter.com/ManiKantaG


Gmane