初始化自定义RestResource时出现异常

时间:2018-03-29 17:45:55

标签: jersey-2.0 atg oracle-commerce

我遇到自定义RestResource的问题。我想用我自己的实现替换OOTB UserRestResource。当核启动时,我得到以下异常:

Scan failed to process nucleus rest resource class:class com.test.restresources.UserRestResource 
path:/atg/userprofiling/restresources/UserRestResource
atg.service.jaxrs.RestException: Endpoint annotated method without a http method annotation

该类具有以下实现:

@RestResource(id = "com.pki.ebusiness.ocs.restresources.userRestResource")
@Path("/users")
@Api(value="/users")
public class UserRestResource extends GenericService {
    private UserRepository mUserRepository;
    private DomainObjectMapper mObjectMapper = DomainObjectMapper.INSTANCE;

    @GET
    @Path("/{userId}")
    @Endpoint(id = "/users/{userId}#GET", isSingular = true, filterId = "users.id-Default")
    @ApiOperation("Retrieve a user for given ID.")
    public RepresentationModel getUser(@PathParam("userId") String pUserId){
        User user = null;
        try {
            user = mUserRepository.getUser(pUserId);
        } catch (ServletException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (BaseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        UserDto userDto = mObjectMapper.convert(user);

        Builder builder = (new Builder()).state(userDto);
        return builder.build();
    }
}

在调试RestResourceRegistry时,我发现它无法找到Path注释,即使它在那里。

1 个答案:

答案 0 :(得分:0)

atg/dynamo/service/jaxrs/RestResourceRegistry.properties添加nucleusProviders+=security/CsrfProtectionFilter

这是OC 11.3中的一个问题。

更新

除上述内容外,还将以下条目添加到JerseyClassLoaderService.properties

classpathFiles+=\

       {appModuleResource?moduleID=YourBase.ModuleName&resourceURI=lib/make-jersey-classloader.jar}