You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-user@jakarta.apache.org by Daniel Lehmann <dk...@hotmail.com> on 2003/10/13 10:30:00 UTC

ServletTestCase - Error looking up EJB

Hi,

I am trying to build a project using a standalone Tomcat webserver (4.12.1) 
and JBoss 3.2.1.  For unit testing I am using Cactus 13.1.5 beta1.  The goal 
is to automate the whole thing within an Ant build script (Starting up 
Tomcat from Ant, JBoss is running already).  However, I am encountering the 
following two problems:

1.
I cannot build the project from my IDE (Eclipse) because the IDE compiler 
cannot find the CactusTask.class (ClassNotFound).  It works when I run ant 
directly from the command line.  Has anyone encountered this before?  I 
tried adding the cactus.jar to the build classpath etc., but it still 
doesn't work.

2.
When building the project via command line I am getting this error trying to 
set up my test in the ServletTestCase class:

[cactus] CACTUS ERROR RUNNING setUp(): javax.naming.CommunicationException
[Root exception is java.rmi.ServerException: RemoteException occurred in 
server thread; nested exception is:
[cactus]     java.rmi.UnmarshalException: error unmarshalling arguments; 
nested exception is:
[cactus]     java.net.MalformedURLException: no protocol: and]
[cactus] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 3.285 sec

*****************************************************************************

Here is the code that produces the error:


public void setUp()
{
   System.setProperty("java.naming.factory.initial", 
"org.jnp.interfaces.NamingContextFactory");
   System.setProperty("java.naming.provider.url", "jnp://myserver:1099");
   System.setProperty("java.naming.factory.url.pkgs", 
"org.jboss.naming:org.jnp.interfaces");

  try
  {
	InitialContext ctx = new InitialContext();


	OrderSessionHome home = (OrderSessionHome)
		PortableRemoteObject.narrow(ctx.lookup("ejb/pizzaTrader/OrderSession"),
				OrderSessionHome.class);

	session = home.create();
  }
	catch(Exception ex)
	{
		System.out.println("CACTUS ERROR RUNNING setUp(): " + ex.toString());
	}
}

*******************************************************************************

Any help is greatly appreciated.

Regards,
Daniel

_________________________________________________________________
High-speed Internet access as low as $29.95/month (depending on the local 
service providers in your area). Click here.   https://broadband.msn.com


RE: ServletTestCase - Error looking up EJB

Posted by Vincent Massol <vm...@pivolis.com>.
Hi,

> -----Original Message-----
> From: Daniel Lehmann [mailto:dklehmann@hotmail.com]
> Sent: 13 October 2003 10:30
> To: cactus-user@jakarta.apache.org
> Subject: ServletTestCase - Error looking up EJB
> 
> Hi,
> 
> I am trying to build a project using a standalone Tomcat webserver
> (4.12.1)
> and JBoss 3.2.1.  For unit testing I am using Cactus 13.1.5 beta1.
The
> goal
> is to automate the whole thing within an Ant build script (Starting up
> Tomcat from Ant, JBoss is running already).  However, I am
encountering
> the
> following two problems:
> 
> 1.
> I cannot build the project from my IDE (Eclipse) because the IDE
compiler
> cannot find the CactusTask.class (ClassNotFound).  It works when I run
ant
> directly from the command line.  Has anyone encountered this before?
I
> tried adding the cactus.jar to the build classpath etc., but it still
> doesn't work.

That's an Eclipse "limitation"... You'll find this issue with any custom
task. The solution is to explicitly define the task it in Eclipse: open
the Ant properties dialog box and using the "Task" tab, add the cactus
tasks.

> 
> 2.
> When building the project via command line I am getting this error
trying
> to
> set up my test in the ServletTestCase class:
> 
> [cactus] CACTUS ERROR RUNNING setUp():
javax.naming.CommunicationException
> [Root exception is java.rmi.ServerException: RemoteException occurred
in
> server thread; nested exception is:
> [cactus]     java.rmi.UnmarshalException: error unmarshalling
arguments;
> nested exception is:
> [cactus]     java.net.MalformedURLException: no protocol: and]
> [cactus] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 3.285 sec
> 

[snip]

I can't guess anything with out a full stack trace. You should NOT catch
the error in your test (a bad practice) and instead let it bubble up;
you'll then be able to get the full stack trace...

Thanks
-Vincent