how to embedd mysql in grails standalone application - java

I am creating a grails standalone application with with embedded tomcat server
the application works fine with embedded tomcat server.
But i need to integrate embedded mysql with the application.
Any tutorial or any hint to start with is very much appreciated.
The points i need to figure out
how can i configure my standalone application to use embedded mysql
whether mysql can be configured as embedded database or not

According to this question it seems that you're looking for MySQL Connector.

For fresh versions of grails (3,4) the plugin for embedded mysql exist
https://github.com/purpleraven/embedded-mysql-grails-plugin

Related

Is it possible to make a Spring MVC web app run as a "standalone executable" with Java and Tomcat embedded?

I have a web app built with Java, Spring MVC, and JDBC. The result is a WAR file.
To run it, the user has to install Java 8 JDK and Tomcat, and deploy the WAR file to the Tomcat server.
It would be great if they could just download the one file run it as a standalone application.
That is, run "the WAR file" and just browse to http://localhost:8080/myapp
Also, on Windows it would be great it was setup as a Server (like Tomcat is when installed with the installer).
Is there any way to do this? Maybe with Spring Boot or something new like that?
Yep, Spring boot is the way to go.
It allows you to build an executable Jar with all dependencies and a Tomcat (by default, can be changed) embedded.
But users will still need to download a JRE to execute the Jar, and a database if it's required, but you can use en embedded database like H2, HSQLDB..., depends what is your needs.
Yes . you can use spring boot to achieve your results. Kindly refer the below link for sample code
https://mkyong.com/spring-boot/spring-boot-hello-world-example-jsp/
You can use embedded jetty server using maven but that would require you to setup few things your app and may have align your existing app, please check this article for more information.
Jetty is similar to tomcat server in terms of running spring application, there are not much difference in terms of development. Tomcat is just more famous.
Other option as others said, is to migrate your app to spring boot which would be easy if you already have app written in spring (But that depends how much code you have and how much time you have)

Issues deploying a Java application to Tomcat

I built a simple Java web application. It provides a series of RESTful APIs for the user to carry out certain operations on a Java DB through a web interface. I used NetBeans environment during the development, and Glassfish for testing.
Now that I finished it, I would like to be able to deploy it on another machine using binaries (although as for now I use the same machine until I learn how to do it).
I installed Tomcat 7, and moved the .war file into Tomcat's webapp folder. The application deploys. Thereafter I try to read some data from the databse using a button I created just for this, but get the following error
I am not sure what went wrong, but I have two theories.
1) The web application cannot connect to the database. Yet when I attempted to run the application again, after starting JavaDB from NetBeans, there was no difference.
2) Somehow, the application cannot reach the Node service. I assumed that there will be no need to change the API links while moving the app, but perhaps I was wrong.
Or maybe there is some other issue I did not consider? I will be grateful for any advice about how to properly deploy such an application.
EDIT: The issue was solved by using TomEE.
The error is come from your application server of choice.
TomCat is only a servlet container (means it only support Servlet/JSP).
Any other feature (JAX-RS, CDI etc) require a Java EE certified server e.g. GlassFish, WildFly,Payara, WebLogic, OpenLiberty or TomEE.
TomEE could be your best bet if you want to use TomCat in your production or test environment, it is basically TomCat + Java EE other feature.
EDIT:
TomEE don't have a GUI for JNDI datasource configuration like GlassFish, you need to edit conf/tomee.xml
<Resource id="myDataSource" type="javax.sql.DataSource">
jdbcDriver = org.apache.derby.jdbc.ClientDriver
jdbcUrl = jdbc:derby://localhost:1527/dbname
userName = app
password = app
</Resource>
And in your java code:
#Path("resources")
#Stateless
public class MyResources{
#Resource(name="myDataSource")
DataSource dataSource;
#GET
public Response SomeMethod(){
//Do stuff here
}
}
You can check here for more detail configuration on data source.

How do I run a spark application on a tomcat server

After a day of googling, I'm still lost.
I've created a Spark web-application that runs on the embedded Jetty server, but I want to run my web-application on a Tomcat server.
I'm using Maven to build my web-application and can't find any good resources on using Spark on Tomcat with Maven.
How can I create a Maven project with Spark and run it on a Tomcat server?
You'll need to implement EmbeddedServer interface in order to do it. Currently, it only supports Jetty by default. So, fork it and submit a PR to the author.

How to manage a Spring-MVC web application in Eclipse with same workspace for different database testing

I am working on a Spring MVC project with running Tomcat server and using Eclipse STS IDE.
I need to test my project's functionality with different databases (SQL, oracle and postgreSQL database).
To test same functionality in all databases, every time I am changing applicationProperies.properties file to change database configuration and restarting the sever. Is there any way where I can test my application parallely with all databases?

Is it possible to deploy an application with WildFly as a bundle?

Is it possible to deploy an application with WildFly as a bundle?
I am able to do this with embedded Glassfish.
If you want to embed JBoss/Wildfly with your app, you should review Wildfly Swarm. That's a way to generate an application that contains the server embedded. It's very similar to Spring Boot, but you can use Java EE APIs.
As you can see in JBoss documentation there has been something for OSGi, rather than there is...
To me it looks like this has died before wildfly was released.

Categories

Resources