0

I'm facing a quite annoying problem making server Java processes to terminate, kicking out from this bit of code (condensed) :

_sesXslProc = new ArrayList<Transformer>();
TransformerFactory tFactory = TransformerFactory.newInstance();
for( String it : lesFichiers )
{
    try
    {
        _sesXslProc.add( tFactory.newTransformer( new StreamSource( it ) ) ); // breaks there
    }
    catch( Exception ex )
    {
        ...
    }    
}

This code is ran on a server by a cron, many processes like this can be ran at the same time (5 maxi), and the ex.getMessage shows that :

javax.xml.transform.TransformerConfigurationException: Chargement impossible de la classe translet 'cdt17totifv3'

EN : Unable to load Translet class 'cdt17totifv3'

Thus, I'm stuck with that and the manual launch of the processes is fine (generally, fails rarely).

Has anyone an idea of what can cause an XSL transform initialization to fail ?

1 Answer 1

1

This looks to me like a problem with several different threads or processes trying to use the same resources at the same time and interfering with one another. Maybe they're generating a temporary file name based on the current clock time and thus sometimes more than one process picks the same name.

If you have several OS-level processes running at the same time, try giving each one a different value for its java.io.tmpdir system property, to cause them to use different temporary directories. If it's several threads in the same java process then I don't know whether there's much option other than to wrap the newTransformer call in a synchronized block.

Sign up to request clarification or add additional context in comments.

3 Comments

Okay, I added a synchronized(tFactory) on the vicious line. I will post tomorrow the result of the night job.
Night job OK, waiting few more days to validate (or not) your solution.
Weekend passed, no more errors : I accept your answer since there is only that which changed in the code. Thanks Ian !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.