I have three spring boot applications, one is a derby spring boot and the other two have OAuth2 (org.springframework.security.oauth2) one has the OAuth2 client and the other the OAuth2 server. I have converted them to deployable wars and deploy them to a tomcat, they seems to be running fine. Except for the OAuth2, it seems to be failing in the deployable wars. I'm seeing this error:
org.springframework.security.oauth2.client.resource.OAuth2AccessDeniedException: Error requesting access token.
at org.springframework.security.oauth2.client.token.OAuth2AccessTokenSupport.retrieveToken(OAuth2AccessTokenSupport.java:145)
at org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsAccessTokenProvider.obtainAccessToken(ClientCredentialsAccessTokenProvider.java:44)
at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainNewAccessTokenInternal(AccessTokenProviderChain.java:148)
at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainAccessToken(AccessTokenProviderChain.java:121)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.acquireAccessToken(OAuth2RestTemplate.java:221)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.getAccessToken(OAuth2RestTemplate.java:173)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.createRequest(OAuth2RestTemplate.java:105)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:648)
at org.springframework.security.oauth2.client.OAuth2RestTemplate.doExecute(OAuth2RestTemplate.java:128)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:613)
at org.springframework.web.client.RestTemplate.headForHeaders(RestTemplate.java:336)
I have debug both executable and deployable and the only thing I have found is that in the executable wars the OAuth2AccessToken has a value but in the deploy wars in tomcat the OAuth2AccessToken is null.
I'm able to get the token with curl and I have check that the url is correct in the application.
I've also try to deploy the derby spring boot in a separate tomcat and that makes the OAuth2 to start working, not sure why.
I'm not sure why this is happening since the wars are the same. Am I missing some configuration in tomcat?
Or maybe some conflict with the classes deployed in tomcat? Or the tomcat classpath?
I once faced similar issue. I deployed my Spring Boot application on AWS and I was getting the same error. I was deploying the .war file and running the Tomcat separately on AWS. I fixed the error by deploying the .jar file which itself includes the tomcat server. Not sure if the scenario is same.
Related
I have created Spring boot application and Angular project (Angular 1) separately. In my local i am using npm to server the client app and it calls my back end app services. I am using Embedded tomcat in spring boot application.
Now i want to host my application in server. How do i do that?
Can i have embedded tomcat and build as jar or should i have to install standalone tomcat in the server and deploy my application as war?
How to configure my client code for example, in godaddy i have given ip xx.xx.xx.xx to www.xyz.com. The ip address is my production cloud server. How to redirect to angular application and that application calls server exposed apis.
I cannot have single application that has client code. I should do with two different application only. Please help me deploying this in best way. If embedded tomcat doesnt help then i can install standalone tomcat in server and and build my app as war and deploy it.
The current best practice would be to embed the servlet container (Tomcat, Jetty, other) into the artifact and build a fat JAR. The main advantage is a simplified deployment process: it's enough to push the far JAR into environment and execute it. Unlike the usual servlet container with WAR deployment model the embedded approach doesn't have to deal with additional configuration layers e.g. thread pools or data sources shared between different WARs.
One example of how to build a far JAR with embedded servlet container is spring-boot-starter-web dependency with spring-boot-maven-plugin:repackage goal. In this setup to build a fat JAR it's enough to run mvn clean package repackage.
If you are developing locally your web client code most likely will face issues with the same-origin policy. You most likely will need a CORS filter, however it's provided by Tomcat.
It maybe a trivial question for experienced web application developers, but for me as a new developer, I cannot understand that why do we need an application container(like Tomcat or Wildfly) when deploying a Spring Boot web application to Openshift, Heroku, or Google App Engine, etc? My understanding is that Spring Boot already contains an embedded container (Tomcat). Can someone explain this to me? Thanks
SpringBoot is Java API that relies on an embedded Java Servlet engine to support the API calls. These dependencies are typically pulled in by Maven as dependencies. So for the end user, it just looks like a FAR JAR with a bunch dependencies included (where one of those dependencies is Embed Tomcat, Jetty or Undertow for example)
More information can be found on the main SpringBoot project page.
I'm deploying a .war file built from one of the Spring Boot Getting Started projects, built with Spring Tool Suite. It's a simple RESTful webservice that works on the Tomcat server provided in the Spring Tool Suite running on my PC. The service responds with a string property on a get operation, so it's simple.
I added the Web Fragment Module facet in order to generate a war file. I'm deploying this war to a Weblogic 10.3.5 managed server instance on a test host. The deployment is successful. However, when I use the test URL provided from the Weblogic admin console, I get a 403 forbidden error.
This basic war does not have a web.xml. Should I have one? Should it contain a welcome file reference?
Is there additional configuration that I should do on Weblogic? I am reading the Weblogic documentation.
I read in a forum that Weblogic comes with a version of Spring inside it, but I have been searching how to use that and I didn't find a way.
Is it true?
Is there a way to deploy a Spring application in Weblogic without put the jars related to Spring inside the application or in Weblogic's lib directory?
Thanks.
I have a Spring Roo app that is deploying to Tomcat with no issues. I'm trying to deploy it to JBoss 6, but I'm finding it impossible to do so.
I've exhausted all resources from Google and I simply receive errors everywhere. Unfortunately, they do not seem specific enough to start narrowing them down to list here.
What can information could I provide to help resolve this situation?
Essentially, I need to know what I need to change from a standard Spring Roo app, using Hibernate and Mysql to work with JBoss 6.
EDIT:
This is the error that I am getting
[ClassLoaderManager] Unexpected error during load of:org.apache.commons.collections.DoubleOrderedMap$1$1: java.lang.IllegalAccessError: class org.apache.commons.collections.DoubleOrderedMap$1$1 cannot access its superclass org.apache.commons.collections.DoubleOrderedMap$DoubleOrderedMapIterator
Impossible to tell, since you posted no errors.
I'm guessing that it's a problem with the configuration difference between JBOSS and Tomcat.
You set up JDBC data source connection pools differently. Tomcat has the context.xml in the server /conf folder. JBOSS has other XML config files in its server/default/deploy folder. Did you create those correctly?
I assume that you're using JNDI names for injected data sources.
Your JDBC driver JAR for MySQL goes in the Tomcat /lib folder and the JBOSS server/default/deploy/lib folder, not the wAR WEB-INF/lib.
But you should be able to take a WAR with all the Spring Roo stuff, put it into an EAR with jboss-web.xml configuration, and start it up.