You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by coolfire <Ma...@web.de> on 2007/07/24 11:43:17 UTC

jUnit test, NodeletException

Hi all,
i' trying to perform a simple JUnit Test, but without success.
I'm using Eclipse 3.2, iBatis 2.3.0, jre 1.5.0_09 and jUnit 4.3.1.
The error occurs in SqlMapClientBuilder.buildSqlMapClient(reader);

java.lang.RuntimeException: Error occurred. Cause:
com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:89)
at
com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
at
com.eternity.bugtracking.IBatisConnection.<clinit>(IBatisConnection.java:16)
at
com.eternity.bugtracking.src.business.persister.JUnitProjects.insertProject(JUnitProjects.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at
org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
at
org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at
org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
at
org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
at
org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
at
org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
at
org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
org.xml.sax.SAXParseException: Content is not allowed in prolog.
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
at
com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86)
... 23 more
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown
Source)
at
com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
Source)
at
com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
... 24 more

----------------------------------

here my SqlMap config file:

<?xml version = "1.0" encoding="UTF-16"?>

<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">



<!--DOCTYPE sqlMapConfig
SYSTEM "file:E:/Programmieren/Java/libraries/sql-map-config-2.dtd"-->



<!-- Always ensure to use the correct XML header as above! -->
<sqlMapConfig>
<!-- The properties (name=value) in the file specified here can be used
placeholders in this config
file (e.g. "${driver}". The file is usually relative to the classpath and is
optional. -->
<properties resource="com/eternity/bugtracking/SqlMapConfig.properties"/>
<!-- These settings control SqlMap configuration details, primarily to do
with transaction
management. They are all optional (see the Developer Guide for more). -->
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="32"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="false"
/>
<!-- Type aliases allow you to use a shorter name for long fully qualified
class names. -->
<typeAlias alias="projects"
type="com.eternity.bugtracking.src.business.bean.Projects"/>
<typeAlias alias="projectsModules"
type="com.eternity.bugtracking.src.business.bean.ProjectsModules"/>

<!-- Configure a datasource to use with this SQL Map using SimpleDataSource.
Notice the use of the properties from the above resource -->
<transactionManager type="JDBC" >
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="${driver}"/>
<property name="JDBC.ConnectionURL" value="${url}"/>
<property name="JDBC.Username" value="${username}"/>
<property name="JDBC.Password" value="${password}"/>
</dataSource>
</transactionManager>
<!-- Identify all SQL Map XML files to be loaded by this SQL map. Notice the
paths
are relative to the classpath. For now, we only have one... -->
<!--sqlMap
resource="com/eternity/bugtracking/src/business/persister/BugtrackingPersister.xml"
/-->
</sqlMapConfig>

thanks for your help
Marco

-- 
View this message in context: http://www.nabble.com/jUnit-test%2C-NodeletException-tf4134769.html#a11759754
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: jUnit test, NodeletException

Posted by Chris Lamey <cl...@localmatters.com>.
Great, good to hear!

Whenever I hit an xml problem, the first thing I do is run it through
xmllint.  I cut and paste your file into a new one called /tmp/x.xml

Then when I ran xmllint on it, I saw it:

dev02lt 01:59 PM > xmllint /tmp/x.xml
��<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE sqlMapConfig PUBLIC "-//ibatis.apache.org//DTD SQL Map Config
2.0//EN" "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>

<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
<property name="JDBC.ConnectionURL"
value="jdbc:mysql://87.xxx.xx.xxx:1111/mySchema"/>
<property name="JDBC.Username" value="xxx"/>
<property name="JDBC.Password" value="xxx"/>
</dataSource>
</transactionManager>

</sqlMapConfig>

Cheers,
Chris

On Tue, 2007-07-24 at 12:20 -0700, coolfire wrote:
> thanks chris!
> now it's working.
> I just put UTF-16 because i got following error in my xml-viewer:
> Character conversion error: "Malformed UTF-8 char -- is an XML encoding
> declaration missing?" (line number may be too low).	SqlMapConfig.xml
> I created now a new file and put all my staff into and then it worked with
> UTF-8.
> Maybe I got some UTF-16 characters by copying from a tutorial.
> BTW, how did you saw the BOM?
> 
> 
> 
> Chris Lamey wrote:
> > 
> > BTW, if you change the file's encoding from UTF-16 to UTF-8, you will
> > definitely need to get rid of the first two bytes.
> > 
> > On Tue, 2007-07-24 at 11:42 -0600, Chris Lamey wrote:
> >> Hello,
> >> 
> >> Is the file really UTF-16 and if so, is your jvm default encoding
> >> UTF-16?
> >> 
> >> I cut and paste your file into one on my filesystem and saw a BOM before
> >> the first line.  My guess is that the xml parser is choking on that.
> >> You either need to set your jvm default encoding correctly
> >> (-Dfile.encoding=UTF-16) so the jvm handles the BOM correctly or you
> >> need to change the encoding attribute in the file from UTF-16 to UTF-8.
> >> You could also try removing the first two bytes in the file, but then
> >> the file loses it's byte order marking.
> >> 
> >> Cheers,
> >> Chris
> >> 
> >> On Tue, 2007-07-24 at 10:14 -0700, coolfire wrote:
> >> > <?xml version="1.0" encoding="UTF-16" ?>
> >> > 
> >> > <!DOCTYPE sqlMapConfig
> >> > PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
> >> >         "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
> >> > 
> >> > 
> >> > 
> >> > <sqlMapConfig>
> >> > 
> >> >         <transactionManager type="JDBC">
> >> >                 <dataSource type="SIMPLE">
> >> >                         <property name="JDBC.Driver"
> >> > value="com.mysql.jdbc.Driver"/>
> >> >                         <property name="JDBC.ConnectionURL"
> >> > value="jdbc:mysql://87.xxx.xx.xxx:1111/mySchema"/>
> >> >                         <property name="JDBC.Username" value="xxx"/>
> >> >                         <property name="JDBC.Password" value="xxx"/>
> >> >                 </dataSource>
> >> >         </transactionManager>
> >> > 
> >> > </sqlMapConfig> 
> > 
> > 
> 

Re: jUnit test, NodeletException

Posted by coolfire <Ma...@web.de>.
thanks chris!
now it's working.
I just put UTF-16 because i got following error in my xml-viewer:
Character conversion error: "Malformed UTF-8 char -- is an XML encoding
declaration missing?" (line number may be too low).	SqlMapConfig.xml
I created now a new file and put all my staff into and then it worked with
UTF-8.
Maybe I got some UTF-16 characters by copying from a tutorial.
BTW, how did you saw the BOM?



Chris Lamey wrote:
> 
> BTW, if you change the file's encoding from UTF-16 to UTF-8, you will
> definitely need to get rid of the first two bytes.
> 
> On Tue, 2007-07-24 at 11:42 -0600, Chris Lamey wrote:
>> Hello,
>> 
>> Is the file really UTF-16 and if so, is your jvm default encoding
>> UTF-16?
>> 
>> I cut and paste your file into one on my filesystem and saw a BOM before
>> the first line.  My guess is that the xml parser is choking on that.
>> You either need to set your jvm default encoding correctly
>> (-Dfile.encoding=UTF-16) so the jvm handles the BOM correctly or you
>> need to change the encoding attribute in the file from UTF-16 to UTF-8.
>> You could also try removing the first two bytes in the file, but then
>> the file loses it's byte order marking.
>> 
>> Cheers,
>> Chris
>> 
>> On Tue, 2007-07-24 at 10:14 -0700, coolfire wrote:
>> > <?xml version="1.0" encoding="UTF-16" ?>
>> > 
>> > <!DOCTYPE sqlMapConfig
>> > PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
>> >         "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
>> > 
>> > 
>> > 
>> > <sqlMapConfig>
>> > 
>> >         <transactionManager type="JDBC">
>> >                 <dataSource type="SIMPLE">
>> >                         <property name="JDBC.Driver"
>> > value="com.mysql.jdbc.Driver"/>
>> >                         <property name="JDBC.ConnectionURL"
>> > value="jdbc:mysql://87.xxx.xx.xxx:1111/mySchema"/>
>> >                         <property name="JDBC.Username" value="xxx"/>
>> >                         <property name="JDBC.Password" value="xxx"/>
>> >                 </dataSource>
>> >         </transactionManager>
>> > 
>> > </sqlMapConfig> 
> 
> 

-- 
View this message in context: http://www.nabble.com/jUnit-test%2C-NodeletException-tf4134769.html#a11770055
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: jUnit test, NodeletException

Posted by Chris Lamey <cl...@localmatters.com>.
BTW, if you change the file's encoding from UTF-16 to UTF-8, you will
definitely need to get rid of the first two bytes.

On Tue, 2007-07-24 at 11:42 -0600, Chris Lamey wrote:
> Hello,
> 
> Is the file really UTF-16 and if so, is your jvm default encoding
> UTF-16?
> 
> I cut and paste your file into one on my filesystem and saw a BOM before
> the first line.  My guess is that the xml parser is choking on that.
> You either need to set your jvm default encoding correctly
> (-Dfile.encoding=UTF-16) so the jvm handles the BOM correctly or you
> need to change the encoding attribute in the file from UTF-16 to UTF-8.
> You could also try removing the first two bytes in the file, but then
> the file loses it's byte order marking.
> 
> Cheers,
> Chris
> 
> On Tue, 2007-07-24 at 10:14 -0700, coolfire wrote:
> > <?xml version="1.0" encoding="UTF-16" ?>
> > 
> > <!DOCTYPE sqlMapConfig
> > PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
> >         "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
> > 
> > 
> > 
> > <sqlMapConfig>
> > 
> >         <transactionManager type="JDBC">
> >                 <dataSource type="SIMPLE">
> >                         <property name="JDBC.Driver"
> > value="com.mysql.jdbc.Driver"/>
> >                         <property name="JDBC.ConnectionURL"
> > value="jdbc:mysql://87.xxx.xx.xxx:1111/mySchema"/>
> >                         <property name="JDBC.Username" value="xxx"/>
> >                         <property name="JDBC.Password" value="xxx"/>
> >                 </dataSource>
> >         </transactionManager>
> > 
> > </sqlMapConfig> 

Re: jUnit test, NodeletException

Posted by Chris Lamey <cl...@localmatters.com>.
Hello,

Is the file really UTF-16 and if so, is your jvm default encoding
UTF-16?

I cut and paste your file into one on my filesystem and saw a BOM before
the first line.  My guess is that the xml parser is choking on that.
You either need to set your jvm default encoding correctly
(-Dfile.encoding=UTF-16) so the jvm handles the BOM correctly or you
need to change the encoding attribute in the file from UTF-16 to UTF-8.
You could also try removing the first two bytes in the file, but then
the file loses it's byte order marking.

Cheers,
Chris

On Tue, 2007-07-24 at 10:14 -0700, coolfire wrote:
> <?xml version="1.0" encoding="UTF-16" ?>
> 
> <!DOCTYPE sqlMapConfig
> PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
>         "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
> 
> 
> 
> <sqlMapConfig>
> 
>         <transactionManager type="JDBC">
>                 <dataSource type="SIMPLE">
>                         <property name="JDBC.Driver"
> value="com.mysql.jdbc.Driver"/>
>                         <property name="JDBC.ConnectionURL"
> value="jdbc:mysql://87.xxx.xx.xxx:1111/mySchema"/>
>                         <property name="JDBC.Username" value="xxx"/>
>                         <property name="JDBC.Password" value="xxx"/>
>                 </dataSource>
>         </transactionManager>
> 
> </sqlMapConfig> 

Re: jUnit test, NodeletException

Posted by coolfire <Ma...@web.de>.
Ok, thanks. I changed the SqlMapConfig.xml to this:

<?xml version="1.0" encoding="UTF-16" ?>

<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
	"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">



<sqlMapConfig>

	<transactionManager type="JDBC">
		<dataSource type="SIMPLE">
			<property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
			<property name="JDBC.ConnectionURL"
value="jdbc:mysql://87.xxx.xx.xxx:1111/mySchema"/>
			<property name="JDBC.Username" value="xxx"/>
			<property name="JDBC.Password" value="xxx"/>
		</dataSource>
	</transactionManager>

</sqlMapConfig>

but I still get this error. 
Do you have further ideas?
Marco



Larry Meadors-2 wrote:
> 
> 9 times out of 10, that is due to weird errors in your XML file - line
> feeds, etc.
> 
> You can either start with a bare-bones file and build it back up, or
> trying to remove (by deleting content, not commenting it out) until it
> works, then add stuff back in until it either works, or you have
> isolated the issue. Comments will most likely just make more of a
> mess.
> 
> Larry
> 
> 
> On 7/24/07, coolfire <Ma...@web.de> wrote:
>>
>> Hi all,
>> i' trying to perform a simple JUnit Test, but without success.
>> I'm using Eclipse 3.2, iBatis 2.3.0, jre 1.5.0_09 and jUnit 4.3.1.
>> The error occurs in SqlMapClientBuilder.buildSqlMapClient(reader);
>>
>> java.lang.RuntimeException: Error occurred. Cause:
>> com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
>> org.xml.sax.SAXParseException: Content is not allowed in prolog.
>> at
>> com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:89)
>> at
>> com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
>> at
>> com.eternity.bugtracking.IBatisConnection.<clinit>(IBatisConnection.java:16)
>> at
>> com.eternity.bugtracking.src.business.persister.JUnitProjects.insertProject(JUnitProjects.java:17)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> at java.lang.reflect.Method.invoke(Unknown Source)
>> at
>> org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
>> at
>> org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
>> at
>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
>> at
>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
>> at
>> org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
>> at
>> org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
>> at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>> Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.
>> Cause:
>> org.xml.sax.SAXParseException: Content is not allowed in prolog.
>> at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
>> at
>> com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86)
>> ... 23 more
>> Caused by: org.xml.sax.SAXParseException: Content is not allowed in
>> prolog.
>> at
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
>> Source)
>> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
>> Source)
>> at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
>> Source)
>> at
>> com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
>> at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
>> ... 24 more
>>
>> ----------------------------------
>>
>> here my SqlMap config file:
>>
>> <?xml version = "1.0" encoding="UTF-16"?>
>>
>> <!DOCTYPE sqlMapConfig
>> PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
>> "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
>>
>>
>>
>> <!--DOCTYPE sqlMapConfig
>> SYSTEM "file:E:/Programmieren/Java/libraries/sql-map-config-2.dtd"-->
>>
>>
>>
>> <!-- Always ensure to use the correct XML header as above! -->
>> <sqlMapConfig>
>> <!-- The properties (name=value) in the file specified here can be used
>> placeholders in this config
>> file (e.g. "${driver}". The file is usually relative to the classpath and
>> is
>> optional. -->
>> <properties resource="com/eternity/bugtracking/SqlMapConfig.properties"/>
>> <!-- These settings control SqlMap configuration details, primarily to do
>> with transaction
>> management. They are all optional (see the Developer Guide for more). -->
>> <settings
>> cacheModelsEnabled="true"
>> enhancementEnabled="true"
>> lazyLoadingEnabled="true"
>> maxRequests="32"
>> maxSessions="10"
>> maxTransactions="5"
>> useStatementNamespaces="false"
>> />
>> <!-- Type aliases allow you to use a shorter name for long fully
>> qualified
>> class names. -->
>> <typeAlias alias="projects"
>> type="com.eternity.bugtracking.src.business.bean.Projects"/>
>> <typeAlias alias="projectsModules"
>> type="com.eternity.bugtracking.src.business.bean.ProjectsModules"/>
>>
>> <!-- Configure a datasource to use with this SQL Map using
>> SimpleDataSource.
>> Notice the use of the properties from the above resource -->
>> <transactionManager type="JDBC" >
>> <dataSource type="SIMPLE">
>> <property name="JDBC.Driver" value="${driver}"/>
>> <property name="JDBC.ConnectionURL" value="${url}"/>
>> <property name="JDBC.Username" value="${username}"/>
>> <property name="JDBC.Password" value="${password}"/>
>> </dataSource>
>> </transactionManager>
>> <!-- Identify all SQL Map XML files to be loaded by this SQL map. Notice
>> the
>> paths
>> are relative to the classpath. For now, we only have one... -->
>> <!--sqlMap
>> resource="com/eternity/bugtracking/src/business/persister/BugtrackingPersister.xml"
>> /-->
>> </sqlMapConfig>
>>
>> thanks for your help
>> Marco
>>
>> --
>> View this message in context:
>> http://www.nabble.com/jUnit-test%2C-NodeletException-tf4134769.html#a11759754
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/jUnit-test%2C-NodeletException-tf4134769.html#a11767145
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: jUnit test, NodeletException

Posted by coolfire <Ma...@web.de>.
Ok, thanks. I changed the SqlMapConfig.xml to this:

<?xml version="1.0" encoding="UTF-16" ?>

<!DOCTYPE sqlMapConfig
PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
	"http://ibatis.apache.org/dtd/sql-map-config-2.dtd">



<sqlMapConfig>

	<transactionManager type="JDBC">
		<dataSource type="SIMPLE">
			<property name="JDBC.Driver" value="com.mysql.jdbc.Driver"/>
			<property name="JDBC.ConnectionURL"
value="jdbc:mysql://87.xxx.xx.xxx:1111/mySchema"/>
			<property name="JDBC.Username" value="xxx"/>
			<property name="JDBC.Password" value="xxx"/>
		</dataSource>
	</transactionManager>

</sqlMapConfig>

but I still get this error. 
Do you have further ideas?
Can you publish a SqlMapConfig.xml which works?
I only have the ibatis-2.3.0.677.jar in my build path. 
Is a jar missing?
Marco



Larry Meadors-2 wrote:
> 
> 9 times out of 10, that is due to weird errors in your XML file - line
> feeds, etc.
> 
> You can either start with a bare-bones file and build it back up, or
> trying to remove (by deleting content, not commenting it out) until it
> works, then add stuff back in until it either works, or you have
> isolated the issue. Comments will most likely just make more of a
> mess.
> 
> Larry
> 
> 
> On 7/24/07, coolfire <Ma...@web.de> wrote:
>>
>> Hi all,
>> i' trying to perform a simple JUnit Test, but without success.
>> I'm using Eclipse 3.2, iBatis 2.3.0, jre 1.5.0_09 and jUnit 4.3.1.
>> The error occurs in SqlMapClientBuilder.buildSqlMapClient(reader);
>>
>> java.lang.RuntimeException: Error occurred. Cause:
>> com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
>> org.xml.sax.SAXParseException: Content is not allowed in prolog.
>> at
>> com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:89)
>> at
>> com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
>> at
>> com.eternity.bugtracking.IBatisConnection.<clinit>(IBatisConnection.java:16)
>> at
>> com.eternity.bugtracking.src.business.persister.JUnitProjects.insertProject(JUnitProjects.java:17)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>> at java.lang.reflect.Method.invoke(Unknown Source)
>> at
>> org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
>> at
>> org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
>> at
>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
>> at
>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
>> at
>> org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
>> at
>> org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
>> at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
>> at
>> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
>> Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML.
>> Cause:
>> org.xml.sax.SAXParseException: Content is not allowed in prolog.
>> at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
>> at
>> com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86)
>> ... 23 more
>> Caused by: org.xml.sax.SAXParseException: Content is not allowed in
>> prolog.
>> at
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
>> Source)
>> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
>> Source)
>> at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
>> Source)
>> at
>> com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
>> at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
>> ... 24 more
>>
>> ----------------------------------
>>
>> here my SqlMap config file:
>>
>> <?xml version = "1.0" encoding="UTF-16"?>
>>
>> <!DOCTYPE sqlMapConfig
>> PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
>> "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
>>
>>
>>
>> <!--DOCTYPE sqlMapConfig
>> SYSTEM "file:E:/Programmieren/Java/libraries/sql-map-config-2.dtd"-->
>>
>>
>>
>> <!-- Always ensure to use the correct XML header as above! -->
>> <sqlMapConfig>
>> <!-- The properties (name=value) in the file specified here can be used
>> placeholders in this config
>> file (e.g. "${driver}". The file is usually relative to the classpath and
>> is
>> optional. -->
>> <properties resource="com/eternity/bugtracking/SqlMapConfig.properties"/>
>> <!-- These settings control SqlMap configuration details, primarily to do
>> with transaction
>> management. They are all optional (see the Developer Guide for more). -->
>> <settings
>> cacheModelsEnabled="true"
>> enhancementEnabled="true"
>> lazyLoadingEnabled="true"
>> maxRequests="32"
>> maxSessions="10"
>> maxTransactions="5"
>> useStatementNamespaces="false"
>> />
>> <!-- Type aliases allow you to use a shorter name for long fully
>> qualified
>> class names. -->
>> <typeAlias alias="projects"
>> type="com.eternity.bugtracking.src.business.bean.Projects"/>
>> <typeAlias alias="projectsModules"
>> type="com.eternity.bugtracking.src.business.bean.ProjectsModules"/>
>>
>> <!-- Configure a datasource to use with this SQL Map using
>> SimpleDataSource.
>> Notice the use of the properties from the above resource -->
>> <transactionManager type="JDBC" >
>> <dataSource type="SIMPLE">
>> <property name="JDBC.Driver" value="${driver}"/>
>> <property name="JDBC.ConnectionURL" value="${url}"/>
>> <property name="JDBC.Username" value="${username}"/>
>> <property name="JDBC.Password" value="${password}"/>
>> </dataSource>
>> </transactionManager>
>> <!-- Identify all SQL Map XML files to be loaded by this SQL map. Notice
>> the
>> paths
>> are relative to the classpath. For now, we only have one... -->
>> <!--sqlMap
>> resource="com/eternity/bugtracking/src/business/persister/BugtrackingPersister.xml"
>> /-->
>> </sqlMapConfig>
>>
>> thanks for your help
>> Marco
>>
>> --
>> View this message in context:
>> http://www.nabble.com/jUnit-test%2C-NodeletException-tf4134769.html#a11759754
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/jUnit-test%2C-NodeletException-tf4134769.html#a11767145
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.


Re: jUnit test, NodeletException

Posted by Larry Meadors <lm...@apache.org>.
9 times out of 10, that is due to weird errors in your XML file - line
feeds, etc.

You can either start with a bare-bones file and build it back up, or
trying to remove (by deleting content, not commenting it out) until it
works, then add stuff back in until it either works, or you have
isolated the issue. Comments will most likely just make more of a
mess.

Larry


On 7/24/07, coolfire <Ma...@web.de> wrote:
>
> Hi all,
> i' trying to perform a simple JUnit Test, but without success.
> I'm using Eclipse 3.2, iBatis 2.3.0, jre 1.5.0_09 and jUnit 4.3.1.
> The error occurs in SqlMapClientBuilder.buildSqlMapClient(reader);
>
> java.lang.RuntimeException: Error occurred. Cause:
> com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
> org.xml.sax.SAXParseException: Content is not allowed in prolog.
> at
> com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:89)
> at
> com.ibatis.sqlmap.client.SqlMapClientBuilder.buildSqlMapClient(SqlMapClientBuilder.java:63)
> at
> com.eternity.bugtracking.IBatisConnection.<clinit>(IBatisConnection.java:16)
> at
> com.eternity.bugtracking.src.business.persister.JUnitProjects.insertProject(JUnitProjects.java:17)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at
> org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
> at
> org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
> at
> org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
> at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
> at
> org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)
> at
> org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
> at
> org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
> at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> Caused by: com.ibatis.common.xml.NodeletException: Error parsing XML. Cause:
> org.xml.sax.SAXParseException: Content is not allowed in prolog.
> at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:53)
> at
> com.ibatis.sqlmap.engine.builder.xml.SqlMapConfigParser.parse(SqlMapConfigParser.java:86)
> ... 23 more
> Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
> at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown
> Source)
> at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown
> Source)
> at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown
> Source)
> at
> com.ibatis.common.xml.NodeletParser.createDocument(NodeletParser.java:157)
> at com.ibatis.common.xml.NodeletParser.parse(NodeletParser.java:50)
> ... 24 more
>
> ----------------------------------
>
> here my SqlMap config file:
>
> <?xml version = "1.0" encoding="UTF-16"?>
>
> <!DOCTYPE sqlMapConfig
> PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"
> "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
>
>
>
> <!--DOCTYPE sqlMapConfig
> SYSTEM "file:E:/Programmieren/Java/libraries/sql-map-config-2.dtd"-->
>
>
>
> <!-- Always ensure to use the correct XML header as above! -->
> <sqlMapConfig>
> <!-- The properties (name=value) in the file specified here can be used
> placeholders in this config
> file (e.g. "${driver}". The file is usually relative to the classpath and is
> optional. -->
> <properties resource="com/eternity/bugtracking/SqlMapConfig.properties"/>
> <!-- These settings control SqlMap configuration details, primarily to do
> with transaction
> management. They are all optional (see the Developer Guide for more). -->
> <settings
> cacheModelsEnabled="true"
> enhancementEnabled="true"
> lazyLoadingEnabled="true"
> maxRequests="32"
> maxSessions="10"
> maxTransactions="5"
> useStatementNamespaces="false"
> />
> <!-- Type aliases allow you to use a shorter name for long fully qualified
> class names. -->
> <typeAlias alias="projects"
> type="com.eternity.bugtracking.src.business.bean.Projects"/>
> <typeAlias alias="projectsModules"
> type="com.eternity.bugtracking.src.business.bean.ProjectsModules"/>
>
> <!-- Configure a datasource to use with this SQL Map using SimpleDataSource.
> Notice the use of the properties from the above resource -->
> <transactionManager type="JDBC" >
> <dataSource type="SIMPLE">
> <property name="JDBC.Driver" value="${driver}"/>
> <property name="JDBC.ConnectionURL" value="${url}"/>
> <property name="JDBC.Username" value="${username}"/>
> <property name="JDBC.Password" value="${password}"/>
> </dataSource>
> </transactionManager>
> <!-- Identify all SQL Map XML files to be loaded by this SQL map. Notice the
> paths
> are relative to the classpath. For now, we only have one... -->
> <!--sqlMap
> resource="com/eternity/bugtracking/src/business/persister/BugtrackingPersister.xml"
> /-->
> </sqlMapConfig>
>
> thanks for your help
> Marco
>
> --
> View this message in context: http://www.nabble.com/jUnit-test%2C-NodeletException-tf4134769.html#a11759754
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>