개발시에 많이 겪는 문제 일수 있다. 

멋쟁이 아틀라시안의 정보를 참조함.

https://confluence.atlassian.com/display/STASHKB/Login+and+session+conflicts+with+multiple+Atlassian+applications

증상

같은 어플리케이션을 설정을 달리하여 2개를 구동하였다.

ex) http://localhost:8080 and http://localhost:8090

1번재 서버에서 로그인후 2번째 서버에 로그인을 하면 타이머로 ajax를 통해 서버가 호출 된다면

2군데 페이지에서 세션이 바뀌고 로그인이 팅길수 있다.


이유 

java 웹 어플리케이션은 세션아이디를  브라우저 쿠키에 저장한다.  

이 쿠키는 도메인 과 컨텍스트 별로 관리되지만 port 는 무시한다.

그래서 1번 어플리케이션과 2번 어플리케이션 간의 세션 정보를 덮어 쓸수 있다.


해결방법

1. 도메인을 다르게 하거나 다른 context path로 설정. (귀찮음)

2. 각각 어플리케이션을 서로 다른 브라우저로 사용한다. 1은 크롬 2번은 파폭


[JETTY 에서만 확인해 봄 톰캣에서도 발생한다고 함.]




Posted by 마법수정화살
,

maven-surefire가 안본사이 버전업이 많이 되었다. 

  1. The test-classes directory
  2. The classes directory
  3. The project dependencies
  4. Additional classpath elements
surefire가 참조하는 classpath 순서이다. 

surefire가 동작 할때 target/surefire 안에 tmp 블라블라  파일이 2개가 생기는데
그중에 classpath가 정리되어있는 파일이 있다. surefire가 동작할때 이 파일을 매개변수로 받는다.
** 빌드가 완료되면 삭제되므로 주의.

우리는 살다보면 jar를  loading 해서 jar안에 resource 파일에 접근하려는 실수를 하게 된다.
open소스가 file경로를 요구하면 답이 없다..

그럴땐 surefire와 maven-dependency-plugin 의 콜라보로 surefire에서 classes classpath로 참조하게 할수 있다.

http://maven.apache.org/surefire/maven-surefire-plugin/examples/configuring-classpath.html

<plugin>

<artifactId>maven-surefire-plugin</artifactId>

<version>2.17</version>

<configuration>

        <systemProperties>

          <property>

            <name>build.db</name>

            <value>${build.db}</value>

          </property>

        </systemProperties>

<useSystemClassLoader>true</useSystemClassLoader>

<argLine>-Xms256m -Xmx512m -XX:MaxPermSize=128m -Dfile.encoding=UTF-8</argLine>

<includes>

<include>**/AllTests.java</include> <!-- AllTest.java -->

</includes>

<properties>

<property>

<name>listener</name>

<value>spectra.ee.test.MyRunListener</value>

</property>

</properties>

        <additionalClasspathElements>

            <additionalClasspathElement>${basedir}classes경로</additionalClasspathElement>

        </additionalClasspathElements>

        <classpathDependencyExcludes>

            <classpathDependencyExcludes>class디펜던시</classpathDependencyExcludes>

        </classpathDependencyExcludes>

</configuration>

jar 디펜던시를 제거하고 classes 디렉토리를 추가하는 방법.

Posted by 마법수정화살
,

[JAVA] sealing violation

JAVA 2014. 4. 17. 20:25

JAR를 패킹 할때 선택적으로 sealed 여부를 정할 수 있다.

클래스들 사이에 버전 일관성을 보장한다고 하는데 맘에 안든다. 이유는 아래.


http://docs.oracle.com/javase/tutorial/deployment/jar/sealman.html

jar를 까서 manifest 파일을 보면 아래 설정 값이 있다.

Sealed: true


사용할때. 같은 A 클래스를 A.jar에서 로딩하고 다시 B.jar에서 같은 A클래스를 로딩하려고 하면 

sealing violation 이 발생한다. 


대표적인 것이 ojdbc 등 jdbc 드라이버 류 인데 maven-surefire 에서 수행된 후 embed was를 구동해서 테스트 하려고 하면 sealing violation 과 함께 에러 작렬

순서를 바꾸면 먼저하는 놈은 성공한다. 

ANT, application, WAS 에서 쓰려고 하니 난리가 난적이 있다. 


그래서 maven에서  dependency를 아예 제거한 후 Thread.currentThread().getContextClassLoader() 를 저장해 놓고 대충 아래와 같이 jdbc 드라이버를 로딩한다. 다 끝나면 저장되있던 원래 classloader로 세팅하여 깨끗하게 만든다. 

            URL[] urls = { 

                           new java.io.File(OJDBC6).toURI().toURL()};

            URLClassLoader urlCL = new URLClassLoader(urls, contextCL);

            Thread.currentThread().setContextClassLoader(urlCL);

귀찮으면 먼저 로딩된 jar를 나중에 사용하는 것들이 사용하도록 classpath를 적절하게 사용한다.

끝.



Posted by 마법수정화살
,