1

我在使用自定义 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 注释,即使它在那里。

4

1 回答 1

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}
于 2018-03-30T18:04:29.960 回答