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 Amol <am...@indicussoftware.com> on 2004/09/03 16:51:25 UTC

Cactus and weblogic7 using JBuilder9

Hello,
I am new to Cactus I just started using Cactus for EJB Unit Testing.
I used it with JBoss3.2.2 but I am facing some problem with weblogic-7.
I want to know stepwise procedure to use cactus with weblogic and run
the tests.
Please help me.
My web.xml is as follows
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <servlet>
    <servlet-name>ServletRedirector</servlet-name>
    <servlet-class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>ServletRedirector</servlet-name>
    <url-pattern>/ServletRedirector</url-pattern>
  </servlet-mapping>
  <ejb-ref>
    <ejb-ref-name>CurrencyConverter</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>example.CurrencyConverterHome</home>
    <remote>example.CurrencyConverter</remote>
    <ejb-link>CurrencyConverter</ejb-link>
  </ejb-ref>
</web-app>

and weblogic.xml is as 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 6.1//EN" "http://www.bea.com/servers/wls610/dtd/weblogic-web-jar.dtd">
<weblogic-web-app>
    <display-name>CurrencyConverter</display-name>
    <context-root>CurrencyConverter</context-root>
    <ejb-ref>
      <ejb-ref-name>CurrencyConverter</ejb-ref-name>
      <jndi-name>CurrencyConverter</jndi-name>
    </ejb-ref>
</weblogic-web-app>

I have deployed CurrencyConverter bean on weblogic succefully
now I want to test that bean so I have written a Test class as follows

package amol;

import example.*;
import javax.rmi.*;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;

import junit.framework.*;

import org.apache.cactus.*;

public class CurrencyConverterTest extends ServletTestCase
{
    private CurrencyConverter converter;

    public CurrencyConverterTest(String name)
    {
        super(name);
    }

    public static Test suite()
    {
        return new TestSuite(CurrencyConverterTest.class);
    }

    public void setUp()
    {
      try
      {
        Properties prop = new Properties();
        prop.put(Context.INITIAL_CONTEXT_FACTORY,
                 "weblogic.jndi.WLInitialContextFactory");
        prop.put(Context.PROVIDER_URL, "t3://localhost:7001");
        Context ctx = new InitialContext(prop);
        Object objref = ctx.lookup("CurrencyConverter");
        CurrencyConverterHome home =
            (CurrencyConverterHome) javax.rmi.PortableRemoteObject.narrow(
            objref, CurrencyConverterHome.class);
        converter = home.create();
      }
      catch(Exception e)
      {
        e.printStackTrace();
      }
    }

    public void testConvertCurrencyRsToDollar() throws Exception
    {
        double dollar = this.converter.ConvertCurrencyRsToDollar(2000);
        assertEquals("rs", 40, dollar, 0);
    }

    public void testConvertCurrencyDollarToRs() throws Exception
    {
        double dollar = this.converter.ConvertCurrencyDollarToRs(2000);
        assertEquals("dollar", 100000, dollar, 0);
    }
}

I created a war file of above compiled CurrencyConverterTest.class file,web.xml
and weblogic.xml and deploying it as separate webapplication on weblogic
whether I am following CORRECT procedure or it is wrong?
if wrog please tell me stepwise procedure for EJB Unit testing on
weblogic
Ii am getting error like

weblogic.management.ApplicationException: activate failed forEJB-Test
{
Module Name: EJB-Test, Error: weblogic.j2ee.DeploymentException: Could not setup environment - with nested exception:
[weblogic.deployment.EnvironmentException: Could not resolve ejbLink: CurrencyConverter]
}
	at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:1035)
	at weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.java:1016)
	at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDeployer.java:1112)
	at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer.java:732)
	at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.java:24)
	at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
	at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)


Thanks & Regards,
Amol Pophale
Software Programmer
Indicus Software Pvt. Ltd.
28, Varshananda Society,
Sinhagad Road, Pune - 411051
Tel : +91-20-24341287 / 8
Mobile No. : +91-9822207490
Email: amol@indicussoftware.com
Web: http://www.indicussoftware.com



RE: Cactus and weblogic7 using JBuilder9

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

Your problem seems to be in your application and not in Cactus. I would
suggest you use the Sample EJB application provided in the Cactus
distribution. It works fine with WL7. Make it work without changing anything
(apart from the build.properties file). You should read the doc on the
Cactus web site for how to install/run the sample application.

Once you get it to work, then you'll know what's wrong in your
application/project.

Thanks
-Vincent

> -----Original Message-----
> From: Amol [mailto:amol@indicussoftware.com]
> Sent: vendredi 3 septembre 2004 16:51
> To: cactus-user@jakarta.apache.org
> Subject: Cactus and weblogic7 using JBuilder9
> 
> 
> Hello,
> I am new to Cactus I just started using Cactus for EJB Unit Testing.
> I used it with JBoss3.2.2 but I am facing some problem with weblogic-7.
> I want to know stepwise procedure to use cactus with weblogic and run
> the tests.
> Please help me.
> My web.xml is as follows
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
> 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
> <web-app>
>   <servlet>
>     <servlet-name>ServletRedirector</servlet-name>
>     <servlet-
> class>org.apache.cactus.server.ServletTestRedirector</servlet-class>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>ServletRedirector</servlet-name>
>     <url-pattern>/ServletRedirector</url-pattern>
>   </servlet-mapping>
>   <ejb-ref>
>     <ejb-ref-name>CurrencyConverter</ejb-ref-name>
>     <ejb-ref-type>Session</ejb-ref-type>
>     <home>example.CurrencyConverterHome</home>
>     <remote>example.CurrencyConverter</remote>
>     <ejb-link>CurrencyConverter</ejb-link>
>   </ejb-ref>
> </web-app>
> 
> and weblogic.xml is as
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web
> Application 6.1//EN" "http://www.bea.com/servers/wls610/dtd/weblogic-web-
> jar.dtd">
> <weblogic-web-app>
>     <display-name>CurrencyConverter</display-name>
>     <context-root>CurrencyConverter</context-root>
>     <ejb-ref>
>       <ejb-ref-name>CurrencyConverter</ejb-ref-name>
>       <jndi-name>CurrencyConverter</jndi-name>
>     </ejb-ref>
> </weblogic-web-app>
> 
> I have deployed CurrencyConverter bean on weblogic succefully
> now I want to test that bean so I have written a Test class as follows
> 
> package amol;
> 
> import example.*;
> import javax.rmi.*;
> import java.util.Properties;
> import javax.naming.Context;
> import javax.naming.InitialContext;
> 
> import junit.framework.*;
> 
> import org.apache.cactus.*;
> 
> public class CurrencyConverterTest extends ServletTestCase
> {
>     private CurrencyConverter converter;
> 
>     public CurrencyConverterTest(String name)
>     {
>         super(name);
>     }
> 
>     public static Test suite()
>     {
>         return new TestSuite(CurrencyConverterTest.class);
>     }
> 
>     public void setUp()
>     {
>       try
>       {
>         Properties prop = new Properties();
>         prop.put(Context.INITIAL_CONTEXT_FACTORY,
>                  "weblogic.jndi.WLInitialContextFactory");
>         prop.put(Context.PROVIDER_URL, "t3://localhost:7001");
>         Context ctx = new InitialContext(prop);
>         Object objref = ctx.lookup("CurrencyConverter");
>         CurrencyConverterHome home =
>             (CurrencyConverterHome) javax.rmi.PortableRemoteObject.narrow(
>             objref, CurrencyConverterHome.class);
>         converter = home.create();
>       }
>       catch(Exception e)
>       {
>         e.printStackTrace();
>       }
>     }
> 
>     public void testConvertCurrencyRsToDollar() throws Exception
>     {
>         double dollar = this.converter.ConvertCurrencyRsToDollar(2000);
>         assertEquals("rs", 40, dollar, 0);
>     }
> 
>     public void testConvertCurrencyDollarToRs() throws Exception
>     {
>         double dollar = this.converter.ConvertCurrencyDollarToRs(2000);
>         assertEquals("dollar", 100000, dollar, 0);
>     }
> }
> 
> I created a war file of above compiled CurrencyConverterTest.class
> file,web.xml
> and weblogic.xml and deploying it as separate webapplication on weblogic
> whether I am following CORRECT procedure or it is wrong?
> if wrog please tell me stepwise procedure for EJB Unit testing on
> weblogic
> Ii am getting error like
> 
> weblogic.management.ApplicationException: activate failed forEJB-Test
> {
> Module Name: EJB-Test, Error: weblogic.j2ee.DeploymentException: Could not
> setup environment - with nested exception:
> [weblogic.deployment.EnvironmentException: Could not resolve ejbLink:
> CurrencyConverter]
> }
> 	at
> weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.j
> ava:1035)
> 	at
> weblogic.j2ee.J2EEApplicationContainer.activate(J2EEApplicationContainer.j
> ava:1016)
> 	at
> weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(SlaveDep
> loyer.java:1112)
> 	at
> weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDeployer
> .java:732)
> 	at
> weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHandler.
> java:24)
> 	at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
> 	at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
> 
> 
> Thanks & Regards,
> Amol Pophale
> Software Programmer
> Indicus Software Pvt. Ltd.
> 28, Varshananda Society,
> Sinhagad Road, Pune - 411051
> Tel : +91-20-24341287 / 8
> Mobile No. : +91-9822207490
> Email: amol@indicussoftware.com
> Web: http://www.indicussoftware.com
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cactus-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: cactus-user-help@jakarta.apache.org