gpt4 book ai didi

jsf - @EJB(lookup) 因 org.omg.CosNaming.NamingContextPackage.NotFound 而失败

转载 作者:行者123 更新时间:2023-12-04 19:48:36 25 4
gpt4 key购买 nike

我在 Websphere 8.5 上部署了一个应用程序,它给出了以下异常:

[10/6/13 22:30:18:323 PDT] 000000be InjectionBind E   CWNEN0030E: The @EJB factory encountered a problem getting the object instance com.chander.test.web.managebean.Registration/staticDataService binding object.  The exception message was: Context: chander-4ae021bNode01Cell/nodes/chander-4ae021bNode01/servers/server1, name: com.chander.test.service.api.StaticDataService: First component in name com.chander.test.service.api.StaticDataService not found.
[10/6/13 22:30:18:417 PDT] 000000be annotation E com.ibm.ws.webcontainer.annotation.WASAnnotationHelper inject SRVE8060E: An unexpected exception occurred during resource injection.
com.ibm.wsspi.injectionengine.InjectionException: Unable to obtain an instance for com.chander.test.web.managebean.Registration/staticDataService: javax.naming.NameNotFoundException: Context: chander-4ae021bNode01Cell/nodes/chander-4ae021bNode01/servers/server1, name: com.chander.test.service.api.StaticDataService: First component in name com.chander.test.service.api.StaticDataService not found. [Root exception is org.omg.CosNaming.NamingContextPackage.NotFound: IDL:omg.org/CosNaming/NamingContext/NotFound:1.0]
at com.ibm.wsspi.injectionengine.InjectionBinding.getInjectionObject(InjectionBinding.java:1123)
at com.ibm.ws.ejb.injection.processor.EJBInjectionBinding.getInjectionObject(EJBInjectionBinding.java:1101)

以下是注册类:

@SuppressWarnings("serial")
@ManagedBean(name = "registration")
@SessionScoped
public class Registration implements Serializable {

private static final Logger log = LoggerFactory.getLogger(Registration.class);

private UserRegistrationForm form = new UserRegistrationForm();

@EJB(lookup = "com.chander.test.service.api.StaticDataService")
private StaticDataService staticDataService;

public StaticDataService getStaticDataService() {
return staticDataService;
}

public UserRegistrationForm getForm() {
return form;
}

public void setForm(UserRegistrationForm form) {
this.form = form;
}

// navigation

public String toFirstPage() {
log.info("Registration First Page");

return "REGISTRATION_FIRST_PAGE";
}

public String toSecondPage() {
log.info("Registration Second Page");

return "REGISTRATION_SECOND_PAGE";
}

}

persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">

<persistence-unit name="chander.test" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>oracle/chander_datasource</jta-data-source>

<class>com.chander.test.dao.model.UserProfile</class>
<class>com.chander.test.dao.model.CreditCard</class>
<class>com.chander.test.dao.model.Address</class>
<class>com.chander.test.dao.model.Country</class>

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.hbm2ddl.auto" value="none" />

<property name="hibernate.transaction.factory_class"
value="org.hibernate.transaction.CMTTransactionFactory" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.WebSphereExtendedJTATransactionLookup" />

<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="false" />
<property name="hibernate.use_sql_comments" value="false"/>
</properties>
</persistence-unit>
</persistence>

最佳答案

我想 com.chander.test.service.api.StaticDataService 是您的 EJB 类或接口(interface)的名称。 @EJB 注释的 lookup 参数采用 JNDI 路径。

我不知道 Websphere 8 如何将 EJB 置于 JNDI 上下文中,但您确定这是正确的吗?您是否尝试过省略 lookup,即:

@EJB
private StaticDataService staticDataService;

关于jsf - @EJB(lookup) 因 org.omg.CosNaming.NamingContextPackage.NotFound 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19218124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com