tomcat 위에서 library를 load하기 Java


servlet 을 만들 때, library를 maven에 넣는 것으로는 컴파일까지는 잘 되지만,
tomcat 위에서 실행할 때, ClassNotFoundException 이 난다.


말대로 jar파일을 /WEB-INF/lib 안에 넣기.

maven도 같이 작동하게 하려면

우선은 pom.xml 안에 

<dependency>

...

<scope>system</scope>

<systemPath>${basedir}/web/WEB-INF/lib/...

와 같이 경로를 적었다. 

이런 거 하지 말라고 하던뎅..




이어지는 내용

junit에서 byte array 비교하기

framework.Assert 말고,
org.junit.Assert
를 써야 assertArrayEquals를 쓸 수 있다.

http://www.junit.org/junit/javadoc/4.3/org/junit/Assert.html#assertArrayEquals(byte[], byte[])


List element에 interface를 넣었더니, 불편해 Java




public interface IA {
}

public class CA implements IA {
}

List<IA> iList = new ArrayList<IA>();
List<CA> cList = new ArrayList<CA>();

IA ia = new CA(); // 이건 되지
CA ca = new CA();

iList.add(ia); // 이것도 되겠지
iList.add(ca); // 이것도 됐던 것 같다.

iList = cList; // 근데, 이게 안돼 -_-;;
어찌까잉.



Msgpack serialization, deserialization Computers

serialization할 때는 outputstream 이 생기고,
deserialization할 때는 InputStream 이 input이 된다.
그런데, output stream --> input stream 의 경우,

ByteArrayInputStream bai2 = newByteArrayInputStream(outputStream.toString().getBytes("UTF-8"));

 

outputStream에서 위와 같이 toString을 쓰면안된다

stream 안의 내용들이 망가진다.

string으로 출력해봐도 알 수 있다.

 

 

outputStream = newByteArrayOutputStream();

ByteArrayInputStream bais = new ByteArrayInputStream(outputStream.toByteArray());

 

와 같이 toByteArray 로 바꿔야 손실이없다.

servlet, client 간 통신을 할 때도 저 과정이 있는데, 내가 손을 대는 부분이 아니잖아..
어쩌지.

 

Servlet 에서

protected voiddoPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException {

ServletOutputStream outputStream =res.getOutputStream();

d1.setOutputStream(outputStream);

 

Client에서 쓰는 inputstream

 

InputStream org.apache.commons.httpclient.HttpMethodBase.getResponseBodyAsStream()throws IOException

 

d2.setInputStream(inputStream);

 


안에 어떤 내용들이 들어가는지 보려면, FilterOutputStream 을 Decorator로 중간에 끼워 넣는다.


http://devday.tistory.com/entry/OutputStream을-String으로-출력하기



http://www.java2s.com/Code/Java/Development-Class/TraceInputStream.htm

http://www.java2s.com/Code/Java/Development-Class/TraceOutputStream.htm





이전 tomcat이 port 점유 Mac



나는
mac에서 ps도 제대로 못하고,
tomcat을 어디 설치했었는지도 잘 기억 못해서

한심하게 그냥 재부팅하네.

$ ps -elf | grep tomcat
하면 된다.

1 2 3 4 5 6 7 8 9 10 다음


메모장 실험

메모장도 로그가 남나 실험