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 Philippe de Rochambeau <ph...@free.fr> on 2011/11/28 21:00:11 UTC

Setting a service's CLASSPATH at runtime

Hello,

let's say that I create an Axis2 service based on a POJO class, which uses classes stored in large jar files, called, say, a.jar and b.jar, and compile it into an .aar file.

When I run the service on Tomcat, I get a "class not found" error. Adding the  jar files to the axis2 WEB-INF/services directory and WEB-INF/lib directory, makes no difference. Is there a parameter you can set to tell Axis2 where to find  custom classes/jars at runtime?

Many thanks.

p



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


AW: Calling non-multi-threaded C code in an Axis2 service

Posted by Stadelmann Josef <jo...@axa-winterthur.ch>.
Maybe the best is to make your C code thread safe.
If that is too much work then you can think of a barrier
used to synchronize the C-code-callers at the java level. 
The barrier goes down before the C code is invoked and 
once the legacy-C-code is left, the barrier goes up, and 
allows another thread to enter the same legacy-C-code. 
The third option I can see is as we do with our legacy server 
written in OpenVMS PASCAL, to use / create for each 
incoming thread an java-object talking to his own 
out-of-process server. Can be done by IPC inter-process-channels 
We create for each user-session-thread an out-of-process-server. 
As we have long lasting state full sessions, the creation time has no 
impact to overall session performance.  And in Axis2/J we use 
scope="soapsession" to make a session-thread long-lasting, 
reaching its own "process-placeholder-object". Talking
to unique objects brings you to state-full-service-providing-objects. 
This as opposed to state-less logic. Again, this works only if
you talk to legacy-C-code which is somehow isolated from the
multi thread calling capability of axis2 java sessions. i.e. a
mapping between a thread and a single-threaded-legacy-process
is required.

Josef 

-----Ursprüngliche Nachricht-----
Von: robert lazarski [mailto:robertlazarski@gmail.com] 
Gesendet: Montag, 28. November 2011 21:55
An: java-user@axis.apache.org
Betreff: Re: Calling non-multi-threaded C code in an Axis2 service

On Mon, Nov 28, 2011 at 5:13 PM, Philippe de Rochambeau <ph...@free.fr> wrote:
> Hello,
>
> I would like to create a Web service based on a class which calls C functions via JNI.
>
> The only problem is that the C functions are legacy and therefore not multi-threaded. In other words, if several people simultaneously call the service, they might cause the C code to crash.
>
> What is the best way to make the Axis2 service handle simultaneous calls without crashing or crashing the C code?
>
> Many thanks.
>wa
> p
>

Just invoke a thread in your service. A few lines of code like this
(untested) would work I think, if I understand correctly ... lots of
options also on how to setup queues, etc. One thing that comes to mind
is I do this type of thing with Spring controlled service beans, which
are loaded as singletons IIRC - that I know works. ymmv. Anyways, hope
this helps.

public class MyService {
    private static final ThreadFactory factory = new ThreadFactory();
    private ExecutorService executorService =
Executors.newSingleThreadExecutor(factory);
    private AtomicBoolean isRunning = new AtomicBoolean();

    public OMElement doMyJob(OMElement element) throws XMLStreamException {
        execute();
    }

    public void execute() throws Exception {
        try {
            if (isRunning.compareAndSet(false, true)) {
                // execute asynchronously and return immediately
                executorService.execute(new Runnable() {
                    public void run() {
                        try {
                            // put code here
                        } catch (Exception ex) {
                            logger.error(ex.getMessage(), ex);
                        }
                    }
                });
            }
        } finally {
            isRunning.set(false);
        }
    }

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


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


Re: Calling non-multi-threaded C code in an Axis2 service

Posted by robert lazarski <ro...@gmail.com>.
On Mon, Nov 28, 2011 at 5:13 PM, Philippe de Rochambeau <ph...@free.fr> wrote:
> Hello,
>
> I would like to create a Web service based on a class which calls C functions via JNI.
>
> The only problem is that the C functions are legacy and therefore not multi-threaded. In other words, if several people simultaneously call the service, they might cause the C code to crash.
>
> What is the best way to make the Axis2 service handle simultaneous calls without crashing or crashing the C code?
>
> Many thanks.
>wa
> p
>

Just invoke a thread in your service. A few lines of code like this
(untested) would work I think, if I understand correctly ... lots of
options also on how to setup queues, etc. One thing that comes to mind
is I do this type of thing with Spring controlled service beans, which
are loaded as singletons IIRC - that I know works. ymmv. Anyways, hope
this helps.

public class MyService {
    private static final ThreadFactory factory = new ThreadFactory();
    private ExecutorService executorService =
Executors.newSingleThreadExecutor(factory);
    private AtomicBoolean isRunning = new AtomicBoolean();

    public OMElement doMyJob(OMElement element) throws XMLStreamException {
        execute();
    }

    public void execute() throws Exception {
        try {
            if (isRunning.compareAndSet(false, true)) {
                // execute asynchronously and return immediately
                executorService.execute(new Runnable() {
                    public void run() {
                        try {
                            // put code here
                        } catch (Exception ex) {
                            logger.error(ex.getMessage(), ex);
                        }
                    }
                });
            }
        } finally {
            isRunning.set(false);
        }
    }

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


Calling non-multi-threaded C code in an Axis2 service

Posted by Philippe de Rochambeau <ph...@free.fr>.
Hello,

I would like to create a Web service based on a class which calls C functions via JNI.

The only problem is that the C functions are legacy and therefore not multi-threaded. In other words, if several people simultaneously call the service, they might cause the C code to crash.

What is the best way to make the Axis2 service handle simultaneous calls without crashing or crashing the C code?

Many thanks.

p







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