users@jersey.java.net

Re: [Jersey] how to register MultiPartConfigProvider class in Glassfish when using multipart/mixed API.

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 27 Jan 2009 17:19:01 +0100

See also the following thread where Jeff is having similarly
frustrating issues:

http://markmail.org/search/?q=list
%3Anet.java.dev.jersey.users#query:list%3Anet.java.dev.jersey.users
+page:2+mid:axx4ibpy7m7ydcvm+state:results

Paul.

On Jan 27, 2009, at 5:10 PM, Craig McClanahan wrote:

> odin wrote:
>> Hi, everyone,
>> I am a new comer in using jersey, and now I get this problem, so I
>> hope someone can give me some help.
>>
>>
>> I tried to use the multipart/mixed API of Jersey in my web
>> application program.
>> My Environment is:
>> Netbeans + Glassfish v3 + Jersey 1.0.1 + jdk1.5.0.
>>
>> I do not use maven, so in order to use the multipart api of Jersey,
>> I included the jersey-multipart-1.0.1 into the classpath of the
>> project.
> By "into the classpath of the project" do you mean that it gets
> loaded into WEB-INF/lib? This will be a requirement.
>
> The most likely explanation for the exception you see is a missing
> dependency that MultiPartConfigProvider requires. Without Maven,
> you also need to make sure you've satisfied all the dependencies of
> jersey-multipart itself. Please check that all the following JARs
> are in WEB-INF/lib:
>
> jersey-core-1.0.1.jar
> jersey-server-1.0.1.jar
> jaxb-impl-2.1.jar (unless its included in your GFv3 configuration)
> javamail.jar
> activation.jar
>
> Finally, there have been cases where developers have tried to use
> the NetBeans built-in support for Jersey, and then tried to switch
> to using the most recent Jersey libraries as an external library.
> The symptom is that NB will sometimes add the 1.0 version of Jersey
> (built in to NB) back onto your library dependencies, which causes
> both 1.0 and 1.0.1 versions to be included in the app. This can
> cause all sorts of class loader grief, depending on which versions
> of which class gets loaded.
>
> Craig
>>
>> After I deployed the project, I get a error report as follows when
>> I try to run the project:
>> INFO: Provider classes found:
>> SEVERE: java.lang.reflect.InvocationTargetException
>> SEVERE: at
>> sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>> SEVERE: at
>> sun
>> .reflect
>> .NativeConstructorAccessorImpl
>> .newInstance(NativeConstructorAccessorImpl.java:39)
>> SEVERE: at
>> sun
>> .reflect
>> .DelegatingConstructorAccessorImpl
>> .newInstance(DelegatingConstructorAccessorImpl.java:27)
>> SEVERE: at
>> java.lang.reflect.Constructor.newInstance(Constructor.java:494)
>> SEVERE: at
>> com.sun.jersey.impl.application.WebApplicationImpl
>> $DefaultComponentProvider.getInstance(WebApplicationImpl.java:437)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .impl
>> .application
>> .ComponentProviderCache.getComponent(ComponentProviderCache.java:187)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .impl
>> .application
>> .ComponentProviderCache
>> .getProvidersAndServices(ComponentProviderCache.java:122)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .impl
>> .application
>> .MessageBodyFactory.getProviderMap(MessageBodyFactory.java:133)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .impl
>> .application.MessageBodyFactory.initReaders(MessageBodyFactory.java:
>> 107)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .impl.application.MessageBodyFactory.init(MessageBodyFactory.java:
>> 102)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .impl
>> .application.WebApplicationImpl.initiate(WebApplicationImpl.java:642)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .impl
>> .application.WebApplicationImpl.initiate(WebApplicationImpl.java:487)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .spi
>> .container.servlet.ServletContainer.initiate(ServletContainer.java:
>> 622)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .spi.container.servlet.ServletContainer.load(ServletContainer.java:
>> 538)
>> SEVERE: at
>> com
>> .sun
>> .jersey
>> .spi.container.servlet.ServletContainer.init(ServletContainer.java:
>> 197)
>> SEVERE: at
>> org
>> .apache
>> .catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1198)
>> SEVERE: at
>> org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:
>> 1038)
>> SEVERE: at
>> org
>> .apache
>> .catalina.core.StandardContext.loadOnStartup(StandardContext.java:
>> 4953)
>> SEVERE: at
>> org.apache.catalina.core.StandardContext.start(StandardContext.java:
>> 5350)
>> SEVERE: at
>> com.sun.enterprise.web.WebModule.start(WebModule.java:456)
>> SEVERE: at
>> org
>> .apache
>> .catalina.core.ContainerBase.addChildInternal(ContainerBase.java:922)
>> SEVERE: at
>> org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:
>> 906)
>> SEVERE: at
>> org.apache.catalina.core.StandardHost.addChild(StandardHost.java:696)
>> SEVERE: at
>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
>> 2205)
>> SEVERE: at
>> com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:
>> 1890)
>> SEVERE: at
>> com.sun.enterprise.web.WebApplication.start(WebApplication.java:85)
>> SEVERE: at
>> com
>> .sun
>> .enterprise
>> .v3.server.ApplicationLifecycle.start(ApplicationLifecycle.java:560)
>> SEVERE: at
>> com
>> .sun
>> .enterprise
>> .v3.server.ApplicationLifecycle.start(ApplicationLifecycle.java:547)
>> SEVERE: at
>> com
>> .sun
>> .enterprise
>> .v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:189)
>> SEVERE: at
>> org
>> .glassfish
>> .deployment.admin.DeployCommand.execute(DeployCommand.java:329)
>> SEVERE: at com.sun.enterprise.v3.admin.CommandRunner
>> $2.execute(CommandRunner.java:302)
>> SEVERE: at
>> com
>> .sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:
>> 312)
>> SEVERE: at
>> com
>> .sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:
>> 119)
>> SEVERE: at
>> com
>> .sun.enterprise.v3.admin.CommandRunner.doCommand(CommandRunner.java:
>> 99)
>> SEVERE: at
>> com
>> .sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:
>> 250)
>> SEVERE: at
>> com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:
>> 176)
>> SEVERE: at
>> com
>> .sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:
>> 147)
>> SEVERE: at
>> com
>> .sun
>> .enterprise
>> .v3.services.impl.ContainerMapper.service(ContainerMapper.java:180)
>> SEVERE: at
>> com
>> .sun
>> .grizzly
>> .http.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:
>> 633)
>> SEVERE: at
>> com
>> .sun
>> .grizzly
>> .http.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:570)
>> SEVERE: at
>> com
>> .sun
>> .grizzly
>> .http.DefaultProcessorTask.process(DefaultProcessorTask.java:827)
>> SEVERE: at
>> com
>> .sun
>> .grizzly
>> .http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:152)
>> SEVERE: at
>> com
>> .sun
>> .enterprise
>> .v3
>> .services
>> .impl
>> .GlassfishProtocolChain
>> .executeProtocolFilter(GlassfishProtocolChain.java:71)
>> SEVERE: at
>> com
>> .sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
>> 103)
>> SEVERE: at
>> com
>> .sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:
>> 89)
>> SEVERE: at
>> com
>> .sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:
>> 76)
>> SEVERE: at
>> com
>> .sun
>> .grizzly
>> .ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:67)
>> SEVERE: at
>> com
>> .sun
>> .grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:
>> 56)
>> SEVERE: at
>> com
>> .sun
>> .grizzly.util.WorkerThreadImpl.processTask(WorkerThreadImpl.java:325)
>> SEVERE: at
>> com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:184)
>> SEVERE: Caused by: java.lang.IllegalArgumentException: The
>> MultiPartConfig instance we expected is not present. Have you
>> registered the MultiPartConfigProvider class?
>> SEVERE: at
>> com
>> .sun
>> .jersey.multipart.impl.MultiPartReader.<init>(MultiPartReader.java:
>> 78)
>> SEVERE: ... 50 more
>> INFO: null
>> INFO: Loading application CheroWeb at /CheroWeb
>> INFO: Deployment of CheroWeb done is 6765 ms
>>
>> and when I use a client to connect this web service, I get the
>> following:
>>
>> SEVERE: A message body reader for Java type, class
>> com.sun.jersey.multipart.MultiPart, and MIME media type, multipart/
>> mixed, was not found
>>
>> So I think I need to register the jar file into the server
>> application, but I do not know how to do it, I would really
>> appreciate if someone can tell me.
>>
>> odin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>