Hi,
I successfully implemented the multi EAR deployment. The core EAR is
deployed first, then the rest of EARs are deployed and they register their
REST resources at startup (via addJndiResource). So far so good. When
undeployed, I want them to unregister resources, but there is no
"removeJndiResource" method on the Registry class. If those methods are not
unregistered, then, when the EAR is deployed again, the resources are
doubled and I get the following error when trying to access one of them:

13:22:05,557 SEVERE [org.jboss.resteasy.core.SynchronousDispatcher]
(http--127.0.0.1-8080-1) Failed executing GET /hw:
org.jboss.resteasy.spi.InternalServerErrorException: Bad arguments passed
to public abstract java.lang.String
com.acme.ejbremote.services.rest.RestService.helloWorld()  ( )
    at
org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:181)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:255)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:220)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:209)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:519)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:496)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:119)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at
org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
[resteasy-jaxrs-2.2.3.GA.jar:]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
[jboss-servlet-api_3.0_spec-1.0.0.Final.jar:]
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.3.Final.jar:]
    at
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
[weld-core-1.1.4.Final.jar:]
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
[jbossweb-7.0.3.Final.jar:]
    at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151)
[jboss-as-web-7.1.0.Beta1.jar:]
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
[jbossweb-7.0.3.Final.jar:]
    at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
[jbossweb-7.0.3.Final.jar:]
    at java.lang.Thread.run(Thread.java:662) [:1.6.0_27]
Caused by: java.lang.IllegalArgumentException: object is not an instance of
declaring class
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[:1.6.0_27]
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[:1.6.0_27]
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[:1.6.0_27]
    at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_27]
    at
org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:140)
[resteasy-jaxrs-2.2.3.GA.jar:]
    ... 26 more

Is there a way to "unregister" resources (via their JNDI names) in runtime?


On Fri, Nov 25, 2011 at 11:51, <for...@paaro.com> wrote:

> OK, what I managed so far is:
>
> I have two EARs: one is core EAR (with WAR and jaxrs activator class and a
> test REST method) and the other one contains just a test REST method. I
> also wrote a web filter with the following code in doFilter:
>
>         Registry registry = (Registry)
> request.getServletContext().getAttribute(Registry.class.getName());
>
> registry.addJndiResource("java:global/rest1-ear-1.0.0/rest1-ejb-1.0.0/RestServiceImpl");
>         chain.doFilter(request, response);
>
> This is very non optimized code, but it works. It adds the resource from
> my other EAR. Of course, this snippet executes with every request, so this
> is apparently not the right way to do it.
>
> My idea is for every EAR (apart from the core EAR) to have a @StartUp
> annotated singleton class, which would, at deploy time, somehow inform the
> core EAR (maybe via jndi) that it wants to register its own REST resources
> and providers (again, maybe via jndi names). Do you have any suggestions
> how to accomplish this?
>
> Thanks!
>
>
> On Wed, Nov 23, 2011 at 16:52, <for...@paaro.com> wrote:
>
>> I tested it inside an EAR and it works ok. You can have resource classes
>> in different JARs and the scanner registers them. But we're developing a
>> large project, which consists of multiple EARs, but would like to have a
>> single REST entry point, so when the "core" EAR (with WAR module and JAR
>> with JAX-RS activator class) is deployed and another EAR is deployed, the
>> scanner would also scan for newly deployed resource/provider classes. I
>> don't know it the idea is reasonable, so any other suggestions are
>> appreciated. For now, what I could do would be that every EAR would have
>> its own WAR and REST resources, completely isolated from other EARs. That
>> would mean that web roots would be different for every EAR/module, for
>> example for first EAR it would be /module1/rest_method_x, for another EAR
>> it would be /module_n/rest_method_y, etc.
>>
>> Thanks!
>>
>> On Wed, Nov 23, 2011 at 14:50, Bill Burke <bbu...@redhat.com> wrote:
>>
>>> I don't think the jsr is specific on where providers should be scanned
>>> from.  You'll probably have to manually register them as I believe the
>>> current AS7 integration only scans the WAR.
>>>
>>> On 11/23/11 3:46 AM, for...@paaro.com wrote:
>>> > Hi,
>>> >
>>> > I have the following scenario: multi EAR project, from which one of
>>> them
>>> > also have a WAR inside. Is it possible to register resteasy providers
>>> > and resources from different EARs into the servlet context of that WAR?
>>> > I know I can register them from different JARs inside the EAR
>>> containing
>>> > the WAR, but I don't know if I can do it from other EARs. I'm using
>>> > JBoss AS 7.0.2.
>>> >
>>> > Thanks!
>>> >
>>> >
>>> >
>>> ------------------------------------------------------------------------------
>>> > All the data continuously generated in your IT infrastructure
>>> > contains a definitive record of customers, application performance,
>>> > security threats, fraudulent activity, and more. Splunk takes this
>>> > data and makes sense of it. IT sense. And common sense.
>>> > http://p.sf.net/sfu/splunk-novd2d
>>> >
>>> >
>>> >
>>> > _______________________________________________
>>> > Resteasy-users mailing list
>>> > Resteasy-users@lists.sourceforge.net
>>> > https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>>
>>> --
>>> Bill Burke
>>> JBoss, a division of Red Hat
>>> http://bill.burkecentral.com
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> All the data continuously generated in your IT infrastructure
>>> contains a definitive record of customers, application performance,
>>> security threats, fraudulent activity, and more. Splunk takes this
>>> data and makes sense of it. IT sense. And common sense.
>>> http://p.sf.net/sfu/splunk-novd2d
>>> _______________________________________________
>>> Resteasy-users mailing list
>>> Resteasy-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>>>
>>>
>>
>
------------------------------------------------------------------------------
Cloud Services Checklist: Pricing and Packaging Optimization
This white paper is intended to serve as a reference, checklist and point of 
discussion for anyone considering optimizing the pricing and packaging model 
of a cloud services business. Read Now!
http://www.accelacomm.com/jaw/sfnl/114/51491232/
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users

Reply via email to