Bug 252787 - SAXParseException: Premature end of file when using LTW
Summary: SAXParseException: Premature end of file when using LTW
Status: REOPENED
Alias: None
Product: AspectJ
Classification: Tools
Component: LTWeaving (show other bugs)
Version: 1.6.1   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 1.6.4   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-30 12:11 EDT by Wim Deblauwe CLA
Modified: 2009-07-07 11:08 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wim Deblauwe CLA 2008-10-30 12:11:57 EDT
When using LTW you can get this exception:

I am using LTW and I get this exception:

 [WebappClassLoader@1478a43] warning parse definitions failed -- (SAXParseException) Premature end of file.
[INFO] [talledLocalContainer] Premature end of file.
[INFO] [talledLocalContainer] org.xml.sax.SAXParseException: Premature end of file.
[INFO] [talledLocalContainer]     at org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1183)
[INFO] [talledLocalContainer]     at org.aspectj.weaver.loadtime.definition.DocumentParser.parse(DocumentParser.java:108)
[INFO] [talledLocalContainer]     at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.parseDefinitions(ClassLoaderWeavingAdaptor.java:211)
[INFO] [talledLocalContainer]     at org.aspectj.weaver.loadtime.DefaultWeavingContext.getDefinitions(DefaultWeavingContext.java:121)
[INFO] [talledLocalContainer]     at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize(ClassLoaderWeavingAdaptor.java:137)
[INFO] [talledLocalContainer]     at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.initialize(Aj.java:262)
[INFO] [talledLocalContainer]     at org.aspectj.weaver.loadtime.Aj$ExplicitlyInitializedClassLoaderWeavingAdaptor.

I was using this aop.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE aspectj PUBLIC
        "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">

<aspectj>

    <weaver options="-verbose -showWeaveInfo">
        <include within="com.mycomp.domain.message.event.hibernate.*"/>
    </weaver>
    <aspects>
        <aspect name="org.springframework.beans.factory.aspectj.AnnotationBeanConfigurerAspect"/>
        <aspect name="org.springframework.transaction.aspectj.AnnotationTransactionAspect"/>
    </aspects>
   
</aspectj>

The error went away with removing the xml declaration and the DTD declaration.
Comment 1 Andrew Clement CLA 2008-10-30 12:28:27 EDT
take a look for 1.6.3 - are we using the parser correctly?
Comment 2 Andrew Clement CLA 2009-01-21 13:50:25 EST
I can't recreate this - can you?  I am on Java6 (1.6.0_06-b02).  If I add those initial lines it works fine.  If I remove them it works fine.  if I add them and make a mistake in the DTD name, it fails as expected.

A google for the SAX problem indicates this can happen if there is a network issue preventing correct download of the DTD.  I wonder if this was happening at the time you were having the problem?  Can you just retry it now, or perhaps grab the DTD and put it in a local file then change the URL in the DOCTYPE element to point to the local version to see if it helps.
Comment 3 Andrew Clement CLA 2009-02-01 13:20:17 EST
closing as works for me - may have been an intermittent network glitch to the eclipse.org servers.  please reopen if still a problem.
Comment 4 Marius Petoi CLA 2009-05-12 03:22:59 EDT
This bug also appears for me. I use aspectj 1.6.2 and Java 1.6.10. Also tried it with aspectj 1.6.4 and with Java 1.6.13 and the same exception is thrown. If I try to take the file locally, I get the same exception.
Comment 5 Andrew Clement CLA 2009-05-12 12:31:13 EDT
Marius - you need to reopen it, not just cc on a closed bug :)

I'll reopen it.

I just tried again on 1.6.5 dev builds with java 1.6.0_13 and using the aop.xml file you sent me:
---
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE aspectj PUBLIC
        "-//AspectJ//DTD//EN" "http://www.eclipse.org/aspectj/dtd/aspectj.dtd">

<aspectj>
    <aspects>
        <aspect name="Aspect"/>
        <include within="package..*"/>
    </aspects>
</aspectj>
---

it worked just fine.  Do you *really* need to include the dtd reference in the xml file?
Comment 6 Natan Cox CLA 2009-07-07 06:33:38 EDT
I had a similar problem when having 2 aop.xml files in my project (a project with multiple subprojects in maven).

Moving all information into one aop.xml file fixed the problem for me.
Comment 7 Andrew Clement CLA 2009-07-07 11:08:37 EDT
Natan's comment is interesting.  In AspectJ 1.6.5 I fixed bug 274986.  That was where the caching of the DTD caused a problem if it was reused (by loading a second aop.xml file for example).  It might be that fix addresses this issue too.