Я работаю над проектом Java (интерфейс Swing) и пытаюсь использовать EJB, но у меня всегда одна и та же проблема:
Вот исключение, я пытался создать файл JAR из EJB (с помощью intellij idea и развернуть его в wildfly, но не работает:
развернуть JAR-файлы на wildfly
контент развернут на wildfly
исключение, когда я нажимаю кнопку «подключение»
Bonjour
01 декабря 2024 г., 23:55:19 org. wildfly.naming.client.Версия
ИНФОРМАЦИЯ: Версия WildFly Naming 2.0.1.Окончательная версия
01 декабря. 2024 23:55:20 org.wildfly.security.Version
ИНФОРМАЦИЯ: ELY00001: WildFly Elytron версия 2.3.0.Окончательная версия
01 декабря 2024 г., 23:55:20 org.xnio.Xnio.
ИНФОРМАЦИЯ: версия XNIO 3.8.16.Окончательная версия
01 декабря 2024 г., 23:55:20 org.xnio.nio.NioXnio
ИНФОРМАЦИЯ: Версия реализации XNIO NIO 3.8.16.Окончательная версия
01 декабря. 2024 23:55:20 org.jboss.threads.Version
INFO: JBoss Threads version 2.4.0.Final
01 декабря 2024 г., 23:55:20 org.jboss.remoting3.EndpointImpl
INFO: JBoss Удаленная версия 5.0.29. Финальная
здесь
global — service jboss.naming.context.java.jboss.exported.global
Исключение в потоке «AWT-EventQueue-0» java.lang.RuntimeException: javax.naming.NameNotFoundException: global — service jboss .naming.context.java.jboss.exported.global
at Mahloul.ilyas.view.client.Authentification$2.actionPerformed(Authentification.java:130)
на java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
на java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2314)
в java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:407)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:262)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:279)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6621)
в java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3398)
в java.desktop/ java.awt.Component.processEvent(Component.java:6386)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
в java.desktop/java.awt.Component.dispatchEventImpl(Component.java:4996)
в java.desktop/ java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
в java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948)
в java.desktop/ java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575)
в java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516)
в java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
в java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2780)
на java.desktop/java.awt.Component.dispatchEvent(Component.java:4828)
на java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:775)
на java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
на java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
на java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
на java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:98)
at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:747)
в java.desktop/java.awt.EventQueue$5.run(EventQueue.java:745)
в java. base/java.security.AccessController.doPrivileged(AccessController.java:400)
в java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
в java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:744)
в java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
на java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
на java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
на java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
на java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
на java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Вызвано: javax. naming.NameNotFoundException: глобальный -- сервис jboss.naming.context.java.jboss.exported.global
по адресу [email protected]//org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:89 )
в [email protected]//org.jboss.as.naming.NamingContext.lookup(NamingContext.java:190)
at [email protected]//org.jboss.as.naming.NamingContext.lookup(NamingContext.java:176)
at [email protected]//org.jboss.as.naming.NamingContext.lookup(NamingContext.java:172)
at [email protected]//org.wildfly.naming.client.remote.RemoteServerTransport.handleLookup(RemoteServerTransport.java:200)
at [email protected]//org.wildfly.naming.client.remote.RemoteServerTransport$1.handleMessage(RemoteServerTransport.java:120)
at [email protected]//org.jboss.remoting3.remote.RemoteConnectionChannel.lambda$handleMessageData$3(RemoteConnectionChannel.java:432)
at [email protected]//org.jboss.remoting3.EndpointImpl$TrackingExecutor.lambda$execute$0(EndpointImpl.java:993)
at [email protected]//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at [email protected]//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at [email protected]//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1282)
на java.base/java.lang.Thread.run(Thread. java:1583)
Процесс завершен с кодом завершения 0
Мои EJB:
IclientAuthentificationRemote
package Makhloul.ilyas.EJBs;
import jakarta.ejb.Remote;
@Remote
public interface IclientAuthentificationRemote {
public int Sauthentifier(String username, String password);
}
IClientSessionRemote:
package Makhloul.ilyas.EJBs;
import jakarta.ejb.Remote;
@Remote
public interface IClientSessionRemote {
public void seConnecter(int id );
public void deconecter() ;
}
ClientAuthentificationBean:
package Makhloul.ilyas.EJBs;
import jakarta.ejb.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@Stateless
@Remote(IclientAuthentificationRemote.class)
public class ClientAuthentificationBean implements IclientAuthentificationRemote {
@Override
public int Sauthentifier(String email, String password) {
Connection connection = null;
PreparedStatement preparedStatement = null;
ResultSet resultSet = null;
try {
// Obtenez la connexion via DBConnection
connection = DBConnection.getConnection();
if (connection == null) {
System.out.println("Impossible de se connecter à la base de données.");
return 0;
}
// Requête SQL pour vérifier l'email et le mot de passe
String sql = "SELECT id FROM clients WHERE email = ? AND password = ?";
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, email);
preparedStatement.setString(2, password);
// Exécutez la requête
resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
// Si une correspondance est trouvée, retournez l'ID du client
return resultSet.getInt("id");
} else {
// Si aucune correspondance n'est trouvée, retournez 0
return -1;
}
} catch (SQLException e) {
e.printStackTrace();
return 0;
} finally {
// Fermez les ressources
try {
if (resultSet != null) resultSet.close();
if (preparedStatement != null) preparedStatement.close();
if (connection != null) connection.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
ClientSessionBean
package Makhloul.ilyas.EJBs;
import jakarta.ejb.Remote;
import jakarta.ejb.Stateful;
@Stateful
@Remote(IClientSessionRemote.class)
public class ClientSessionBean implements IClientSessionRemote {
int clientId ;
@Override
public void seConnecter(int id ) {
this.clientId = id;
}
@Override
public void deconecter() {
this.clientId = -1;
}
}
и здесь кнопка для аутентификации
connectButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("Bonjour");
String email = emailField.getText();
String password = passwordField.getText();
if (email.isEmpty() || password.isEmpty() )
JOptionPane.showMessageDialog(mainPanel, "Veuillez remplir tous les champs!", "Erreur", JOptionPane.ERROR_MESSAGE);
else {
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
env.put(Context.PROVIDER_URL, "http-remoting://localhost:8080"); // URL de votre WildFly
env.put(Context.SECURITY_PRINCIPAL, "root"); // Nom d'utilisateur si nécessaire
env.put(Context.SECURITY_CREDENTIALS, "Ilyas2024"); // Mot de passe si nécessaire
// Initialisation du contexte JNDI
InitialContext ctx = new InitialContext(env);
/* Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
env.put(Context.PROVIDER_URL, "remote://localhost:8080"); // Adresse de votre serveur WildFly
InitialContext ctx = new InitialContext(env);*/
IclientAuthentificationRemote clientBean = (IclientAuthentificationRemote) ctx.lookup("java:global/wildfly-naming...0.1.Final/ClientAuthentificationBean!Makhloul.ilyas.EJBs.EJB.IclientAuthentificationRemote");
// IclientAuthentificationRemote authService = (IclientAuthentificationRemote) ctx.lookup("java:global/gestionHotel_RMI_EJB/ClientAuthentificationBean!Makhloul.ilyas.IclientAuthentificationRemote");
// IClientSessionRemote userSession = (IClientSessionRemote) ctx.lookup("java:global/gestionHotel_RMI_EJB/ClientSessionBean!Makhloul.ilyas.IClientSessionRemote");
int clientId = clientBean.Sauthentifier(email , password);
if(clientId==0) JOptionPane.showMessageDialog(mainPanel, "Erreur de connection!", "Erreur", JOptionPane.ERROR_MESSAGE);
else if(clientId==-1) JOptionPane.showMessageDialog(mainPanel, "Email ou password incorrect!", "Erreur", JOptionPane.ERROR_MESSAGE);
else {
System.out.println("Bienvenur Monsieur "+clientId+" !");
// userSession.seConnecter(clientId);
}
} catch (NamingException ex) {
System.out.println("here");
System.out.println(ex.getMessage());
throw new RuntimeException(ex);
}
}
}
});
Подробнее здесь: https://stackoverflow.com/questions/792 ... ted-global
Исключение при использовании EJB jboss.naming.context.java.jboss.exported.global ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Исключение при использовании EJB jboss.naming.context.java.jboss.exported.global
Anonymous » » в форуме JAVA - 0 Ответы
- 16 Просмотры
-
Последнее сообщение Anonymous
-
-
-
В JBoss 7 отсутствует jboss.naming.context.java – невозможно запустить EAR
Anonymous » » в форуме JAVA - 0 Ответы
- 22 Просмотры
-
Последнее сообщение Anonymous
-
-
-
В JBoss 7 отсутствует jboss.naming.context.java – невозможно запустить EAR
Anonymous » » в форуме JAVA - 0 Ответы
- 19 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Jboss 7 пропал без вести jboss.naming.context.java - не могу запустить ухо
Anonymous » » в форуме JAVA - 0 Ответы
- 2 Просмотры
-
Последнее сообщение Anonymous
-