Jon,
Verify if Account.xml is in correct format. It should contain

<!DOCTYPE mapper
        PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
        "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd";>

instead of

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

to begin with.

Regards.


On 17/03/2010 10:39, Jon Finanger wrote:
I'm evaluating the technology and have a "tricky" startup problem I'm not
able to "see" the solution for.
I get the:
Exception in thread "main" org.apache.ibatis.exceptions.IbatisException:
### Error building SqlSession.
### The error may exist in test/ibatis/Account.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL
Mapper Configuration.
Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause:
java.lang.NullPointerException
         at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory
.java:8)
         at
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBu
ilder.java:32)
         at
org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBu
ilder.java:15)


Well,
To start with I use the account table and account.java from the JPetshop
example as the base (with small mods).
Does it exists examplecode for ibatis 3?
My testclass is like this:

public class Test {
        public static void main(String[] args) {
                String resource = " test/ibatis/SqlMapperConfig.xml";
                Reader reader = null;
                try {
                        reader = Resources.getResourceAsReader(resource);
                } catch (IOException e) {}
                SqlSessionFactoryBuilder builder = new
SqlSessionFactoryBuilder();
                SqlSessionFactory factory = builder.build(reader);
                SqlSession session = factory.openSession();
                try {
                        Account account = new Account();
                        account.setAddress1("test address");
                        account.setCity("Trondheim");
                        account.setEmail("t...@test.no");
                        account.setFirstName("Jon");
                        account.setLastName("XYZ");
                        session.insert("insertAccount", account);
                        session.commit();

                } finally {
                        session.close();
                }

        }
}


Then I set up the sqlmapperconfig.xml file like this:
<?xml  version="1.0"  encoding="UTF-8"  ?>
<!DOCTYPE  configuration  PUBLIC
"-//ibatis.apache.org//DTD  Config  3.0//EN"
"http://ibatis.apache.org/dtd/ibatis-3-config.dtd";>
<configuration>
   <environments  default="development">
     <environment  id="development">
        ....
     </environment>
   </environments>
   <mappers>
     <mapper  resource=" test/ibatis/Account.xml"/>
   </mappers>
</configuration>

The account.xml is like this (2.0 way):

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

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

<sqlMap namespace="Account">

   <typeAlias type="tagsmart.test.ibatis.Account" alias="account" />

   <select id="getAccountByUsername" resultClass="account"
parameterClass="string">
     SELECT
           ACCOUNT.EMAIL,
           ACCOUNT.FIRSTNAME,
           ACCOUNT.LASTNAME,
           ACCOUNT.STATUS,
           ACCOUNT.ADDR1 AS address1,
           ACCOUNT.ADDR2 AS address2,
           ACCOUNT.CITY,
           ACCOUNT.STATE,
           ACCOUNT.ZIP,
           ACCOUNT.COUNTRY,
           ACCOUNT.PHONE,
     FROM ACCOUNT
     WHERE ACCOUNT.USERID = #username#
   </select>
.........
.......

</sqlMap>

I've tried to use the 3.0 descriptor, but it complains about sqlMap
declaration

Any ideas?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org

Reply via email to