Hi Jan
On 21/11/12 09:09, janb wrote:
Hi Sergey,
I tried to set the required permissions to my webapp, but I still get the same
error message.
First I added this to my catalina.policy file:
grant codeBase
"file:${catalina.home}/webapps/syncope/WEB-INF/lib/cxf-rt-frontend-jaxrs-2.7.0.jar"
{
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
};
After no success, I tried to set my permissions as low as possible, but still
no success:
grant codeBase "file:${catalina.home}/webapps/syncope/WEB-INF/lib/-" {
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.security.AllPermission;
};
Can you please confirm that you actually have SecurityManager activated
in this Tomcat instance ? If yes then I will experiment on my end too...
I did not change the default spring scope for my service class, so it should be
singleton. Here is my jaxrs:server code:
<jaxrs:server id="restContainer" address="/">
<jaxrs:serviceBeans>
<bean class="org.apache.syncope.core.rest.controller.RoleControllerImpl"
/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jaxbProvider" />
<ref bean="jsonProvider" />
<bean class="org.apache.syncope.exceptions.RestHttpStatusCodeMapper"/>
</jaxrs:providers>
<jaxrs:extensionMappings>
<entry key="json" value="application/json;charset=UTF-8" />
<entry key="xml" value="application/xml;charset=UTF-8" />
<entry key="html" value="text/html;charset=UTF-8" />
</jaxrs:extensionMappings>
</jaxrs:server>
Yes, this is a singleton, I was thinking may be it was some advanced
Spring scope which was leading to the field becoming somehow
unaccessible due to the proxification, but it does not seem to be the
case...
Cheers, Sergey
Best regards.
Jan
From: Sergey Beryozkin-5 [via CXF]
[mailto:[email protected]]
Sent: Dienstag, 20. November 2012 17:50
To: Jan Bernhardt
Subject: Re: IllegalArgumentException for UriInfo context injection
Hi Jan
On 20/11/12 15:42, janb wrote:
Hi,
I'm trying to use UriInfo within my REST webservice to create a dynamic
response URL. If I use @Context UriInfo uriInfo within my method signature
everything is working fine. But since I don't like to mix my business
service interface with REST specific arguments, I would rather like to use
UriInfo as a field with my service class. I tried a couple of CXF systest to
learn how this can be done. I even created my own sample app. All is working
well. But when I try to do the same thing in my much more complex
webapplication I cannot deploy my Service any longer, due to an
IllegalArgumentException caused by injecting my UriInfo field.... :(
I debugged CXF code, to find the place where the injection happens
(org.apache.cxf.jaxrs.utils.InjectionUtils, Line 167, Version 2.7.0), and
all the parameters look OK to me, but still I get an
IllegalArgumentException. I don't know how to solve this issue. Does someone
else knows how to investigate this issue any further?
I can see from the stack trace that
java.security.AccessController.doPrivileged is in the frame,
is SecurityManager enabled ? If yes then may be
http://cxf.apache.org/docs/secure-jax-rs-services.html#SecureJAX-RSServices-NoteaboutSecurityManager
will help ?
You can also inject "UriInfo" as a method parameter, example
"@GET Data get(@Context UriInfo ui, @PathParam("id") long id)",
but the field injection should also work...
The actual service bean, what Spring scope it is in ?
Cheers, Sergey
Best regads.
Jan
Here is my Tomcat log:
20.11.2012 15:35:55 org.apache.catalina.core.StandardContext listenerStart
SCHWERWIEGEND: Exception sending context initialized event to listener
instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'restContainer': Invocation of init method failed; nested
exception is org.apache.cxf.service.factory.ServiceConstructionException
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:605)
at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:383)
at
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at
org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1099)
at
org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1621)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException
at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:201)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1581)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1522)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 26 more
Caused by: java.lang.IllegalArgumentException: Can not set
javax.ws.rs.core.UriInfo field
org.apache.syncope.core.rest.controller.RoleControllerImpl.uriInfo to
$Proxy98
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at
sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at
sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:37)
at
sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:57)
at java.lang.reflect.Field.set(Field.java:657)
at org.apache.cxf.jaxrs.utils.InjectionUtils$1.run(InjectionUtils.java:167)
at java.security.AccessController.doPrivileged(Native Method)
at
org.apache.cxf.jaxrs.utils.InjectionUtils.injectFieldValue(InjectionUtils.java:163)
at
org.apache.cxf.jaxrs.utils.InjectionUtils.injectContextProxiesAndApplication(InjectionUtils.java:921)
at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.injectContexts(JAXRSServerFactoryBean.java:365)
at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.updateClassResourceProviders(JAXRSServerFactoryBean.java:391)
at
org.apache.cxf.jaxrs.JAXRSServerFactoryBean.create(JAXRSServerFactoryBean.java:151)
... 33 more
20.11.2012 15:35:55 org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
--
View this message in context:
http://cxf.547215.n5.nabble.com/IllegalArgumentException-for-UriInfo-context-injection-tp5718839.html
Sent from the cxf-user mailing list archive at Nabble.com.
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com
________________________________
If you reply to this email, your message will be added to the discussion below:
http://cxf.547215.n5.nabble.com/IllegalArgumentException-for-UriInfo-context-injection-tp5718839p5718848.html
To unsubscribe from IllegalArgumentException for UriInfo context injection, click
here<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5718839&code=amJlcm5oYXJkdEB0YWxlbmQuY29tfDU3MTg4Mzl8LTEzMDQ4ODk1MjM=>.
NAML<http://cxf.547215.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
--
View this message in context:
http://cxf.547215.n5.nabble.com/IllegalArgumentException-for-UriInfo-context-injection-tp5718839p5718895.html
Sent from the cxf-user mailing list archive at Nabble.com.