Tomcat setting - cookies? Twitter4j/Spring social in a tomcat webapp Spring MVC doesnt work inside tomcat - works fine in eclipse and outside tomcat


#1

I have a Spring MVC application. The code works well in eclipse environment. Fails at tomcat (all three (G3, G5 and Intermediate Secure )certificates are added to the truststore) - could there be a problem because of the cookies not accepted?

The error I get on stackTrace is really vague and isnt helping me - trying to solve it for almost 2 weeks now.

Its really mysterious since it works fine in the exact same server when I run it using javac!

Is there a special tomcat setting needed for twitter to work?

Error:
org.springframework.web.client.ResourceAccessException: I/O error: Server key; nested exception is javax.net.ssl.SSLException: Server key

root cause

javax.net.ssl.SSLException: Server key
sun.security.ssl.Handshaker.throwSSLException(Handshaker.java:898)
sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:195)
sun.security.ssl.Handshaker.processLoop(Handshaker.java:609)
sun.security.ssl.Handshaker.process_record(Handshaker.java:545)
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:963)
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1208)
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1235)
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1219)
org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:533)
org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:401)
org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:144)
org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:131)
org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
org.springframework.social.support.HttpComponentsClientHttpRequest.executeInternal(HttpComponentsClientHttpRequest.java:81)
org.springframework.social.support.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:49)
org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:91)
org.springframework.social.oauth1.OAuth1RequestInterceptor.intercept(OAuth1RequestInterceptor.java:48)
org.springframework.http.client.InterceptingClientHttpRequest$RequestExecution.execute(InterceptingClientHttpRequest.java:81)
org.springframework.http.client.InterceptingClientHttpRequest.executeInternal(InterceptingClientHttpRequest.java:67)
org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:46)
org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:49)
org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:438)
org.springframework.web.client.RestTemplate.execute(RestTemplate.java:415)
org.springframework.web.client.RestTemplate.postForObject(RestTemplate.java:294)
org.springframework.social.twitter.api.impl.TimelineTemplate.updateStatus(TimelineTemplate.java:154)
org.springframework.social.twitter.api.impl.TimelineTemplate.updateStatus(TimelineTemplate.java:142)

Thank you for helping me with ideas and pointers


#2

I finally found the solution! Completely by accident and nothing from the error messages!
I needed a line in my tomcat.policy file that permits sockets to be opened to api.twitter.com

I also seem to need port 8443 connector written and open at tomcat server.xml, even though I dont use the port at all! Perhaps some setting inside it does a system setting that is essential for twitter api to function via tomcat!


#3

i don’t understand


#4