GlassFish错误:javax.servlet.ServletException:在托管bean用户上执行资源注入时发生错误

时间:2013-07-01 20:05:24

标签: java jsf glassfish ejb glassfish-3

当我启动glassfish应用程序服务器时,我看到以下错误:

exception

javax.servlet.ServletException: An error occurred performing resource injection on managed bean user
root cause

com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean user
root cause

com.sun.faces.spi.InjectionProviderException: com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=com.tsystems.demail.Beans.User/first_name,Remote 3.x interface =java.lang.String,ejb-link=null,lookup=,mappedName=,jndi-name=java.lang.String,refType=Session into class com.tsystems.demail.Beans.User: Lookup failed for 'java:comp/env/com.tsystems.demail.Beans.User/first_name' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
root cause

com.sun.enterprise.container.common.spi.util.InjectionException: Exception attempting to inject Remote ejb-ref name=com.tsystems.demail.Beans.User/first_name,Remote 3.x interface =java.lang.String,ejb-link=null,lookup=,mappedName=,jndi-name=java.lang.String,refType=Session into class com.tsystems.demail.Beans.User: Lookup failed for 'java:comp/env/com.tsystems.demail.Beans.User/first_name' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
root cause

javax.naming.NamingException: Lookup failed for 'java:comp/env/com.tsystems.demail.Beans.User/first_name' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=com.tsystems.demail.Beans.User/first_name,Remote 3.x interface =java.lang.String,ejb-link=null,lookup=,mappedName=,jndi-name=java.lang.String,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'java.lang.String#java.lang.String' [Root exception is javax.naming.NamingException: Lookup failed for 'java.lang.String#java.lang.String' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: java.lang.String#java.lang.String not found]]]
root cause

javax.naming.NamingException: Exception resolving Ejb for 'Remote ejb-ref name=com.tsystems.demail.Beans.User/first_name,Remote 3.x interface =java.lang.String,ejb-link=null,lookup=,mappedName=,jndi-name=java.lang.String,refType=Session' .  Actual (possibly internal) Remote JNDI name used for lookup is 'java.lang.String#java.lang.String' [Root exception is javax.naming.NamingException: Lookup failed for 'java.lang.String#java.lang.String' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: java.lang.String#java.lang.String not found]]
root cause

javax.naming.NamingException: Lookup failed for 'java.lang.String#java.lang.String' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming} [Root exception is javax.naming.NameNotFoundException: java.lang.String#java.lang.String not found]
root cause

javax.naming.NameNotFoundException: java.lang.String#java.lang.String not found

在stacktrace中,我看到以下错误:

[#|2013-07-01T23:53:14.447+0400|WARNING|glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=100;_ThreadName=Thread-2;|StandardWrapperValve[FacesServlet]: PWC1406: Servlet.service() for servlet FacesServlet threw exception
javax.naming.NameNotFoundException: java.lang.String#java.lang.String not found 

我的bean类的一部分:

@ManagedBean
@SessionScoped
public class User {

    public static EntityManagerFactory emf = Persistence.createEntityManagerFactory("NewPersistenceUnit");

    @EJB
    private String first_name;
    private String last_name;
    private String mobile_phone;
    private String password;
    private String rtPassword;
    private Date birth_day;
    private String username;
    private List data;
    private Map<String,Object> userList;
    private String temp;
    private UIComponent phoneLogin;
    private UIComponent profileReg;
    .....
    //logic with methods

如何解决?请帮忙。

1 个答案:

答案 0 :(得分:0)

private String first_name;不是EJB,但您使用@EJB注释标记它。删除注释,错误应该消失。有关注释正在执行的操作的详细信息,请参阅this link