[jboss-user] [JBoss Getting Started Documentation] - Re: how to deploy the hellowworld bean in JBOSS-i dont find
singam_19
do-not-reply at jboss.com
Wed Oct 25 03:30:21 EDT 2006
This document is completely for the JBOSS- Remote home interface.---SingamGiridharaReddy(TataElxsi)-singam_19 at yahoo.com
1)
a)META-INF
Ejb-jar.xml
Jboss.xml
b)Clinet/demo
HellowWorldTest
c)Ejb/demo
HellowWorld
HellowWorldBean
HellowWorldHome
d)JNDI.properties:keep this parellel to your META-INF folder.
2)The contents of ejb-jar file
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--Here the encoding typs is very important.and dtd is also very important.And also it is very important not to have any spaces in this xml file.-->
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN'
'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar>
<enterprise-beans>
<![CDATA[Interface Session Bean]]>
<display-name>HellowWorldDemo</display-name>
<ejb-name>HellowWorldDemo</ejb-name>
ejb.demo.HellowWorldHome
ejb.demo.HellowWorld
<ejb-class>ejb.demo.HellowWorldBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</enterprise-beans>
</ejb-jar>
3)The contents of jboss.xml file
<?xml version="1.0" encoding="UTF-8"?>
<enterprise-beans>
<ejb-name>HellowWorldDemo</ejb-name>
<jndi-name>HellowWorldDemo</jndi-name>
</enterprise-beans>
4)The contents of jndi.properties
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp\://127.0.0.1\:1099
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
5)change the configuration in the following way in the jboss-service.xml
<mbean code="org.jboss.naming.NamingService"
name="jboss:service=Naming"
xmbean-dd="resource:xmdesc/NamingService-xmbean.xml">
<!-- The call by value mode. true if all lookups are unmarshalled using
the caller's TCL, false if in VM lookups return the value by reference.
-->
false
<!-- The listening port for the bootstrap JNP service. Set this to -1
to run the NamingService without the JNP invoker listening port.
-->
1099
<!-- The bootstrap JNP server bind address. This also sets the default
RMI service bind address. Empty == all addresses
-->
${jboss.bind.address}
<!-- The port of the RMI naming service, 0 == anonymous -->
1098
<!-- The RMI service bind address. Empty == all addresses
-->
${jboss.bind.address}
<!-- The thread pool service used to control the bootstrap lookups -->
<depends optional-attribute-name="LookupPool"
proxy-type="attribute">jboss.system:service=ThreadPool
6)
a)The jar file that need to in classpath while compiling server files
javac -classpath D:\jboss-4.0.4.GA\client\jboss-j2ee.jar ejb\demo\*.java
b)The content that need to be in server jar file are
jar cvf HellowWorldDemoEJB.jar ejb\demo\* META-INF\
c)Keep the HellowWorldDemoEJB.jar under the
D:\jboss-4.0.4.GA\server\default\deploy
d)The jar files that need to be in classpath while compiling client files
javac -classpath D:\project7\HellowWorldDemoEJB.jar;D:\jboss-4.0.4.GA\client\jboss-j2ee.jar client\demo\*.java
e)The content that need to be in client jar file are
D:\project7>jar cvf HellowWorldDemoclient.jar ejb/demo/HellowWorld.class HellowWorldHome.class client/demo/*.class jndi.properties
f)Copy the client jar under
D:\jboss-4.0.4.GA\client\HellowWorldDemoclient.jar;
g)The Jar files that need to be in class path while running client .
D:\project7>D:\dev\vendor\Windows\sun\jdk\jdk1.5.0_03\bin\java -Djava.security.policy=java.policy -classpath D:\jboss.0.4.GA\client\HellowWorldDemoclient.jar;
D:\jboss-4.0.4.GA\client\jnp-client.jar;D:\jboss-4.0.4.GA\client\jboss-j2ee.jar;
D:\jboss-4.0.4.GA\client\jboss-common-client.jar;D:\jboss-4.0.4.GA\client\jbossa
ll-client.jar;. client.demo.HellowWorldTest
7) -Djava.security.policy=java.policy is must to pass as the argument.
Java,policy file which will be under D:\dev\vendor\Windows\sun\jdk\jdk1.5.0_03\jre\lib\security need to altered or added
As the following
permission java.util.PropertyPermission "org.jboss.security.SecurityAssociation.ThreadLocal", "read";
permission java.lang.RuntimePermission "org.jboss.security.SecurityAssociation.getPrincipalInfo";
permission java.io.SerializablePermission "enableSubstitution";
permission java.net.SocketPermission "*:1024-65535", "listen,connect,accept,resolve";
8)The source files:
Server files:
package ejb.demo;
//import java.rmi.Remote;
//import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.EJBObject;
import java.rmi.RemoteException;
public interface HellowWorld
extends EJBObject
{
public String hellow()
throws RemoteException;
}
b)
package ejb.demo;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
// Referenced classes of package ejb.demo:
// HellowWorld
public interface HellowWorldHome
extends EJBHome
{
public HellowWorld create()
throws RemoteException,CreateException;
}
c)
package ejb.demo;
//import java.rmi.RemoteException;
import javax.ejb.*;
public class HellowWorldBean
implements SessionBean
{
public HellowWorldBean()
{
}
public void ejbCreate()
{
}
public void ejbActivate()
throws EJBException
{
}
public void ejbPassivate()
throws EJBException
{
}
public void ejbRemove()
throws EJBException
{
}
public void setSessionContext(SessionContext sessioncontext)
throws EJBException
{
this.ctx=sessioncontext ;
}
public String hellow()
throws EJBException
{
return "hello world";
}
private SessionContext ctx;
static final boolean verbose = true;
}
client file:
package client.demo;
import javax.naming.*;
import ejb.demo.HellowWorldHome;
import ejb.demo.HellowWorld;
import java.util.Properties;
import javax.rmi.*;
import java.rmi.RMISecurityManager;
/**
*
* @author Singam.Reddy
*/
public class HellowWorldTest {
/** Creates a new instance of HellowWorldTest */
public HellowWorldTest() {
}
public static void main(String args[])
{
HellowWorldHome hw=null;
Context context1=null;
HellowWorld hwa = null;
try{
/* Properties env = new Properties();
System.out.println("got here 1a");
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url", "localhost:1099");
env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
System.out.println("got here 1b");
*/
context1 = new InitialContext();
System.out.println("got here 1c");
/*hw=(HellowWorldLocalHome)PortableRemoteObject.narrow(context1.lookup("HellowWorldDemoLocal"),HellowWorldLocalHome.class);
*/
hw = ( HellowWorldHome)context1.lookup("HellowWorldDemo");
System.out.println("got here 1");
if (System.getSecurityManager() == null)
{
System.setSecurityManager(new RMISecurityManager());
}
hwa = hw.create();
System.out.println("hellow"+hwa.hellow());
}catch(Exception e)
{
e.printStackTrace() ;
}
}
public static void close(Context context2)
{
try{
System.out.println("got here 4");
context2.close();
}catch(NamingException namingException)
{
namingException.printStackTrace();
}
}
}
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3980629#3980629
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3980629
More information about the jboss-user
mailing list