Is it possible to use New Relic on my Java site? I built it with JHipster Yeoman generator and deployed the WAR file to Heroku. I setup New Relic. I looked at the default policy. It appears to have a pinging service, but I am wondering if I have to do something in addition to keep my site up. Maybe create a route for the pinging service?
From looking at the Jhipster site, it says it creates a Spring boot backend: https://jhipster.github.io/
Providing the version of spring used is v3 or v4 it should work. (I was unable to verify what version boot actually uses)
https://docs.newrelic.com/docs/agents/java-agent/getting-started/new-relic-java
This looks like it should work to me, trying it is the only way to know for sure. Here is the heroku-newrelic-java install doc:
https://devcenter.heroku.com/articles/newrelic#java-installation-and-configuration
The ping service will attempt to connect to your site over http/https from external locations, to verify that it can be reached. You shouldn't need to do any additional configuration on your site.
Related
I am new to AWS world and still learning. It's been only a month that I am trying things.
I have been looking for it for quite a few days now and haven't been able to find a correct and more appropriate solution. Therefore it would be great if somebody can help me by giving a sample code, provide some pointer or guide in the right direction.
I have a AWS RDS MySQL instance and a database created. I have configured "IAM DB AUthentication Enabled" to "Yes".
Created an IAM Role and Policy as per AWS documentation.
And finally, I have an EC2 instance with Tomcat with my Java/Spring application deployed and running in it. I am able to access the MySQL database using database credentials (like db user name, password, db url, etc.) successfully. So I know things are setup properly now.
Can somebody please help me know how to connect to this database from my Java/Spring application using spring-jdbc and AWS IAM Authentication (the IAM role I created above)?
I read somewhere that I need the certificate file or certificate bundle file in my application environment and that I need to generate a token to be connected to the database. But I am not able to think on how to put it together.
Any help will be highly appreciated.
Thanks.
I had a similar problem recently.
This is what I did:
Included Spring Cloud AWS JDBC and Spring Data JPA
Implemented a custom DataSourceFactory, which generates an IAM access token and uses that for the connection
You can find a full step-by-step guide here.
Btw., Spring Cloud AWS JDBC provides some additional benefits, like read replica or failover support, and you only have to provide the instance ID of your RDS instance, and not the full canonical endpoint.
I know this is an older question, but after a some searching I found a pretty easy way you can now do this using the MariaDB driver. In version 2.5 they added an AWS IAM credential plugin to the driver. It will handle generating, caching and refreshing the token automatically.
I've tested using Spring Boot 2.3 with the default HikariCP connection pool and it is working fine for me with these settings:
spring.datasource.url=jdbc:mariadb://host/db?credentialType=AWS-IAM&useSsl&serverSslCert=classpath:rds-combined-ca-bundle.pem
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.username=iam_username
#spring.datasource.password=dont-need-this
spring.datasource.hikari.maxLifetime=600000
Download rds-combined-ca-bundle.pem and put it in src/main/resources so you can connect via SSL.
You will need these dependencies on the classpath as well:
runtime 'org.mariadb.jdbc:mariadb-java-client'
runtime 'com.amazonaws:aws-java-sdk-rds:1.11.880'
The driver uses the standard DefaultAWSCredentialsProviderChain so make sure you have credentials with policy allowing IAM DB access available wherever you are running your app.
Addionally, if you want failover support like #markusgulden mentioned in his answer, you can use the aurora mode described here. Your endpoint would then look like
jdbc:mariadb:aurora://host/db?credentialType=AWS-IAM&useSsl&serverSslCert=classpath:rds-combined-ca-bundle.pem
Hope this helps someone else - most examples I found online involved custom code, background threads, etc - but using the new driver feature is much easier!
I would suggest using this library that you use to replace the HikariDatasource. Everything else just works like normal.
<dependency>
<groupId>io.volcanolabs</groupId>
<artifactId>rds-iam-hikari-datasource</artifactId>
<version>1.0.4</version>
</dependency>
I'm currently running my Java application on a GlassFish server on AWS-EB.
Since our front-end is already running on the Google Cloud Platform, I would like to migrate my back-end to GCP as well.
I tried the Jelastic interface but I was not happy with the speed results.
Now I'm looking to deploy my application on the App Engine but when I deploy my current .war file, I get the following error:
Error 404 - Not Found.
No context on this server matched or handled this request.
Contexts known to this server are:
/ ---> o.e.j.w.WebAppContext#7e0b0338{/,file:///var/lib/jetty/webapps/root/,UNAVAILABLE}{/root.war} [failed]
I guess I'm missing something, since GCP is using Jetty as a server.
I'm a bit lost and I hope you guys can point me in the right direction to make this migration successful.
It's suggested here that Jetty requires two configuration files (web.xml and applicationContext.xml).
As well as this, the original poster in the issue above stated that they solved their issue in this GitHub post by rebuilding their project before deploying.
I followed this tutorial on how to connect to google drive. I took some liberty with using maven instead of gradle and a few details, but it worked. I inserted the relevant code into war file and deployed it in my localhost and it worked on the server. However, when I deployed the same war into google compute engine, it didn't work. Obviously it is because of this line.
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
I guess it invokes the authorization procedure on the machine of the tomcat, not user. I would expect there to be a way to deploy such a solution on web server, but I did not find it.
I think about moving my authorization to JS, and pass the token to backend, but that does not seem a good practise for me.
Regards
I kept digging in the Internet for a while and found class
com.google.api.client.extensions.servlet.auth.oauth2.AbstractAuthorizationCodeServlet (and AbstractAuthorizationCodeCallbackServlet from the same package).
Weird it was nowhere in the google tutorials. It is quite close to what I need, so I keep working on it.
For everyone interested in the matter:
It seems that google authorizations don't like external IP addresses, so I need to set up domain properly, but that is another story.
I have a Google AppEngine (Java) project in Eclipse. I want to debug my local code in Eclipse but use the deployed database on AppEngine. Until now I use Remote API with username/password (old way)
This method will be deprecated and I want to use OAuth but when I try to use it, it throws an exception:
java.lang.IllegalStateException: OAuth-based authorization not supported for clients running on App Engine
at com.google.appengine.tools.remoteapi.RemoteApiOptions.getOrCreateHttpTransportForOAuth(RemoteApiOptions.java:359)
at com.google.appengine.tools.remoteapi.RemoteApiOptions.useApplicationDefaultCredential(RemoteApiOptions.java:162)
Everthing is fine when I run a simple Java client app that uses remote api in Eclipse. But if the client is AppEngine development environment in Eclipse, it doesn't work.
How can I debug the server code in eclipse using appengine database?
Bug report: https://code.google.com/p/googleappengine/issues/detail?id=12556
This is expected, as value returned by ApiProxy.getCurrentEnvironment() will not be null, but com.google.appengine.tools.development.LocalHttpRequestEnvironment object. For development server you'll have to use old style (username/password) for now.
According to the documentation, you need to add appengine-remote-api.jar from ${SDK_ROOT}/lib/appengine-remote-api.jar to your WEB-INF/lib directory (or add it to your Maven dependencies) before this will work.
Update: Indeed, it looks like OAuth from App Engine with Remote API has not yet been implemented. I would assume this will change before ClientLogin is fully deprecated, but for now I would recommend opening a feature request on the public issue tracker.
One possible workaround would be to create a regular console application that connects to the Remote API (as per the example in the docs) and can act as a proxy for your App Engine application running on the development server.
In addition to what my colleagues Adam and Nikita previously said, I can officially confirm that the Google Cloud Engineering Team is determined to provide a solution to all reasonable use-cases which are affected by the ClientLogin shutdown before its deadline.
Presumably, the Remote API solution will be available in the upcoming releases 1.9.31/32, although this is just an assumption and there's no ETA for it yet.
As an alternative, you can access Cloud Datastore using Protobufs remotely using service account credentials, which might fit your needs for the moment.
UPDATE 2016/01/21:
The team has extended the ClientLogin shutdown deadline to April 12, 2016.
UPDATE 2016/04/12:
As mentioned before, the fix was properly applied and available in the latest versions of the SDK and gcloud. Remote API can now be used again with OAuth for app-to-app (or devserver-to-app) connection.
I am developing an web app using java/j2ee as middle ware and Mysql 5.1 as database. I have to deploy it on AWS-EC2 server.
My questions are:
How do I create the build
How do I deploy on ec2 server?
I am using Apache Tomcat-6. Should I use any other server like Apache2 as web-server?
Use WTP to create a Dynamic Web Module project.
Use AWS Toolkit for Eclipse
That's pretty terse, but you'll need so many more details that it's pointless to list them here. Read the docs, then come back with specific questions :)
Whether you need Apache2 in front of Tomcat depends on your requirements. If you need it you'll know it :) Things that you might want to punt off on Apache2:
SSL
Static content
URL rewriting
If you are just planning to do every thing manually. You should read this manual http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/
Basically,
You need to create an AMI instance of platform of your choice. (Win/Unix-based).
Configure it with the software that you need. In your case, Tomcat-6 and MySQL-5.1. Configure them. Set Schema etc.
Upload your WAR file to the instance and deploy to Tomcat-6.
Make sure Tomcat port (8080 or whatever you've configured) is open. You can configure this from AWS console's Security Group setting.
Use the instance's Public DNS to access your app. Public DNS can be found from AWS console.
There are many freely available, pre-configured AMI available. Since your setting is one of the most common one. I am sure you will get one and skip Step#2.