You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Michael Watson <wa...@evolove.net> on 2006/05/24 03:18:28 UTC

Deploying Web services with Axis 1.3

I've been trying to figure out how to deploy services using Tomcat 5.5.12 and
Axis 1.3 but I'm having some trouble figuring it out

The user manual for 1.2 (Can't find a link to a 1.3 user manual if there is
one) has only the most very basic deployment instructions and following them
I am able to deploy a very simple Web service where all the implementation
is in the *Impl class. I'm trying to find some slightly more detailed
deployment documentation. Does anyone have a link to some?

Basically what I want to do is have some business logic in one package and
then have the Web service call that business logic. How/where do I put the
class files for these packages?

At the moment I have things set up like this:

Service is in:
\Tomcat\webapps\axis\WEB-INF\classes\au\gov\abs

Helper ('Business Logic") is in:
\Tomcat\webapps\axis\WEB-INF\classes\au\gov\abs\Helpers

But when I try and load the actual implemntation class in the helper using
class.newInstance() I get an exception (one that will not get caught despite
surrounding it in a try/catch block) thrown back to the client. So I assume
I haven't set things out correctly.

Also when using a resource bundle with a properties file, the properties
file needs to be in \Tomcat\webapps\axis\WEB-INF\classes\ to be found. Does
this mean that all services on the server need to have differently named
properties files? Do all services on the server share the helper classes?
What if I want to have different versions of the same service on the server
with different versions of classes?

Sorry if these are all basic questions, I'm still trying to get my head
around Java and Axis.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Michael Watson <wa...@evolove.net>.
Hi Dies,

Thanks for that! Replacing the exceptions with catching throwables gave me
the clue I needed to work out the problem. I didn't have some other classes
in the classpath for Tomcat, but I did for the Eclipse project. So it worked
there, but not in Tomcat. Fixed now tho :-)

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Michael,

Your code looks okay at first glance, so I still suspect an environment 
setting issue..
Regarding the exception you can't catch, could it be an Error that's 
thrown? Try replacing the catch (Exception e)'s with catch (Throwable t)'s..

Regards,
Dies


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Michael Watson <wa...@evolove.net>.
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: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Michael,

> 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)?

> I'm guessing I would need to load the properties before hand and pass them
> to the common jar. You'll have to forgive my lack of knowledge when it comes
> to Java; I've been using .NET for the last 3 years so I haven't had to worry
> about classpaths. Is passing the properties when you load the common jar
> (through say the constructor) the common way to handle this sort of issue?

I think you are trying to apply some OO and have the common jar have 
interface or factory class through which you access it. Depending on how 
common you want that code to be, there are various ways to do this.
If the properties are not vital to make the initial instance, using one 
or more setters would come to mind. If you want the jar to depend on a 
property file, you could also just pass the path to it.
You could try discussing it in a Java developing related mailing list.

Regards,
Dies


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Michael Watson <wa...@evolove.net>.
Hi Dies,

Thank you again for your help :)


Dies wrote:
> 
>> I've checked out the wiki also, but again it only seems to deal with the
>> Web
>> service is all in one package deployment.
> 
> As I see it you can deploy multiple web services in two ways:
> 1. deploy them into the same Axis servlet
> 2. deploy the Axis servlet twice, deploy each web service into one of
> them.
> 
> With the former, they share the same classloader so you cannot have two 
> versions of classes with the same name/package.
> With the latter they can.
> 
> If you are wondering how to set up the latter, it is the same as with 
> the former, just do it twice (just give them a different context-root).
> 

Thanks for clearing that up for me. As I said, I'm still trying to get my
head around Axis.


Dies wrote:
> 
>> it works. However if I try to do the following:
>> 
>> class c =
>> Thread.currentThread().getContextClassLoader().loadClass(className);
>> businesslogic bl = (businesslogic) c.getInstance();
>> 
>> I get an exception. Any ideas why? Also any ideas why the exception
>> refuses
>> to be caught even though I wrap it in a try/catch(Exception e) block? The
>> error on the client side is java.lang.reflect.InvocationTargetException
> 
> The InvocationTargetException at the client could have a range of 
> causes. Probably, either your method with the try/catch block did not 
> even get executed (Axis had a problem invoking your method), or it did, 
> successfully or not, and after that an error occurred. You might want to 
> add a bunch of println statements to your impl's method to see how much 
> of your method is actually called.
> Also, if you use Class.forName(className) instead of the context 
> classloader to load your business logic classes, does it not work?
> 

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!


Dies wrote:
> 
>> Sorry, I'm not 100% sure what you mean here, are you saying that it is
>> usual
>> to store the properties files in a jar (in which case can you alter
>> them?)
>> or just that you should have separate names for them? I am slightly
>> confused
>> at the way that you would have a common package that needs a different
>> configuration for each service it is used in. It seems to me that this is
>> not possible unless you pass the properties to the common package when
>> you
>> instantiate it?
> 
> Maybe I misunderstood what you said. You were talking about a resource 
> bundle with a properties file. I'd expect it to contain locale-specific 
> resources (like messages, image filenames). Each component has its own 
> locale-specific objects and therefore its own property file (usually in 
> the same package in the jar).
> Now I (think that I) understand that you have several web services that 
> share some common jar with business logic, and you need to pass 
> properties to this jar that differ for each invoking service?
> Forget web services, what if you had two clients that you'd have to 
> start with the same classpath setting, how would you do this?
> 

I'm guessing I would need to load the properties before hand and pass them
to the common jar. You'll have to forgive my lack of knowledge when it comes
to Java; I've been using .NET for the last 3 years so I haven't had to worry
about classpaths. Is passing the properties when you load the common jar
(through say the constructor) the common way to handle this sort of issue?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


error while deploying ws

Posted by "eL. Bi." <av...@yahoo.it>.
Hi,

i got this error when i run my client to access the
Web service. I have already used the AdminClient to
deploy it, and i can see it on the list of available
service on Axis.

nested exception is: java.net.ConnectException:
Invalid argument

Can anyone give to me suggestions about this error?

Tanks, Luca.


Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Michael,

> I've checked out the wiki also, but again it only seems to deal with the Web
> service is all in one package deployment.

As I see it you can deploy multiple web services in two ways:
1. deploy them into the same Axis servlet
2. deploy the Axis servlet twice, deploy each web service into one of them.

With the former, they share the same classloader so you cannot have two 
versions of classes with the same name/package.
With the latter they can.

If you are wondering how to set up the latter, it is the same as with 
the former, just do it twice (just give them a different context-root).

> Yes, the folders correspond to the package names. I am able to reference the
> business logic statically, but can't do it dynamically. For example if in my
> Web service *Impl class I write:
> 
> businesslogic bl = new businesslogic();
> bl.doSomething();
> 
> it works. However if I try to do the following:
> 
> class c =
> Thread.currentThread().getContextClassLoader().loadClass(className);
> businesslogic bl = (businesslogic) c.getInstance();
> 
> I get an exception. Any ideas why? Also any ideas why the exception refuses
> to be caught even though I wrap it in a try/catch(Exception e) block? The
> error on the client side is java.lang.reflect.InvocationTargetException

The InvocationTargetException at the client could have a range of 
causes. Probably, either your method with the try/catch block did not 
even get executed (Axis had a problem invoking your method), or it did, 
successfully or not, and after that an error occurred. You might want to 
add a bunch of println statements to your impl's method to see how much 
of your method is actually called.
Also, if you use Class.forName(className) instead of the context 
classloader to load your business logic classes, does it not work?

>>> Also when using a resource bundle with a properties file, the properties
>>> file needs to be in \Tomcat\webapps\axis\WEB-INF\classes\ to be found.
>>> Does
>>> this mean that all services on the server need to have differently named
>> Yes. It is usual to put your property files in packages like your 
>> classes, so this should not be a problem?
> 
> Sorry, I'm not 100% sure what you mean here, are you saying that it is usual
> to store the properties files in a jar (in which case can you alter them?)
> or just that you should have separate names for them? I am slightly confused
> at the way that you would have a common package that needs a different
> configuration for each service it is used in. It seems to me that this is
> not possible unless you pass the properties to the common package when you
> instantiate it?

Maybe I misunderstood what you said. You were talking about a resource 
bundle with a properties file. I'd expect it to contain locale-specific 
resources (like messages, image filenames). Each component has its own 
locale-specific objects and therefore its own property file (usually in 
the same package in the jar).
Now I (think that I) understand that you have several web services that 
share some common jar with business logic, and you need to pass 
properties to this jar that differ for each invoking service?
Forget web services, what if you had two clients that you'd have to 
start with the same classpath setting, how would you do this?

Regards,
Dies


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Michael Watson <wa...@evolove.net>.
Hi Dies, 

Thanks for your reply :)


Dies wrote:
> 
> I believe there are no major updates to the manual since the 1.2. The 
> version number is not even updated.
> Regarding detailed documentation, also check out the Wiki, and this 
> mailing list.
> http://wiki.apache.org/ws/FrontPage/Axis
> 

I've checked out the wiki also, but again it only seems to deal with the Web
service is all in one package deployment.


Dies wrote:
> 
>> But when I try and load the actual implemntation class in the helper
>> using
>> class.newInstance() I get an exception (one that will not get caught
>> despite
>> surrounding it in a try/catch block) thrown back to the client. So I
>> assume
>> I haven't set things out correctly.
> 
> I assume so, I think you put your classes in the right place (provided 
> the directory names match your package name).
> 

Yes, the folders correspond to the package names. I am able to reference the
business logic statically, but can't do it dynamically. For example if in my
Web service *Impl class I write:

businesslogic bl = new businesslogic();
bl.doSomething();

it works. However if I try to do the following:

class c =
Thread.currentThread().getContextClassLoader().loadClass(className);
businesslogic bl = (businesslogic) c.getInstance();

I get an exception. Any ideas why? Also any ideas why the exception refuses
to be caught even though I wrap it in a try/catch(Exception e) block? The
error on the client side is java.lang.reflect.InvocationTargetException


Dies wrote:
> 
>> Also when using a resource bundle with a properties file, the properties
>> file needs to be in \Tomcat\webapps\axis\WEB-INF\classes\ to be found.
>> Does
>> this mean that all services on the server need to have differently named
> 
> Yes. It is usual to put your property files in packages like your 
> classes, so this should not be a problem?
> 

Sorry, I'm not 100% sure what you mean here, are you saying that it is usual
to store the properties files in a jar (in which case can you alter them?)
or just that you should have separate names for them? I am slightly confused
at the way that you would have a common package that needs a different
configuration for each service it is used in. It seems to me that this is
not possible unless you pass the properties to the common package when you
instantiate it?

Thanks for all your help, and any further help you can provide :)

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


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Deploying Web services with Axis 1.3

Posted by Dies Koper <di...@jp.fujitsu.com>.
Hello Michael,

I believe there are no major updates to the manual since the 1.2. The 
version number is not even updated.
Regarding detailed documentation, also check out the Wiki, and this 
mailing list.
http://wiki.apache.org/ws/FrontPage/Axis

> Basically what I want to do is have some business logic in one package and
> then have the Web service call that business logic. How/where do I put the
> class files for these packages?

In
\Tomcat\webapps\axis\WEB-INF\classes
or
\Tomcat\webapps\axis\WEB-INF\lib

> Helper ('Business Logic") is in:

Axis uses helper classes called "helper classes" to help with the 
serialization and deserialization of SOAP messages. Let's call your 
Business Logic classes "Business Logic classes" to prevent confusion.

> But when I try and load the actual implemntation class in the helper using
> class.newInstance() I get an exception (one that will not get caught despite
> surrounding it in a try/catch block) thrown back to the client. So I assume
> I haven't set things out correctly.

I assume so, I think you put your classes in the right place (provided 
the directory names match your package name).

> Also when using a resource bundle with a properties file, the properties
> file needs to be in \Tomcat\webapps\axis\WEB-INF\classes\ to be found. Does
> this mean that all services on the server need to have differently named

Yes. It is usual to put your property files in packages like your 
classes, so this should not be a problem?

> properties files? Do all services on the server share the helper classes?

They can all "see" them.

> What if I want to have different versions of the same service on the server
> with different versions of classes?

If the package names are the same, you'd have to deploy different 
instances of Axis, each with its own WEB-INF/classes. You cannot deploy 
web services that use different classes with the same package/names into 
the same instance of Axis.

> Sorry if these are all basic questions, I'm still trying to get my head
> around Java and Axis.

Good luck!
Dies


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org