[jboss-user] [EJB/JBoss] - The CMP development Problem!!!
chengshan
do-not-reply at jboss.com
Wed Sep 20 14:58:59 EDT 2006
When I develop a CMP ,I meet a problem,My env is :
1.dev env:Jbuilder;
2.run env:jboss 4.0,jdk1.5
3.I develop it ,when I deloply success,run my test client,the console information looks like:
java.security.AccessControlException: access denied (java.net.SocketPermission 230.0.0.4 connect,accept,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
at java.security.AccessController.checkPermission(AccessController.java:427)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkMulticast(SecurityManager.java:1188)
at java.net.MulticastSocket.joinGroup(MulticastSocket.java:269)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1254)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1382)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:579)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:572)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at product.client.ProductClient.main(ProductClient.java:47)
My test client is like this:
package product.client;
import javax.ejb.*;
import javax.naming.*;
import java.rmi.*;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import product.ProductHome;
import product.Product;
public class ProductClient {
public ProductClient() {
}
public static void main(String[] args) throws Exception {
ProductClient productclient = new ProductClient();
ProductHome home = null;
try{
System.setProperty("java.security.policy","policy");
System.setSecurityManager(new RMISecurityManager());
//if(System.getSecurityManager() == null)
// System.setSecurityManager(new RMISecurityManager());
Hashtable props = new Hashtable();
props.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
props.put(Context.URL_PKG_PREFIXES,"org.jboss.naming:org.jnp.interfaces");
props.put(Context.PROVIDER_URL,"jnp://localhost:1099");
Context ctx = new InitialContext(props);
home = (ProductHome)ctx.lookup("ProductBean");
//Object obj = ctx.lookup("ProductBean");
//if(obj == null)
// System.out.println("ProductBean is null");
//home = (ProductHome)PortableRemoteObject.narrow(obj,ProductHome.class);
home.create("100","P5-350","350 MHZ Pentium",200);
home.create("101","P5-400","400 MHZ Pentium",300);
home.create("102","P5-450","450 MHZ Pentium",400);
home.create("103","SD-64","64MB SDRAM",50);
home.create("104","SD-128","128MB SDRAM",100);
home.create("105","SD-256","256MB SDRAM",200);
Iterator i = home.findByName("SD-64").iterator();
System.out.println("These products match the name SD-64:");
while(i.hasNext()){
Product prod = (Product)i.next();
System.out.println("prod.getDescription()"+prod.getDescription());
}
System.out.println("Finding all Products that cost $200");
i = home.findByBasePrice(200).iterator();
while(i.hasNext()){
Product prod = (Product)i.next();
System.out.println("prod.getDescription"+prod.getDescription());
}
}catch(Exception e){
e.printStackTrace();
}finally{
if(home != null){
System.out.println("Destroying products....");
Iterator i = home.findAllProducts().iterator();
while(i.hasNext()){
try{
Product prod = (Product)i.next();
if(prod.getProductId().startsWith("123")){
prod.remove();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
}
}
}
I don't know hot to modify(add) the my policy file,the new policy file must be which dir?how to add the VM argument use policy file?
Thank you!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973042#3973042
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973042
More information about the jboss-user
mailing list