umgewandelt werden Ich habe ein Stateless Projekt EJB (Helloworld) unter Wildfly ausgeführt 8.2.1 Final Server mit Java 1.7 und eine Client-App mit Java 1.8. Ich erhalte einen Fehler. Dankejava.lang.ClassCastException: org.jboss.ejb.client.naming.ejb.EjbNamingContext kann nicht in
Exception in thread "main" java.lang.ClassCastException: org.jboss.ejb.client.naming.ejb.EjbNamingContext kann nicht auf com.aburak.sb.SessionBeanRemote bei com gegossen werden. aburak.sb.Driver.main (Driver.java:15)
dies ist mein Treiberklasse, die Client-Anwendung
public class Driver {
public static void main(String[] args) throws NamingException {
Context context=Driver.getInitialContext();
SessionBeanRemote sbRemote= (SessionBeanRemote) context.lookup("ejb:SessionBean/SessionBean!com.aburak.sb.SessionBeanRemote");
sbRemote.sessionBeanMethod();
}
public static Context getInitialContext() throws NamingException{
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
properties.setProperty(Context.PROVIDER_URL, "http://127.0.0.1:8080");
return new InitialContext(properties);
}
}
Fern BeanSession
ist@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class SessionBean implements SessionBeanRemote, SessionBeanLocal{
private static final long serialVersionUID = -7201692010023776738L;
@Override
public void sessionBeanMethod() {
System.out.println("SessionBean executed...");
}
SessionBeanRemote
@Remote
public interface SessionBeanRemote extends SessionBeanIF{
}
(SessionBeanLocal ist genau die gleiche SessionBeanRemote außer @Local Anmerkung)
SessionBeanIF
public interface SessionBeanIF extends Serializable{
public void sessionBeanMethod();
}
und dies ist die Client-Laufwerk Klasse
public class Driver {
public static void main(String[] args) throws NamingException {
Context context=Driver.getInitialContext();
SessionBeanRemote sbRemote= (SessionBeanRemote) context.lookup("ejb:SessionBean/SessionBean!com.aburak.sb.SessionBeanRemote");
sbRemote.sessionBeanMethod();
}
public static Context getInitialContext() throws NamingException{
Properties properties = new Properties();
properties.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
properties.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
properties.setProperty(Context.PROVIDER_URL, "http://127.0.0.1:8080");
return new InitialContext(properties);
}
}
SessionBeanClient >> pom.xml
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ejb-client-bom</artifactId>
<version>8.2.1.Final</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-jms-client-bom</artifactId>
<version>8.2.1.Final</version>
<type>pom</type>
</dependency>
</dependencies>
SessionBean >> pom.xml
<dependency>
<groupId>javax.ejb</groupId>
<artifactId>javax.ejb-api</artifactId>
<version>3.2</version>
<scope>compile</scope>
</dependency>
Ich folge this tutorial video aber ich etwas App-Server ändern usw. und auch der Fehler this finden suchen, aber es hat mein Problem nicht gelöst.
Das ist meine Package explorer
Dank vier Ihre Hilfe.