The Artima Developer Community
Sponsored Link

SuiteRunner Forum
Attempting to connect to EJB fails

2 replies on 1 page. Most recent reply: Jun 4, 2004 11:20 AM by devendra

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Frank Burough

Posts: 1
Nickname: fwburough
Registered: Mar, 2003

Attempting to connect to EJB fails Posted: Mar 20, 2003 9:45 AM
Reply to this message Reply
Advertisement
Hi--

I am writing an application that needs to access some EJBs for its functionality. I need to access the real EJBs rather than write stubs for integration tests. Can SuiteRunner do this? My first attempt yields exceptions.

Here is the relevant (I think) code:

Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");
properties.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");

InitialContext jndiContext = new InitialContext(properties);

Object ref = jndiContext.lookup("StringProcessor");

I get an exception raised on the call to jndiContext.lookup:
Test Failed
Name: AdminDBSuite.testGetUserList()
Message: javax.naming.CommunicationException [Root exception is java.lang.ClassNotFoundException: com.javapro.ejb.StringProcessorHome (no security manager: RMI class loader disabled)]
Date: Thu Mar 20 11:30:53 EST 2003
Source: tests.AdminDBSuite@149a794
Thread: Thread-3
Throwable:
javax.naming.CommunicationException. Root exception is java.lang.ClassNotFoundException: com.javapro.ejb.StringProcessorHome (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:521)
<rest of the stack trace deleted for clarity>

Any ideas??

Thanks for your help!

The same code works great as an application.

Frank


Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: Attempting to connect to EJB fails Posted: Mar 21, 2003 8:36 PM
Reply to this message Reply
When you start the JVM with no security manager installed, RMI won't load classes remotely. It looks like that's what your problem is.

I don't create a security manager in SuiteRunner, so you should be able to install one in your test code. For example, you could put this code in the constructor of your main Suite:

if (System.getSecurityManager() == null) {
     System.setSecurityManager(new RMISecurityManager());
}


You'll have to specify a policy file when you start SuiteRunner, as in:


java -Djava.security.policy=policy.all -jar suiterunner.jar myrecipe.srj


A nice tutorial on RMISecurityManager is here:

http://gethelp.devx.com/techtips/java_pro/10MinuteSolutions/10min0500.asp

I haven't tried this. If you get this to work, please post again here.

Thanks.

devendra

Posts: 1
Nickname: devendra
Registered: Jun, 2004

Attempting to connect to EJB fails Posted: Jun 4, 2004 11:20 AM
Reply to this message Reply
hi everybody
i have tried all above recommodation but problem doesn't diverted
plz help

Flat View: This topic has 2 replies on 1 page
Topic: 1.0beta7 and junit Previous Topic   Next Topic Topic: System Programing with VC++(Disk I/O)

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use