Adi*_*tya 5 jndi java-ee jpa-2.0 ejb-3.1
我正在使用以下Bean类:
@Stateless(name="UserBean", mappedName="UserBean")
@LocalBean
public class User implements UserRemote {
@PersistenceContext
private EntityManager em;
public User() {
}
public String login(String username, String password) {
Query query = em.createQuery("...");
return "xyz";
}
}
Run Code Online (Sandbox Code Playgroud)
我的方法是
public String myMethod() {
try {
User user = (User) new InitialContext().lookup("UserBean");
return "xyz";
} catch (NamingException e) {
e.printStackTrace();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
我在这里得到一个
javax.naming.NameNotFoundException: Unable to resolve 'UserBean'. Resolved ''; remaining name 'UserBean'
Run Code Online (Sandbox Code Playgroud)
JNDI查找名称'UserBean'似乎是正确的.不知道问题是什么.有人可以帮忙吗?我已经使用JPA 2.0和EJB 3.x在weblogic 12c上部署了我的应用程序
提前致谢.
问题是我使用的是远程接口。仅使用 @stateless 注释而不使用映射名称以下代码有效:
\n\nnew InitialContext().lookup("java:global/ProjectName/ModuleName/BeanName!FullyQualif\xe2\x80\x8c\xe2\x80\x8biedNameOfRemoteInterface"); \nRun Code Online (Sandbox Code Playgroud)\n\n谢谢@安德烈!
\n| 归档时间: |
|
| 查看次数: |
10779 次 |
| 最近记录: |