eto vsichko:
mport javax.ejb.Stateless;
@Stateless(name="SimpleSession")
public class SimpleSessionBean implements SimpleSession {
public SimpleSessionBean() {
}
public String sayHello(String name) {
return "Hello "+name;
}
}
package beans;
import javax.ejb.Remote;
@Remote
public interface SimpleSession {
public String sayHello(String name) ;
}
testoviq client go ima gore no vse pak :
package client;
import beans.SimpleSession;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class SimpleSessionClient {
public static void main(String[] args) {
InitialContext ctx;
try {
ctx = new InitialContext();
ctx.addToEnvironment("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
ctx.addToEnvironment("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
ctx.addToEnvironment(Context.PROVIDER_URL,"jnp://localhost:1099");
SimpleSession simpleSession
= (SimpleSession) ctx.lookup(SimpleSession.class.getName());
System.out.println(simpleSession.sayHello("EJB3"));
} catch (NamingException e) {
e.printStackTrace();
}
}
}
jar tf ear fail
META-INF/application.xml
SimpleSessionBean.jar
jar tf jar fail
beans/SimpleSession.class
beans/SimpleSessionBean.class
kogato deployvam v loga na JBOSS vijdam :
23:28:12,296 INFO [EARDeployer] Undeploying J2EE application, destroy step: fil
e:/G:/jboss-4.0.4.GA/server/default/deploy/SimpleSessionBean.ear
23:28:12,296 INFO [EARDeployer] Undeployed J2EE application: file:/G:/jboss-4.0
.4.GA/server/default/deploy/SimpleSessionBean.ear
23:28:12,296 INFO [EARDeployer] Init J2EE application: file:/G:/jboss-4.0.4.GA/
server/default/deploy/SimpleSessionBean.ear
23:28:12,375 INFO [Ejb3Deployment] EJB3 deployment time took: 16
23:28:12,390 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:ear=Simpl
eSessionBean.ear,jar=SimpleSessionBean.jar,name=SimpleSession,service=EJB3 with
dependencies:
23:28:12,406 INFO [EJBContainer] STARTED EJB: beans.SimpleSessionBean ejbName:
SimpleSession
23:28:12,421 INFO [EJB3Deployer] Deployed: file:/G:/jboss-4.0.4.GA/server/defau
lt/tmp/deploy/tmp25139SimpleSessionBean.ear-contents/SimpleSessionBean.jar
23:28:12,421 INFO [EARDeployer] Started J2EE application: file:/G:/jboss-4.0.4.
GA/server/default/deploy/SimpleSessionBean.ear
neshto stranno obahce
v JMX console-ta vijdam
SimpleSessionBean
no v jboss.j2ee apps
veroqtno tova e MBean za saotvetnoto EJB de ama vse pak
eto paste
jboss.j2eeear=SimpleSessionBean.ear,jar=SimpleSessionBean.jar,name=SimpleSession,service=EJB3
module=SimpleSessionBean.jar,service=EJB3
application.xml-a koito e generiran ot Jdeveloper sydyrja :
<?xml version = '1.0' encoding = 'windows-1251'?>
<application xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd" version="1.4" xmlns="
http://java.sun.com/xml/ns/j2ee">
<display-name>SimpleSessionBean</display-name>
SimpleSessionBean.jar