Hi Dies,

Dies wrote:
> 
>> No that doesn't work either. In fact switching to this I get an error on
>> the
>> Class.forName(className) line where as previously I could create the
>> Class
>> object (but not instantiate it). When I debug using Eclipse, the method
>> does
>> get executed, but when I step over the line of code, it throws the
>> exception
>> without going into the try/catch block. Most frustrating as I can't even
>> determine what the problem is!
> 
> Could you show us the whole code of where you use Class.forName with the 
> try-catch block around it?
> Does the code work stand-alone (without Axis)?
> 

Yes the code works when calling it from a Java application as opposed to
when it is deployed into Axis.

Here is the relevant method from MailHelperFactory (the business logic
loader if you will)
public static IMailHelper loadClass( String mailHelperClassName ) {
        Class mailHelperGenClass = null;
        IMailHelper mailHelper = null;
                
        try {
            // instruct the class loader to load the MailHelper
implementation
            //mailHelperGenClass = createClass(mailHelperClassName);
            mailHelperGenClass = Class.forName( mailHelperClassName ); //
<-- using what you suggested
        } catch (java.lang.Exception e) {
            e.printStackTrace();
            throw new RuntimeException(mailHelperClassName + " Not Found");
        }
        try {
            // try to instantiate the MailHelper class
            mailHelper = (IMailHelper) mailHelperGenClass.newInstance();
            return mailHelper;
        } catch (java.lang.Exception e) {
            e.printStackTrace();
            throw new RuntimeException(mailHelperClassName + " cannot create
instance");
        }
    }

now in my test application I call:

package au.gov.abs.webservices.BpmsMessageSendingService;

import au.gov.abs.Helpers.MailHelper.IMailHelper;
import au.gov.abs.Helpers.MailHelper.MailHelperFactory;

public class Test
{

    /**
     * @param args
     */
    public static void main( String[] args )
    {
        // TODO Auto-generated method stub
        
        IMailHelper mh =
MailHelperFactory.loadClass("au.gov.abs.Helpers.MailHelper.NotesMailHelper");
        System.out.println( mh.toString() );
    }
}

That works. In my Web service:

public void sendEvent(java.lang.String headers, boolean sign,
java.lang.String invoker, java.lang.String eventname, java.lang.String
discriminator, java.lang.String eventPayload) throws
java.rmi.RemoteException 
    {
        IMailHelper mh =
MailHelperFactory.loadClass("au.gov.abs.Helpers.MailHelper.NotesMailHelper");
        System.out.println( mh.toString() );                
    }

Doesn't work. Even when I wrap the loadClass call in the Web service with a
try/catch block the exception doesn't get caught.

- Michael
--
View this message in context: 
http://www.nabble.com/Deploying+Web+services+with+Axis+1.3-t1672497.html#a4552323
Sent from the Axis - User forum at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to