我发现Tynamo团队在Tapestry和Resteasy之间进行了精彩的整合工作。
我正在尝试在webservices上激活Liveclass Reloading。按照医生的说法:
您需要做的唯一事情就是为您启用实时课程重新加载 REST服务是将它们绑定为常规Tapestry IoC服务和 将它们贡献给javax.ws.rs.core.Application.class。了解更多 服务实现重新加载如何工作: http://tapestry.apache.org/reload.html
以下是tapestry-resteasy测试套件的一个例子。
public static void bind(ServiceBinder binder)
{
binder.bind(ReloadableEchoResource.class, ReloadableEchoResourceImpl.class);
}
@Contribute(javax.ws.rs.core.Application.class)
public static void configureRestResources(Configuration<Object> singletons, ReloadableEchoResource reloadableEchoResource)
{
singletons.add(reloadableEchoResource);
}
这正是我正在做的事情(嗯...至少我相信它是; D):
public static void bind(ServiceBinder binder)
{
binder.bind(PushMessageService.class, GCMPushMessageServiceImpl.class);
binder.bind(UserService.class, HibernateUserServiceImpl.class);
binder.bind(IUserResource.class, UserResourceImpl.class);
}
/**
* Contributions to the RESTeasy main Application, insert all your RESTeasy singletons services here.
*/
@Contribute(javax.ws.rs.core.Application.class)
public static void configureRestResources(Configuration<Object> singletons, IUserResource userResource)
{
singletons.add(userResource);
}
@Path("/user")
public interface IUserResource {
/**
* Lecture de tous les utilisateurs
*
* @return une List des utilisateurs existants
*/
@GET
@Produces("application/json")
public abstract List<User> getAllDomains();
但是当我启动我的应用程序时,我收到了这条消息:
HTTP ERROR 500
Problem accessing /user. Reason:
Exception constructing service 'ResteasyRequestFilter': Error building service proxy for service 'Application' (at org.tynamo.resteasy.Application(Collection) (at Application.java:14) via org.tynamo.resteasy.ResteasyModule.bind(ServiceBinder) (at ResteasyModule.java:31)): Error invoking service contribution method org.tynamo.resteasy.ResteasyModule.javaxWsRsCoreApplication(Configuration, ObjectLocator, ResteasyPackageManager, ClassNameLocator): Class com.sopragroup.ecommerce.mobile.rest.IUserResource does not contain a public constructor needed to autobuild.
Caused by:
java.lang.RuntimeException: Exception constructing service 'ResteasyRequestFilter': Error building service proxy for service 'Application' (at org.tynamo.resteasy.Application(Collection) (at Application.java:14) via org.tynamo.resteasy.ResteasyModule.bind(ServiceBinder) (at ResteasyModule.java:31)): Error invoking service contribution method org.tynamo.resteasy.ResteasyModule.javaxWsRsCoreApplication(Configuration, ObjectLocator, ResteasyPackageManager, ClassNameLocator): Class com.sopragroup.ecommerce.mobile.rest.IUserResource does not contain a public constructor needed to autobuild.
at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.obtainObjectFromCreator(JustInTimeObjectCreator.java:75)
at org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:54)
这很像自动装订不起作用(事实上我确实认为是这样)。 显然,当我尝试不创建界面和绑定时,它就像一个魅力。
有人能给我一些线索吗?
答案 0 :(得分:1)
我认为问题是 tapestry-resteasy 正在尝试自动生成 IUserResource ,因为它位于“rest”包中。
以下是您可能错过的非常重要的文档行:
还有一件事:不要将此服务放在自动发现包中。
这是一个重要的部分,它以某种方式隐藏在文档中,所以我添加了一个警告,以使其对未来的用户更加明显:http://docs.codehaus.org/pages/diffpagesbyversion.action?pageId=151847035&selectedPageVersions=24&selectedPageVersions=23