반응형

OS: Ubuntu 14.04 LTS (amd64)


우분투(Ubuntu)에서 그냥 apt-get install로 gradle을 설치했더니 1.4가 설치되었다.


그런데 Spring REST 서버 코드를 빌드하는 과정에서 에러가 발생했는데 살펴보니 gradle-2.9 이상을 쓰라는 것이었다.


사실 그냥 gradle 공식 사이트 [1]에서 직접 받아서 설치해도 문제는 없다.

하지만 apt-get을 통해서 높은 버전 (또는 비교적 최신 버전)을 설치하고 싶을 경우에는 ppa를 통해 최신 gradle을 받을 수있는 repository를 등록해서 해결할 수 있다. [1]


$ sudo add-apt-repository ppa:cwchien/gradle

$ sudo apt-get update


$ sudo apt-get install gradle-3 <-- 여기까지 입력하고 탭(Tab) 키를 연타해서 설치할 수 있는 버전을 찾아서 설치하면 된다.




<참고자료>

[1] https://gradle.org/gradle-download/

[2] Upgrading Gradle to the latest version on Ubuntu, http://wtanaka.com/node/8079

반응형
블로그 이미지

Bryan_

,
반응형

OS: Ubuntu 14.04.2 LTS (amd64)

Type: Eclipse C/C++ Developer, version: Mars.1



이클립스 CDT에 플러그인 설치를 하다가 오류가 나고 매우 느려져서 강제종료를 했더니, 그 후로 이클립스가 시작이 되지 않았다. 더 자세하게 살펴보면, 이클립스가 시작은 되는데 workspace 를 로드하는 과정에서 에러를 겪으면서 종료된다. 에러 메세지는 다음과 같다:

An error has occurred. See the log file

이클립스의 workspace 디렉토리 위치/.metadata/.log.


즉, 새로운 workspace를 만들어서 실행할 수는 있지만 그러면 기존 프로젝트들을 다시 로드하는 것이 귀찮으므로 가급적이면 기존 workspace를 살리는 방법을 찾아야 한다.


여러가지 해결 방법이 있는데, 가장 먼저 이클립스의 workspace 디렉토리 위치/.metadata/.plugins/org.eclipse.core.resources 디렉토리에 있는 .snap 파일을 모두 지우는 것(예: 50.snap)이다.

아쉽게도 나는 이렇게 해도 같은 에러가 나오면서 해결되지 않았다.


두번째 방법으로는 이클립스를 실행할 때, " -clean" 옵션을 주는 것.

이클립스 실행파일 위치에 가서 콘솔에서 $ ./eclipse -clean 을 실행한다.

아쉽게도, 이 방법 또한 효과가 없었다.


대체로 위의 2가지 방법만 언급하는데, StackOverflow에는 다행히 다른 방법이 또 있었다. 

(사실상 기존 workspace를 리셋하는 것과 다를 바가 없지만...)

참조 URL: http://stackoverflow.com/questions/15333825/an-error-has-occured-please-see-log-file-eclipse-juno


아예 이클립스의 workspace 디렉토리 위치/.metadata 디렉토리를 통째로 다른 곳에 백업해 둔다.

그리고 이클립스를 실행하고 해당 workspace를 선택하면, 

이클립스는 마치 맨 처음 실행되는 것처럼 아무 프로젝트도 없이(ㅠㅠ) 켜진다.

그다음 File > Import... > General > Existing Projects into Workspace 선택,

Select root directory: 항목에 기존의 workspace 디렉토리 선택,

그리고 Finish 하면 workspace에 있던 모든 기존 프로젝트들이 나타난다.



반응형
블로그 이미지

Bryan_

,
반응형

테스트한 운영체제: MS 윈도우7 (64-bit)

이클립스 버전: Juno (4.2)


이클립스(Eclipse)에서 Subversive 플러그인과 SVN Connector, JavaHL, SVNKit 등의 플러그인을 설치하는 과정에서 예전 버전을 실수로 잘못 설치하게 되었다.


이클립스에서 모든 플러그인 설치는 Help > Install New Software... 메뉴에서 바로 할 수 있지만, 기존에 설치된 플러그인을 삭제하는 방법은 같은 위치에 없어서 헷갈리는 경우가 많다. 그래서 가장 흔히 쓰는 Subversive 플러그인을 재설치하는 과정을 메모로 남겨 둔다.



* 메뉴에서 "Help > About Eclipse" 선택

 - 대화창이 나오면 왼쪽 하단에 있는 "Installation Details" 버튼을 누른다.





* 설치된 플러그인 목록 중에서 삭제를 원하는 플러그인 이름을 선택하고, 중간 하단의 "Uninstall..." 버튼을 누른다. 

 - 아래 스크린샷에서는 버튼이 비활성화 되어 있지만, 플러그인 이름을 선택하면 Uninstall 버튼도 활성화돼서 누를 수 있다.

 - 여기서는 Subversive와 관련된 플러그인 삭제가 목적이므로 빨간색 테두리로 표시한 플러그인 전체를 다 삭제한다.





* 삭제할 플러그인 목록과 함께 최종적으로 삭제할 것인지 확인하는 대화창이 나타나면, "Finish" 버튼을 누른다. 

 - 삭제 후 재시작할 것인지 물어볼 텐데 Yes를 눌러 재시작한다.



* (이 항목은 안해도 되지만 확실한 삭제를 위해서 추가됨) 이클립스가 재시작되면 바로 검색해서 플러그인 설치를 하는 대신, 다시 이클립스를 종료하고 아래 폴더 위치에 간다. (윈도우7 기준으로 진행; 리눅스의 경우 경로를 자세히 확인하지 못한 관계로 서술하지 못한 점 양해드립니다) 그리고 해당 폴더에서 아래와 같이 삭제한다.


  • C:\Users\[사용자 계정명]\.eclipse\org.eclipse.equinox.security 폴더에서 secure_storage 파일 삭제
  • C:\Users\[사용자 계정명]\AppData\Roaming\Subversion 폴더 통째로 삭제
  • [이클립스가 설치된 폴더 위치]\plugins 폴더에서:
    • "org.polarion.eclipse.team.svn.connector"로 시작하는 폴더(보통 1개 있는 듯)
    • "org.polarion.eclipse.team.svn.connector"로 시작하는 여러 개의 jar 파일들 전부 삭제

사실 이렇게 해도 여전히 어딘가에 SVN repository 정보는 삭제되지 않고 남아있는 듯 하지만, 이정도만 해도(사실 안 해도) 재설치는 가능하다.



Help > Install New Software... 메뉴를 통해서 Subversive 플러그인을 수동 재설치한다.

 - 자세한 방법은 이전 포스팅(http://skylit.tistory.com/70)에 설명되어 있다. 간단히 요약하면: Help > Install New Software... 메뉴에 가서, 플러그인 설치 가능한 주소를 상단에 입력하고, 하단에 나열되는 목록 중 원하는 플러그인을 체크하고 설치를 진행한다.


 - Subversive 경우에는 아래와 같은 순서로 설치하게 된다:

  1. Subversive Team Provider 
  2. http://community.polarion.com/projects/subversive/download/eclipse/3.0/update-site/ 주소에서 나열되는 목록 중에서 Subversive SVN Connectors, 가장 최신 버전의 JavaHL 1.x Binaries, SVNKit 1.x Implementation, Native JavaHL 1.x Implementation 을 선택해서 설치




반응형
블로그 이미지

Bryan_

,
반응형

*테스트한 Eclipse version: JUNO


이클립스(Eclipse IDE)를 쓰다가 느 날, 왼쪽의 Package Explorer 창에서 각 프로젝트 옆에 표시되는 SVN 관련 정보 (revision 번호, SVN repository 주소 등)가 사라져 있는 것을 발견했다.

설정을 바꾸지 않는데도 이렇게 갑자기 보이지 않게 되는 것이 이상하지만, 어쨌든 이클립스를 새로 설치할 필요 없이 설정을 변경해서 다시 복구할 수 있다.



(1) 메뉴에서 Window > Preferences 선택


(2) General > Appearance > Label Decorations 선택

오른편에서 "SVN" 항목이 선택되어 있지 않다면, 체크해서 선택한다.





추가로, SVN 관련 표시에 대한 설정(글자색, 아이콘 등)을 변경하고자 한다면, 

Team > SVN > Label Decorations 에 가면 된다.




반응형
블로그 이미지

Bryan_

,
반응형

Development environment: Oracle Java 1.7


This post shows a case when the "createTextNode" method with the null parameter causes "javax.xml.transform.TransformerException: java.lang.NullPointerException" without detailed information (difficult to find the exact line of code causing NullPointerException).


Using DocumentBuilderFactory and TransformerFactory, users can create an XML document with user-defined tags. Usually, I convert a user-defined object into the XMlL representation in String using DocumentBuilderFactory and TransformerFactory. Below is a simple example which causes a NullPointerException:


/* Person.java */

public class Person {

String name;

String phone;


public Person(){ }


public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getPhone() {

return phone;

}

public void setPhone(String phone) {

this.phone = phone;

}

}


/* TestMain.java */

public class TestMain {

public static void main(String[] args){

Person person = new Person();

// person.setName("Smith"); // commented for making NullPointerException

person.setPhone("01011112222");


try {

DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();

DocumentBuilder docBuilder = dbfac.newDocumentBuilder();

Document doc = docBuilder.newDocument();

// root (person) tag

Element ePerson = doc.createElement("person");

doc.appendChild(ePerson);

// name tag

Element eName = doc.createElement("name");

ePerson.appendChild(eName);

Text nameText = doc.createTextNode(person.getName());

eName.appendChild(nameText);

// phone tag

Element ePhone = doc.createElement("phone");

ePerson.appendChild(ePhone);

Text phoneText = doc.createTextNode(person.getPhone());

ePhone.appendChild(phoneText);

//set up a transformer

TransformerFactory transfac = TransformerFactory.newInstance();

Transformer trans = transfac.newTransformer();

trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

trans.setOutputProperty(OutputKeys.INDENT, "yes");

//create string from xml tree

StringWriter sw = new StringWriter();

StreamResult result = new StreamResult(sw);

DOMSource source = new DOMSource(doc);

trans.transform(source, result); // the line where the Exception indicates

// print the XML output

System.out.println(sw.toString());

} catch (Exception e) {

e.printStackTrace();

}

}

}


As the TestMain.java shows, if the member variable "name" in the Person class is not set, it generates an exception like below:

ERROR:  ''

javax.xml.transform.TransformerException: java.lang.NullPointerException

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)

at org.usera.xml.TestMain.main(TestMain.java:39)

Caused by: java.lang.NullPointerException

at com.sun.org.apache.xml.internal.serializer.ToUnknownStream.characters(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)

... 3 more

---------

java.lang.NullPointerException

at com.sun.org.apache.xml.internal.serializer.ToUnknownStream.characters(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2TO.parse(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transformIdentity(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)

at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)

at org.usera.xml.TestMain.main(TestMain.java:39)


The exception guides me to "trans.transform(source, result)", but it doesn't seem to contain any null parameter. This means the other parts in the XML document object contains null values.

In this example, we can quickly find that the member variable "name" should be initialized with a valid String because it is a very simplified code. However, if I handle complex  objects including tens of member variables, it is not easy to find which variables are set to null.


Thus, I tried to make a wrapping method which make the "createTextNode" always get a "not null" parameter. The simple solution might be like below:

public static Text createTextNodeWithoutNull(Document doc, String str)

{

Text textNode;

if(str != null) textNode = doc.createTextNode(str);

else textNode = doc.createTextNode("null");

return textNode;

}


Then the modified code (a part of TestMain) is:

// name tag

Element eName = doc.createElement("name");

ePerson.appendChild(eName);

Text nameText = createTextNodeWithoutNull (doc, person.getName());

eName.appendChild(nameText);

// phone tag

Element ePhone = doc.createElement("phone");

ePerson.appendChild(ePhone);

Text phoneText = createTextNodeWithoutNull (doc, person.getPhone());

ePhone.appendChild(phoneText);


Likewise, the XML Document object won't contain any null values inside.



반응형
블로그 이미지

Bryan_

,