Re: Problem with Spring Extension

2011-06-26 Thread Rhett Sutphin
Hi Paul,

On Jun 26, 2011, at 10:24 PM, Paul Morris wrote:

> I'm getting the error below. I'm using both the Servlet and the Spring 
> extensions. I figure it must be an XML config file issue so I'm including my 
> web.xml and the two bean container files. The web.xml and the 
> idservlet-servlet.xml are both in the WEB-INF folder and the 
> applicationContext.xml is in the src folder. Using JEE 2.1 M5.
> 
> SEVERE: Allocate exception for servlet idservlet
> org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean 
> named 'root' is defined

>From the javadoc for RestletFrameworkServlet[1]: 'All requests to this servlet 
>will be delegated to a single top-level restlet loaded from the Spring 
>application context. By default, this servlet looks for a bean named "root". 
>You can override that by passing in the targetRestletBeanName parameter.' You 
>don't have a bean named root and you didn't specify an alternative.

Rhett

[1]: 
http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/spring/RestletFrameworkServlet.html


>   at 
> org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:509)
>   at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041)
>   at 
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
>   at 
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
>   at 
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1044)
>   at 
> org.restlet.ext.spring.RestletFrameworkServlet.getTargetRestlet(RestletFrameworkServlet.java:141)
>   at 
> org.restlet.ext.spring.RestletFrameworkServlet.initFrameworkServlet(RestletFrameworkServlet.java:163)
>   at 
> org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:308)
>   at 
> org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
>   at javax.servlet.GenericServlet.init(GenericServlet.java:160)
>   at 
> org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)
>   at 
> org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)
>   at 
> org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:813)
>   at 
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
>   at 
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
>   at 
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
>   at 
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
>   at 
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
>   at 
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
>   at 
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
>   at 
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
>   at 
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
>   at 
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
>   at 
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
>   at 
> org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
>   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)
> 
> --
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2777981

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2777986


RE: Problem with Spring Extension

2011-06-26 Thread Paul Morris
Here is the whole stack trace. There are some warning that look pertinent. I am 
also attaching the corrected applicationContext.xml.

Jun 26, 2011 10:45:46 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'idservlet'
Jun 26, 2011 10:45:46 PM org.springframework.web.servlet.FrameworkServlet 
initServletBean
INFO: FrameworkServlet 'idservlet': initialization started
Jun 26, 2011 10:45:46 PM 
org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'idservlet-servlet': 
startup date [Sun Jun 26 22:45:46 CDT 2011]; root of context hierarchy
Jun 26, 2011 10:45:46 PM 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource 
[/WEB-INF/idservlet-servlet.xml]
Jun 26, 2011 10:45:46 PM 
org.springframework.beans.factory.xml.XmlBeanDefinitionReader 
loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource 
[applicationContext.xml]
Jun 26, 2011 10:45:46 PM 
org.springframework.beans.factory.support.DefaultListableBeanFactory 
preInstantiateSingletons
INFO: Pre-instantiating singletons in 
org.springframework.beans.factory.support.DefaultListableBeanFactory@1304a7c: 
defining beans 
[component,defaultHost,componentChildContext,openAmSessionApplication,engine,openAmSession,openAmResponseParser,documentHelper,openAmSessionProvisionerProxy,openAmSessionAttributes,openAmAuthenticator,openAmAuthorizer,openAmSessionVerifier];
 root of factory hierarchy
Jun 26, 2011 10:45:47 PM 
org.springframework.beans.GenericTypeAwarePropertyDescriptor 
getWriteMethodForActualAccess
WARNING: Invalid JavaBean property 'attachments' being accessed! Ambiguous 
write methods found next to actually used [public void 
org.restlet.ext.spring.SpringRouter.setAttachments(java.util.Map)]: [public 
static void 
org.restlet.ext.spring.SpringRouter.setAttachments(org.restlet.routing.Router,java.util.Map)]
Jun 26, 2011 10:45:47 PM org.restlet.ext.spring.SpringRouter setAttachment
WARNING: Unknown object found in the mappings. Only instances of Restlet and 
subclasses of org.restlet.resource.Resource and ServerResource are allowed.
Jun 26, 2011 10:45:47 PM org.restlet.ext.spring.SpringRouter setAttachment
WARNING: Unknown object found in the mappings. Only instances of Restlet and 
subclasses of org.restlet.resource.Resource and ServerResource are allowed.
Jun 26, 2011 10:45:47 PM org.springframework.web.servlet.FrameworkServlet 
initServletBean
SEVERE: Context initialization failed
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 
'root' is defined
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:509)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at 
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1044)
at 
org.restlet.ext.spring.RestletFrameworkServlet.getTargetRestlet(RestletFrameworkServlet.java:141)
at 
org.restlet.ext.spring.RestletFrameworkServlet.initFrameworkServlet(RestletFrameworkServlet.java:163)
at 
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:308)
at 
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at 
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)
at 
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:813)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Htt

RE: Problem with Spring Extension

2011-06-26 Thread Paul Morris
I think the map values for attachments should be value-ref rather than just 
value because they refer to beans declared in the same file but in either case 
that doesn't eliminate my error.






--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2777982


Problem with Spring Extension

2011-06-26 Thread Paul Morris
I'm getting the error below. I'm using both the Servlet and the Spring 
extensions. I figure it must be an XML config file issue so I'm including my 
web.xml and the two bean container files. The web.xml and the 
idservlet-servlet.xml are both in the WEB-INF folder and the 
applicationContext.xml is in the src folder. Using JEE 2.1 M5.

SEVERE: Allocate exception for servlet idservlet
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 
'root' is defined
at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:509)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1041)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:273)
at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at 
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1044)
at 
org.restlet.ext.spring.RestletFrameworkServlet.getTargetRestlet(RestletFrameworkServlet.java:141)
at 
org.restlet.ext.spring.RestletFrameworkServlet.initFrameworkServlet(RestletFrameworkServlet.java:163)
at 
org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:308)
at 
org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:127)
at javax.servlet.GenericServlet.init(GenericServlet.java:160)
at 
org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)
at 
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)
at 
org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:813)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:135)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at 
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at 
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at 
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:166)
at 
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
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)

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2777981
http://www.springframework.org/schema/beans";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xmlns:util="http://www.springframework.org/schema/util";
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
   	   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
   	   http://www.springframework.org/schema/util 
   	   http://www.springframework.org/schema/util/spring-util-2.5.xsd";>
	
   



http://www.w3.org/2001/XMLSchema-instance"; 
		 xmlns="http://java.sun.com/xml/ns/javaee"; 
		 xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; 
		 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"; 
		 id="WebApp_ID" 
		 version="3.0">
  
  	idservlet
org.restlet.ext.spring.RestletFrameworkServlet
  
  
  
idservlet
/*
  


http://www.springframework.org/schema/beans";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xmlns:util="http://www.springframework.org/schema/util";
   xsi:schemaLocation="http://www.springframework.org/schema/beans 
   	   http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
   	   http://www.springframework.org/schema/util 
   	   http://www.springframework.org/schema/util/spring-util-2.5.xsd";>

	
		
		
		
		
		
		
	
	
	
		
		
	
	
	
		
	
	
	
		
		
		
		
		
		
			


	
		
		
	

			
		
	
	
	
		
			

			
		
	
	
	
		
		
	
	
	
		
	
	
	
	
	
		
	
	
	
		
		
	
	
	
		
		
		
		
	
	
	
		
	
	
	
		
	
	



Problems using JiBX with ClientResource to POST or PUT data

2011-06-26 Thread Mark Butler
Hi,

I have created a short example REST server using JiBX and Restlet here:

https://github.com/butlermh/TVExample

However I encountered some problems in my integration test 

https://github.com/butlermh/TVExample/blob/master/TVProgrammeREST/src/test/java/com/tvexample/programme/integrationTests/ClientProgrammeProxy.java

when using POST or PUT on the client side. I hoped to be able to call my 
interface by using ClientResource.wrap:

ClientResource cr = new ClientResource(resourceURI);
resource = cr.wrap(ProgrammeResource.class);
resource.create(programme);

However this creates a request like this

POST /tv/programmes/4 HTTP/1.1
Transfer-Encoding: chunked
Date: Sun, 26 Jun 2011 12:33:20 GMT
Content-Type: application/octet-stream; charset=UTF-8
Accept: */*
Host: localhost:8181
User-Agent: Restlet-Framework/2.1m3

0045
4Strictly Come Dancing


So I get a response like this

HTTP/1.1 415 Unsupported Media Type
Content-Type: text/html; charset=UTF-8
Date: Sun, 26 Jun 2011 12:33:20 GMT
Accept-Ranges: bytes
Server: Restlet-Framework/2.1m3
Content-Length: 554

If I create the request manually directly from JiBX 

IBindingFactory bfact =  
  BindingDirectory.getFactory(Programme.class);
IMarshallingContext mctx = 
  bfact.createMarshallingContext();
StringWriter sw = new StringWriter();
mctx.marshalDocument(p, "UTF-8", null, sw);
StringRepresentation rep = new 
  StringRepresentation(sw.toString(), MediaType.APPLICATION_XML);
Client cl = new Client(Protocol.HTTP);
Request request = new Request(method, url, rep);
Response response = cl.handle(request);

to create a request like this

PUT /tv/programmes/2 HTTP/1.1
Date: Sun, 26 Jun 2011 12:37:32 GMT
Content-Length: 96
Content-Type: application/xml; charset=UTF-8
Accept: */*
Host: localhost:8181
User-Agent: Restlet-Framework/2.1m3

2Doctor 
Who

then it works. Any ideas why this is happening?

Best wishes,

Mark

--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2777341