retry-policy가 존재하면, 반드시 retry-limit이 존재해야 한다.
항상 이 짝을 생각하자!!

retry-policy="retryPolicy" retry-limit="3"

(설정) 


<chunk reader="reader" processor="processor" writer="writer"   commit-interval="5" retry-limit="3" skip-limit="3" > 
<retryable-exception-classes>
         <include class="org.springframework.dao.DeadlockLoserDataAccessException"/>
         <include class="org.springframework.dao.DataAccessResourceFailureException"/>
        </retryable-exception-classes>
.....


다음과 같은 exception이 발생된다.
org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'step1': FactoryBean threw exception on object creation; nested e
xception is java.lang.IllegalArgumentException: The field 'retryable-exception-c
lasses' is not permitted on the step [step1] because there is no 'retry-limit'.
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveInnerBean(BeanDefinitionValueResolver.java:281)
        at org.springframework.beans.factory.support.BeanDefinitionValueResolver
.resolveValueIfNecessary(BeanDefinitionValueResolver.java:125)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1317)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.populateBean(AbstractAutowireCapableBeanFactory.java:1076)

 

Posted by '김용환'
,


ORA 08177 Exception이 발생했다.
여러 jvm에서 동시에 spring batch job를 실행하고 하나의 job repository를 사용하는 곳에 문제가 발생될 수 있다.


2011-02-25 11:19:25,927 ERROR [org.springframework.batch.core.launch.support.CommandLineJobRunner] - <Job Terminated in error: PreparedStatementCallback; SQL [INSERT INTO BATCH_JOB_EXECUTION_CONTEXT (SHORT_CONTEXT, SERIALIZED_CONTEXT, JOB_EXECUTION_ID) VALUES(?, ?, ?)]; ORA-08177: 이 트랜잭션에 대한 직렬화 액세스를 할 수 없습니다
; nested exception is java.sql.SQLException: ORA-08177: 이 트랜잭션에 대한 직렬화 액세스를 할 수 없습니다

또는

ORA-08177: can't serialize access for this transaction

transactionManager의 IsolationLevelForCreate 속성은 따로 지정하지 않을 경우 디폴트 값인 ISOLATION_SERIALIZABLE으로 설정된다.

<job-repository id="jobRepository"
    dataSource="dataSource"
    transactionManager="transactionManager"
    isolation-level-for-create="SERIALIZABLE"
    table-prefix="BATCH_"
/>

오라클 DB를 경우는 isolation-level-for-create="DEFAULT" 로 해줘야 해당 exception이 발견되지 않는다.

<job-repository id="jobRepository"
    dataSource="dataSource"
    transactionManager="transactionManager"
    isolation-level-for-create="DEFAULT"
    table-prefix="BATCH_"
/>


http://forum.springsource.org/showthread.php?t=61948&highlight=ORA-08177

" multiple spring batch processes were starting simultaneously as separate jobs via a cron schedule.
This was resulting in frequent "ORA-08177: can't serialize access for this transaction" errors.

http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/consist.htm#sthref1981
위의 링크중 오라클쭝 링크의 내용을 보면 다음과 같다.

Oracle generates an error when a serializable transaction tries to update or delete data modified by a transaction that commits after the serializable transaction began:

ORA-08177: Cannot serialize access for this transaction 

When a serializable transaction fails with the Cannot serialize access error, the application can take any of several actions:

  • Commit the work executed to that point

  • Execute additional (but different) statements (perhaps after rolling back to a savepoint established earlier in the transaction)

  • Undo the entire transaction

Figure 13-2 shows an example of an application that rolls back and retries the transaction after it fails with the Cannot serialize access error:

Figure 13-2 Serializable Transaction Failure

Description of Figure 13-2 follows



Posted by '김용환'
,
Posted by '김용환'
,

Lombok(http://projectlombok.org)
http://www.ibm.com/developerworks/kr/library/os-lombok/index.html

이거 함 써보자.. 완젼 귀찮아..

@Data
public class Person  {

   private Long personId;
  
   private String salutation;
   private String firstName;
   private String middleName;
   private String lastName;
  
   private String phoneNumber;
   private String email;
   private String addressLine1;
   private String addressLine2;
   private String city;
   private String state;
   private String country;
  
   private Calendar birthDate;
  
}

=>

 


인터뷰 이야기
http://java.dzone.com/interview-lombok
Posted by '김용환'
,

Eclipse의 java build에서 Error가 발생.

Referenced file contains errors (http://www.iBATIS.com/dtd/sql-map-config-2.dtd). For more information, right click on the message in the Problems View and select "Show Details..."

http://www.ibatis.com/ 을 http://ibatis.apache.com/ 으로 바꿔보자..
문제 해결~

헐~
Posted by '김용환'
,

Junit 오해

general java 2010. 8. 20. 11:51

Junit 에서 @Test 코드 실행시 코드상에서 순차적으로 실행되는 것으로 생각되는 분들이 많은데.
사실은.. 순서를 보장하지 않는다.
참고 내용
http://junit.sourceforge.net/doc/faq/faq.htm

    package junitfaq;

    import org.junit.*;
    import static org.junit.Assert.*;
    import java.util.*;

    public class SimpleTest {

        private Collection<Object> collection;

        @Before
        public void setUp() {
            collection = new ArrayList<Object>();
        }

        @Test
        public void testEmptyCollection() {
            assertTrue(collection.isEmpty());
        }


        @Test
        public void testOneItemCollection() {
            collection.add("itemA");
            assertEquals(1, collection.size());
        }
    }
      

Given this test, the methods might execute in the following order:

setUp()
testEmptyCollection()
setUp()
testOneItemCollection()

The ordering of test-method invocations is not guaranteed, so testOneItemCollection() might be executed before testEmptyCollection(). But it doesn't matter, because each method gets its own instance of the collection.

Posted by '김용환'
,
Posted by '김용환'
,

jdbc에서 지원이 안되니. dbcp단에서 지원할 수 있도록 property를 추가해야 함..
                <property name="poolPreparedStatements" value="true"/>
         <property name="maxOpenPreparedStatements" value="300"/>

'general java' 카테고리의 다른 글

Junit 오해  (0) 2010.08.20
JDK Dynamic Proxy와 CGLIB Proxy에 대한 이해  (0) 2010.07.15
DBCP 기본 정보  (0) 2010.07.07
한 때를 풍미했던 Jikes Compiler  (0) 2010.06.11
Java를 리눅스의 service 로 사용하기  (0) 2010.05.26
Posted by '김용환'
,

DBCP 기본 정보

general java 2010. 7. 7. 14:57

잘 알아두면 좋은 것들..

http://commons.apache.org/dbcp/apidocs/org/apache/commons/dbcp/BasicDataSource.html

protected  boolean closed 
           
protected  List connectionInitSqls 
          These SQL statements run once after a Connection is created.
protected  GenericObjectPool connectionPool 
          The object pool that internally manages our connections.
protected  Properties connectionProperties 
          The connection properties that will be sent to our JDBC driver when establishing new connections.
protected  DataSource dataSource 
          The data source we will use to manage connections.
protected  boolean defaultAutoCommit 
          The default auto-commit state of connections created by this pool.
protected  String defaultCatalog 
          The default "catalog" of connections created by this pool.
protected  Boolean defaultReadOnly 
          The default read-only state of connections created by this pool.
protected  int defaultTransactionIsolation 
          The default TransactionIsolation state of connections created by this pool.
protected  ClassLoader driverClassLoader 
          The class loader instance to use to load the JDBC driver.
protected  String driverClassName 
          The fully qualified Java class name of the JDBC driver to be used.
protected  int initialSize 
          The initial number of connections that are created when the pool is started.
protected  PrintWriter logWriter 
          The PrintWriter to which log messages should be directed.
protected  int maxActive 
          The maximum number of active connections that can be allocated from this pool at the same time, or negative for no limit.
protected  int maxIdle 
          The maximum number of connections that can remain idle in the pool, without extra ones being released, or negative for no limit.
protected  int maxOpenPreparedStatements 
          The maximum number of open statements that can be allocated from the statement pool at the same time, or non-positive for no limit.
protected  long maxWait 
          The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception, or <= 0 to wait indefinitely.
protected  long minEvictableIdleTimeMillis 
          The minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).
protected  int minIdle 
          The minimum number of active connections that can remain idle in the pool, without extra ones being created, or 0 to create none.
protected  int numTestsPerEvictionRun 
          The number of objects to examine during each run of the idle object evictor thread (if any).
protected  String password 
          The connection password to be passed to our JDBC driver to establish a connection.
protected  boolean poolPreparedStatements 
          Prepared statement pooling for this pool.
protected  boolean testOnBorrow 
          The indication of whether objects will be validated before being borrowed from the pool.
protected  boolean testOnReturn 
          The indication of whether objects will be validated before being returned to the pool.
protected  boolean testWhileIdle 
          The indication of whether objects will be validated by the idle object evictor (if any).
protected  long timeBetweenEvictionRunsMillis 
          The number of milliseconds to sleep between runs of the idle object evictor thread.
protected  String url 
          The connection URL to be passed to our JDBC driver to establish a connection.
protected  String username 
          The connection username to be passed to our JDBC driver to establish a connection.
protected  String validationQuery 
          The SQL query that will be used to validate connections from this pool before returning them to the caller.
protected  int validationQueryTimeout 
          Timeout in seconds before connection validation queries fail.

Posted by '김용환'
,

더이상 jdk 6을 지원하지 않고, jdk 5까지만 지원한다.. 
iBM에 만들어졌전 java compiler, 한 때는 sun의 것보다 빨라서 예전 회사에서 쓰기도 했었다..

이젠 빠이빠이

http://en.wikipedia.org/wiki/Jikes
http://sourceforge.net/project/shownotes.php?release_id=306072
Posted by '김용환'
,