EJB中的抽象类错误

时间:2018-05-06 11:58:00

标签: java java-ee

我想问一下如何解决我的CacheBean中的问题。它使用我的自定义EJBTestObject来存储时间。该类通过pom.xml中的依赖项与maven项目相关联。

我仍然遇到错误:

wipb/jee/clientdemo/ejb/CacheBean.java:[17,8] wipb.jee.clientdemo.ejb.CacheBean is not abstract and does not override abstract method add(java.lang.String,java.lang.Object) in wipb.jee.clientdemo.ejb.CacheBeanRemote
wipb/jee/clientdemo/ejb/CacheBean.java:[39,5] method does not override or implement a method from a supertype
2 errors 

EJBTestObject:

public class EJBTestObject {

private String content;
private long lastAccess;

public EJBTestObject(String content, long lastAccess) {
    this.content = content;
    this.lastAccess = lastAccess;
}
..getters and setters

}

CacheBean:

@Singleton
public class CacheBean implements CacheBeanRemote {
private Map<String, EJBTestObject> cache = new HashMap<>();

@Override
public EJBTestObject get(String key) {
    System.out.println("Cache.get called");
    return cache.get(key);
}

@Override
public boolean contains(String key) {
    System.out.println("Cache.contains called");
    return cache.containsKey(key);
}

@Override
public EJBTestObject remove(String key) {
    System.out.println("Cache.remove called");
    return cache.remove(key);
}

@Override
public void add(String key, EJBTestObject value) {
    System.out.println("Cache.add called");
    cache.put(key, value);
}
}

CacheBeanRemote:

    @Remote
public interface CacheBeanRemote {

void add(String key, EJBTestObject value);

EJBTestObject get(String key);

boolean contains(String key);

EJBTestObject remove(String key);

}

我注意到当我在add方法中不使用EJBTestClass时,一切正常。

0 个答案:

没有答案