xxx 类不包含当 xxx 成为 Tapestry 服务时自动构建所需的公共构造函数 [英] Class xxx does not contain a public constructor needed to autobuild when xxx become a Tapestry Service

查看:63
本文介绍了xxx 类不包含当 xxx 成为 Tapestry 服务时自动构建所需的公共构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了 Tynamo 团队在 Tapestry 和 Resteasy 之间进行的精彩整合工作.

I'm discovering the wonderful integration work made by Tynamo's team between Tapestry and Resteasy .

我正在尝试在网络服务上激活 Liveclass Reloading.根据文档说:

I'm trying to activate Liveclass Reloading on webservices. As per doc says :

您唯一需要做的就是为您的课程启用实时课程重新加载REST 服务是将它们绑定为常规 Tapestry IoC 服务和将它们贡献给 javax.ws.rs.core.Application.class.阅读更多关于服务实现重新加载的工作原理:http://tapestry.apache.org/reload.html

The only thing you need to do to enable live class reloading for your REST services is to bind them as regular Tapestry IoC services and contribute them to javax.ws.rs.core.Application.class. Read more about how service implementation reloading works in: http://tapestry.apache.org/reload.html

这是一个来自tapestry-resteasy 测试套件的示例.

Here is an example from the tapestry-resteasy test suite.

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):

My Own Work

This is exactly what I'm doing (well ... hmmm at least I believe that it is ;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();

错误

但是当我启动我的应用程序时,我收到了这条消息:

Error

But when I start my app, I obtain this message :

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)

这很像自动绑定不起作用(我确实认为是这样).显然,当我尝试不创建界面和绑定时,它就像一个魅力.

It's quite like the autobinding don't works (indeed I do think it is). Obviously, when I try to without creating an interface and binding, it works like a charm.

谁能给我一个线索?

推荐答案

我认为问题在于 tapestry-resteasy 正在尝试自动构建 IUserResource 因为它在休息"包.

I think the issue is that tapestry-resteasy is trying to autobuild IUserResource because it's in the "rest" package.

这是您可能错过的非常重要的文档行:

Here is a very important documentation line that you may have missed:

还有一点:不要将此服务放入自动发现包中.

One more thing: DO NOT put this service in the autodiscovery package.

这是一个重要的行,它以某种方式隐藏在文档中,所以我添加了一个警告,使其对未来的用户更可见:http://docs.codehaus.org/pages/diffpagesbyversion.action?pageId=151847035&selectedPageVersions=24&selectedPageas>Versions

This is an important line and it was somehow hidden in the docs so I added a warning to make it more visible for future users: http://docs.codehaus.org/pages/diffpagesbyversion.action?pageId=151847035&selectedPageVersions=24&selectedPageVersions=23

这篇关于xxx 类不包含当 xxx 成为 Tapestry 服务时自动构建所需的公共构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆