You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Brecht Yperman <Br...@invenso.com> on 2006/07/11 10:38:09 UTC

TransformerFactory.newInstance() hangs

Hi,

we've developed a script language which is translated into a Java
program.

The following bit of code is standard in the generated Java class

* ----- *
| CODE  |
* ----- *
if (level>=10 & logging) logLine(3,new
String[]{"serializer",toString(serializer)},10);
if (level>=10 & logging) logLine(10,new String[]{},10);
try {
   TransformerFactory factory = null;
   factory = TransformerFactory.newInstance();
   if (level>=10 & logging) logLine(3,new
String[]{"factory",toString(factory)},10);
   serializer = factory.newTransformer();
   if (level>=10 & logging) logLine(3,new
String[]{"serializer",toString(serializer)},10);
}
catch (Exception e) {
   if (level>=10 & logging) logLine(23,new String[]{},10);
   if (level>=5 & logging) logLine(28,new String[]{"couldn't make new
transformer"},5);
}
if (level>=10 & logging) logLine(11,new String[]{},10);
* ----- *
| /CODE |
* ----- *

The first two logLines are logged, the third one (right after
TransformerFactory.newInstance()) isn't anymore. The program doesn't
quit, no exceptions are thrown.

On our developer machines this works without problems, when we install
our software on a clean, newly installed pc, it doesn't work.

I've tried adding the system value for
javax.xml.transform.TransformerFactory. I'm also sure the xalan.jar
(2.7.0) is on the classpath.

Anyone knows what to do now?

Thanks,
Brecht 

Re: TransformerFactory.newInstance() hangs

Posted by Erin Harris <eh...@ca.ibm.com>.
Hi Brecht,

A couple of things to try:

1.  Add the following to your code before calling 
TransformerFactory.newInstance to make sure the correct factory is being 
used:

String key = "javax.xml.transform.TransformerFactory";
String value = "org.apache.xalan.processor.TransformerFactoryImpl";  // 
Interpreter factory - change to 
"org.apache.xalan.xsltc.trax.TransformerFactoryImpl" for compiled.
Properties props = System.getProperties();
props.put(key, value);
System.setProperties(props);

2. Use the env (windows) instruction (or equivalent) to compare the 
environments on the machine where it works and the one where it doesn't.

3. Use a debugger to suspend the program to see where it is hanging.  Jdb 
can be used to do this.  Start jdb, run the program, wait for a bit so it 
is hanging then enter suspend.  List the threads to get the thread ids. 
Then use where <thread id> to get the stack for each thread.  If the 
program is not multithreaded then just get the stack for the main thread. 
"jdb -?" for help on starting jdb.  Once jdb is started just enter ? to 
get command help.

> jdb
> run <classname> <args>
> suspend
> threads
> where <thread id>

Thanks.

Erin Harris




"Brecht Yperman" <Br...@invenso.com> 
11/07/2006 04:38 AM

To
<xa...@xml.apache.org>
cc

Subject
TransformerFactory.newInstance() hangs






Hi,

we've developed a script language which is translated into a Java
program.

The following bit of code is standard in the generated Java class

* ----- *
| CODE  |
* ----- *
if (level>=10 & logging) logLine(3,new
String[]{"serializer",toString(serializer)},10);
if (level>=10 & logging) logLine(10,new String[]{},10);
try {
   TransformerFactory factory = null;
   factory = TransformerFactory.newInstance();
   if (level>=10 & logging) logLine(3,new
String[]{"factory",toString(factory)},10);
   serializer = factory.newTransformer();
   if (level>=10 & logging) logLine(3,new
String[]{"serializer",toString(serializer)},10);
}
catch (Exception e) {
   if (level>=10 & logging) logLine(23,new String[]{},10);
   if (level>=5 & logging) logLine(28,new String[]{"couldn't make new
transformer"},5);
}
if (level>=10 & logging) logLine(11,new String[]{},10);
* ----- *
| /CODE |
* ----- *

The first two logLines are logged, the third one (right after
TransformerFactory.newInstance()) isn't anymore. The program doesn't
quit, no exceptions are thrown.

On our developer machines this works without problems, when we install
our software on a clean, newly installed pc, it doesn't work.

I've tried adding the system value for
javax.xml.transform.TransformerFactory. I'm also sure the xalan.jar
(2.7.0) is on the classpath.

Anyone knows what to do now?

Thanks,
Brecht