Я начинающий изучать EJB. Я хочу протестировать очень маленькое приложение ejb в netbean 6.7. Код выглядит следующим образом
package jeenptbeans;
import javax.ejb.Remote;
@Remote
public interface NewSessionRemote {
public String getEchoString(String clientString);
}
package jeenptbeans;
import javax.ejb.Stateless;
@Stateless
public class NewSessionBean implements NewSessionRemote, NewSessionLocal {
public String getEchoString(String clientString) {
return clientString + " - from session bean";
}
public String getdisString(String clientString) {
return clientString + " - from session bean";
}
Итак, я создал File -> New Project -> EJB module. И щелкните правой кнопкой мыши проект и выберите New -> Session bean и добавьте приведенный выше код. Но я запускаю этот проект, отображается сообщение «build успешно» Так что я хочу протестировать этот компонент с клиентским приложением. Поэтому я создал приложение Enterprise Application Client и добавил ejb следующим образом.
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.naming.NamingException;
import jeenptbeans.NewSessionRemote;
import javax.naming.InitialContext;
import jeenptbeans.NewSessionBean;
public class Main {
@EJB
private static NewSessionRemote newSessionBean;
public static void main(String[] args) {
try {
InitialContext ctx = new InitialContext();
newSessionBean = (NewSessionBean)ctx.lookup(NewSessionBean.class.getName());
for (int i = 0; i < args.length; i++) {
String returnedString = newSessionBean.getEchoString(args[i]);
System.out.println("sent string: " + args[i] +
", received string: " + returnedString);
}
} catch (NamingException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Но когда я запускаю это клиентское приложение, я получаю следующие исключения.
"SEC5046: Audit: Authentication refused for [admin].
Web login failed: Login failed: javax.security.auth.login.LoginException: Failed file login for admin.
CORE5024: EJB module [JEENPT-SessionEJB1] unloaded successfully!
deployed with moduleid = JEENPT-SessionEJB1
**RemoteBusinessJndiName: jeenptbeans.NewSessionRemote; remoteBusIntf: jeenptbeans.NewSessionRemote
LDR5010: All ejb(s) of [JEENPT-SessionEJB1] loaded successfully!
ADM1006:Uploading the file to:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar]
Class [ jeenptbeans/NewSessionRemote ] not found. Error while loading [ class jeenptappejbclient1.Main ]
Error in annotation processing: java.lang.NoClassDefFoundError: jeenptbeans/NewSessionRemote
deployed with moduleid = JEENPT-AppEJBClient1
Registering ad hoc servlet: WebPathPath: context root = "/JEENPT-AppEJBClient1", path = "'
Java Web Start services started for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@1bb5013 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name=
CORE5024: EJB module [JEENPT-SessionEJB1] unloaded successfully!
deployed with moduleid = JEENPT-SessionEJB1
**RemoteBusinessJndiName: jeenptbeans.NewSessionRemote; remoteBusIntf: jeenptbeans.NewSessionRemote
LDR5010: All ejb(s) of [JEENPT-SessionEJB1] loaded successfully!
classLoader = WebappClassLoader
delegate: false
repositories:
----------> Parent Classloader:
WebappClassLoader
delegate: true
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
EJBClassLoader :
urlSet = []
doneCalled = false
Parent -> java.net.URLClassLoader@103de90
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@cf10ae
Java Web Start services ended for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@1bb5013 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name=
ADM1064:The upload file at [C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar] exists and will be overwritten.
ADM1006:Uploading the file to:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar]
Class [ jeenptbeans/NewSessionRemote ] not found. Error while loading [ class jeenptappejbclient1.Main ]
Error in annotation processing: java.lang.NoClassDefFoundError: jeenptbeans/NewSessionRemote
deployed with moduleid = JEENPT-AppEJBClient1
Registering ad hoc servlet: WebPathPath: context root = "/JEENPT-AppEJBClient1", path = "'
Java Web Start services started for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@db05a8 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name=
CORE5024: EJB module [JEENPT-SessionEJB1] unloaded successfully!
classLoader = WebappClassLoader
delegate: false
repositories:
----------> Parent Classloader:
WebappClassLoader
delegate: true
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
EJBClassLoader :
urlSet = []
doneCalled = false
Parent -> java.net.URLClassLoader@103de90
SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@cf10ae
Java Web Start services ended for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@db05a8 registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name=
ADM1064:The upload file at [C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar] exists and will be overwritten.
ADM1006:Uploading the file to:[C:\Documents and Settings\Yamin\Local Settings\Temp\s1astempdomain1server1142715591\JEENPT-AppEJBClient1.jar]
Class [ jeenptbeans/NewSessionRemote ] not found. Error while loading [ class jeenptappejbclient1.Main ]
Error in annotation processing: java.lang.NoClassDefFoundError: jeenptbeans/NewSessionRemote
deployed with moduleid = JEENPT-AppEJBClient1
Registering ad hoc servlet: WebPathPath: context root = "/JEENPT-AppEJBClient1", path = "'
Java Web Start services started for stand-alone app client com.sun.enterprise.appclient.jws.AppclientContentOrigin@8500bc registration name=JEENPT-AppEJBClient1, context root=/JEENPT-AppEJBClient1, module name=
Пожалуйста, помогите мне. Это правильное или неправильное создание приложения Enterprise Application Client для тестирования простого сессионного компонента? Я также не знаю, где добавить параметры для основной функции. Чтобы протестировать этот очень простой ejb с netbean 6.7, пожалуйста, научите меня следующим шагам. Большое спасибо.