VextoR
VextoR

Reputation: 5175

[Study EJB]: annotation type is not applicable to this kind of declaration?

Trying to create the simplest EJB using NetBeans 7.0 and EJB 3 in Action book.

Well, firstly I've created an interface:

package study;

public interface NewInterface {
    public void sayHello(String name);
}

Then, the EJB:

package study;
import javax.ejb.Stateless;

public class NewClass implements NewInterface{

    @Override
    @Stateless //! ERROR here !
    public void sayHello(String name) {
       System.out.println("Hello " + name);
    }  
}

Java complains at @Stateless

annotation type is not applicable to this kind of declaration

Why?

Upvotes: 1

Views: 9491

Answers (1)

NimChimpsky
NimChimpsky

Reputation: 47300

Should be on the class declaration (not the method). Like so :

package study;
import javax.ejb.Stateless;

@Stateless
public class NewClass implements NewInterface{

    @Override
    public void sayHello(String name) {
       System.out.println("Hello " + name);
    }  
}

From here

Upvotes: 3

Related Questions