views:

187

answers:

3

I have following in my applicaionContext.xml

<bean id="IbatisDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
    <property name="url" value="jdbc:oracle:thin:@123.210.85.56:1522:ORCL"/>
    <property name="username" value="mydb"/>
    <property name="password" value="mydbpwd"/>
</bean>


<bean id="myMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
  <property name="configLocation" value="classpath:sql-map-config-oracle.xml"/>
  <property name="dataSource" ref="IbatisDataSource"/>
 </bean>

then in my code I have:

ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
SqlMapClient sqlclient = (SqlMapClient) ctx.getBean("myMapClient");

doing this gives me the following error:

Error creating bean with name 'myMapClient' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: com/iplanet/ias/admin/common/ASException

I don't understand why is it looking for that class? I am trying to do everything outside the container. So it should not even be looking for that class...but nonetheless just to make it work I tried looking for class called ASException so I could put it on the classpath but no where can I find ASException class.

Any pointers?

Images of stack trace and my compile test / run test libs alt text alt text alt text

Edit Solution: Even though I thought everything was outside the container...there was ONE thing that was not outside the container.
Notice the property configLocation:

<property name="configLocation" value="classpath:sql-map-config-oracle.xml"/>

actual content of sql-map-config-oracle.xml is

<sqlMapConfig>
   <settings enhancementEnabled="true" useStatementNamespaces="true" />
    <transactionManager type="JDBC">
     <dataSource type="JNDI">
      <property name="DataSource" value="my/jndi/mydb" />
     </dataSource>
    </transactionManager>
<sqlMap resource="somemapping.xml"/>
</sqlMapConfig>

JNDI stuff does not need to be there!

sql-map-config-oracle.xml should simply be:

<sqlMapConfig>
   <settings enhancementEnabled="true" useStatementNamespaces="true" />
        <sqlMap resource="somemapping.xml"/>
</sqlMapConfig>
A: 

This class was found during compilation but not during running:

com/iplanet/ias/admin/common/ASException

So when you're running the program, it can't seem to find this class, which belongs to the Sun app or portal server that you're using. In short: it's a classpath error.

cletus
how are you sure that it was found in compiling?..error happens at initialization of the beans..which would not happen at compile time anyways right? ...even though i dont know which jar file it requires but I think the jar is missing from both compile and run classpaths..not just run (or we cant be sure)
Omnipresent
It's important to distinguish between ClassNotFoundException and ClassDefNotFoundError. The first occurs when, say, you attempt to instantiate a class by reflection and it can't be found. The second happens because some code was compiled against a class that is no longer there at runtime. That's what you have. So you'll probably find you're not including all the jars you need to. Like you're including one jar but not the jar that it is dependant on, etc.
cletus
+1  A: 

You definitely have a runtime dependency issue as @Cletus said org.springframework.orm.ibatis.SqlMapClientFactoryBean was compiled with com.iplanet.ias.admin.common.ASException but now you don't have it in your classpath -- Spring can't find it. You should Look at the source for SqlMapClientFactoryBean to see where ASException is called -- Spring should have a dist with all it's dependencies in it, you can also look in there when doing your investigation.

non sequitor
downloaded complete springframework with src. searched src folder for string 'AsException' in all the classes....found nada.
Omnipresent
So looking at this closely this has to be a container specific error *iplanet* is the Sun brand of servers etc (Glassfish etc). If you're testing this "out of container" like on a Tomcat instance in Netbeans it seems like you still have some container reference here. I think `ias` is iPlanet Application Server and you're getting an `ASException` Application Server Exception. I would create a new Netbeans project import ur code, the Spring iBatis dependencies and Spring of course (and its dependencies) and ur code dependencies not found in Spring's.
non sequitor
Well not getting an `ASEXception` but you know what I mean -- rather not getting :)
non sequitor
no i get what you mean ...basically start from scratch :) going to try that too now. ..might as well
Omnipresent
I got it working! instead of starting from scratch...tried 'thinking from scratch'. thanks for help
Omnipresent
A: 

Anyone with similar problem please see the edit in this question.

and also not to self: dont be dumb!

Omnipresent