この例外が発生する前に、私は2つのプロジェクトを持っていました
ページング -> EJB を使用した単純な struts2 Web アプリケーション
シンプルな PagingWithAjaxJSON-ejb -> 上記のプロジェクトで参照される EJB アプリ。
すべてが期待どおりに機能していました。
その後、アプリに Maven を使用することにしました。Web アプリの Maven ディレクトリ構造に従って、最初のアプリ (ページング) を変更しました。そのため、ソース コードのパッケージ インポートのみを変更する必要がありました。
前(ページングアプリ内)
import beans.personBeanRemote;
.
.
and so on..
後(現在のアプリ)
import com.mycompany.ajaxstruts2.beans.personBeanRemote;
.
.
and so on..
また、それに応じてパッケージ宣言でも。
これを除いて、すべてが同じです。
しかし、今度は同じファイル index.jsp を参照すると、次のように表示されます。
**Struts Problem Report
Struts has detected an unhandled exception:
Messages:
beans.personBeanRemote
ejb ref resolution error for remote business interfacebeans.personBeanRemote
Lookup failed for 'java:global/SimplePagingWithAjaxJson-ejb/personBean!beans.personBeanRemote' 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}
javax.naming.NamingException: Lookup failed for 'java:global/SimplePagingWithAjaxJson-ejb/personBean!beans.personBeanRemote' 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: ejb ref resolution error for remote business interfacebeans.personBeanRemote [Root exception is java.lang.ClassNotFoundException: beans.personBeanRemote]]
File: org/glassfish/web/loader/WebappClassLoader.java
Line numbe 1578**
index.jsp のコード スニペットは、以前のアプリと現在のアプリの index.jsp ファイルで同じです。
ただし<%@page import=...>
、現在のプロジェクトでは、変更されたディレクトリ構造に合わせて index.jsp が変更されています。
Context c = new InitialContext();
personBeanRemote bean= (personBeanRemote) c.lookup("java:global/SimplePagingWithAjaxJson-ejb/personBean!beans.personBeanRemote");
int x = bean.getCount();
以前のアプリケーションは機能していますが、現在の Maven アプリは機能していません。両方のアプリに NetBeans IDE 6.9 を使用しました。
注: EJB アプリはそのままです。