Spring Session이용하기

@RequestMapping(value = "/api/memo", method={RequestMethod.GET, RequestMethod.POST})
 @ResponseBody
 public String memo(@RequestParam(value = "action") String action,
 @RequestParam(value = "memoId", required = false) Integer memoId,
 @RequestParam(value = "content", required = false) String content,
 @RequestParam(value = "start", required = false) Integer start,
 @RequestParam(value = "limit", required = false) Integer limit,
 HttpSession session) {
 if (TextUtils.isEmpty(action) || ActionType.getType(action.toUpperCase()) == null) {
 ApiResultModel model = new ApiResultModel();
 model.setResult(ResultConfig.INVALID_PARAMETER);
 return new Gson().toJson(model);
 }

 if (session == null && session.getAttribute(SessionConfig.LOGIN_USER_INFO_SESSION) == null) {
 ApiResultModel model = new ApiResultModel();
 model.setResult(ResultConfig.WRONG_APPROACH);
 return new Gson().toJson(model);
 }

 int id;
 if (memoId == null) {
 id = -1;
 } else {
 id = memoId;
 }

 String userId = ((UserInfoModel) session.getAttribute(SessionConfig.LOGIN_USER_INFO_SESSION)).getUserId();
 log.info("action : " + action + ", type : " + ActionType.getType(action.toUpperCase()) + ", userId : " + userId);

 ApiResultModel model = ActionType.getType(action.toUpperCase()).doAction(memoDao, userId, id, content, start, limit);
 return new Gson().toJson(model);
 }
private void makeSession(HttpSession session, String userId, String oauth, String accessToken) {
 UserInfoModel model = new UserInfoModel();
 model.setAccessToken(accessToken);
 model.setOauthPlatform(oauth);
 model.setUserId(userId);

 session.setAttribute(SessionConfig.LOGIN_USER_INFO_SESSION, model);
 }

jenkins deploy 오류

Caused by: org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded "FAIL - Encountered exception javax.management.RuntimeErrorException: Error invoking method check
" instead of the expected "OK" message
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:715)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:761)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:312)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:101)
	... 18 more
org.codehaus.cargo.container.tomcat.internal.TomcatManagerException: The Tomcat Manager responded "FAIL - Encountered exception javax.management.RuntimeErrorException: Error invoking method check
" instead of the expected "OK" message
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:715)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deployImpl(TomcatManager.java:761)
	at org.codehaus.cargo.container.tomcat.internal.TomcatManager.deploy(TomcatManager.java:312)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.deploy(AbstractTomcatManagerDeployer.java:101)
	at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:184)
	at hudson.plugins.deploy.CargoContainerAdapter.deploy(CargoContainerAdapter.java:77)
	at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:147)
	at hudson.plugins.deploy.CargoContainerAdapter$DeployCallable.invoke(CargoContainerAdapter.java:117)
	at hudson.FilePath.act(FilePath.java:996)
	at hudson.FilePath.act(FilePath.java:974)
	at hudson.plugins.deploy.CargoContainerAdapter.redeploy(CargoContainerAdapter.java:114)
	at hudson.plugins.deploy.PasswordProtectedAdapterCargo.redeploy(PasswordProtectedAdapterCargo.java:93)
	at hudson.plugins.deploy.DeployPublisher.perform(DeployPublisher.java:64)
	at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
	at hudson.model.Build$BuildExecution.post2(Build.java:186)
	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
	at hudson.model.Run.execute(Run.java:1753)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:98)
	at hudson.model.Executor.run(Executor.java:405)
Build step 'Deploy war/ear to a container' marked build as failure
Finished: FAILURE

 

해당 이슈 발생시,

/var/lib/tomcat7/logs 에 확인해 보면

Exception in thread "http-bio-8080-exec-79" java.lang.OutOfMemoryError: Java heap space

라고 oom이 발생하고 있다.

 

tomcat java heap 늘려주기

https://stackoverflow.com/a/25783144

 

jenkins java heap 늘려주기

https://wiki.jenkins.io/display/JENKINS/Builds+failing+with+OutOfMemoryErrors

https://stackoverflow.com/a/14762164

intellij에서 톰캣 연동

maven 프로젝트에서 plugin 추가

<build>
   <plugins>
      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-compiler-plugin</artifactId>
         <version>3.3</version>
         <configuration>
            <source>1.7</source>
            <target>1.7</target>
         </configuration>
      </plugin>
      <plugin>
         <groupId>org.apache.tomcat.maven</groupId>
         <artifactId>tomcat7-maven-plugin</artifactId>
         <version>2.2</version>
         <configuration>
            <path>myProject</path>
         </configuration>
      </plugin>
   </plugins>
</build>

 

빌드 설정에서 command line에서

tomcat7:run

추가 및

http://localhost:8080/myProject/

접속

tomcat manager

/etc/tomcat7/tomcat-users.xml에서

<tomcat-users>
 <role rolename="manager-gui"/>
 <role rolename="manager-script"/>
 <user username="myManagerId" password="secretP^wd" roles="manager-gui,manager-script"/>
</tomcat-users>

추가

 

로컬 ip만 허용

/etc/tomcat7/Catalina/localhost/manager.xml
/etc/tomcat7/Catalina/localhost/host-manager.xml

<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.0\.0\.1" denyStatus="404"/>

추가

 

-참고-

Caused by: java.io.FileNotFoundException: http://localhost:8080/manager/text/list

이 에러가 나오는 경우 tomcat7-admin 설치