Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package javax.annotation.security does not exist

I'm trying to start a Jersey/1.7 based project from scratch (as opposed to copying an existing project and adding new code on top, which is what my client normally does) in order to learn how stuff works. I'm stuck in a very early phase, trying to process a simple HTTP request:

package com.example.foo.view.rest;

import javax.ws.rs.Path;
import javax.annotation.security.RolesAllowed; // package javax.annotation.security does not exist

@Path("user")
@RolesAllowed("valid-users") // cannot find symbol
public class UserService extends BaseService {
    public UserService() {
        super();
    }
}

I've copied these files from another project:

asm-3.1.jar
jackson-core-asl-1.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-mapper-asl-1.9.2.jar
jackson-xc-1.9.2.jar
jersey-client-1.17.jar
jersey-core-1.17.jar
jersey-json-1.17.jar
jersey-multipart-1.17.jar
jersey-server-1.17.jar
jersey-servlet-1.17.jar
jettison-1.1.jar
jsr311-api-1.1.1.jar

Project authentication works with Oracle SSO (Oracle Identity Directory).

The only javax.annotation.security.RolesAllowed I can find is an interface and I can certainly not see an actual implementation anywhere in my codebase. In fact the whole javax.annotation.security package is missing. I don't even know what library is supposed to provide it.

I'd appreciate any hint, no matter how obvious it looks.

like image 494
Álvaro González Avatar asked Jan 25 '23 03:01

Álvaro González


1 Answers

javax.annotation is part of java, but not included directly in the jre. It is not included in jersey. You have to add this jar to your project for it to work.

like image 105
Amir Schnell Avatar answered Jan 31 '23 15:01

Amir Schnell