Using Cypress.io to test React in a Maven project - reactjs

I'm currently working on a project and want to use Cypress to write tests for my app that is being made in React. It seems however that Maven is acting up, and after a lot of Google-Fu I got stuck. It seems I'm missing parts of a module, but I was unable to find what kind.Here is an image of said failure.
What am I missing? Thanks in advance.

Missing package maven compiler plugin reports is inside mozilla rhino jar. Try adding following dependency in to your pom.xml
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7.8</version>
</dependency>

Related

how do you create a war for spring boot / react application

I have a spring boot app as backend and using react as front end (both are in same project). I only have the one pom file for the backend and I run the spring app manually and then do a npm start on the frontend, all works fine. What I want to do now is deploy both backend and frontend and start them up automatically. Do I need another POM file for the front end or something which will execute npm etc? Front end was created with create-react-app and currently running on port 3000 ( "start": "react-scripts start" ), my backend running on port 8080 but would be deployed to an external tomcat server.
Do I need to add the following plugin:
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
and then some execution rules in the pom?
Any information is much appreciated.
Thanks
If you want to create war in spring boot, you need to add packaging as war and spring-boot-starter-tomcat should be <scope>provided</scope>. I think yes you need to add, please check the reference in the below url,
https://github.com/spring-guides/tut-react-and-spring-data-rest/blob/master/basic/pom.xml
Ref: https://spring.io/guides/tutorials/react-and-spring-data-rest/
<packaging>war</packaging>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
let me chip in and say something else. If you need a war as packaging, you can proceed as per Thangavel said. But I am a bit sceptical to go for a deployment like that on a production site.
Since you are using a front-end framework and spring as backend, I would suggest another way. Usually after doing a build of your front-end, you will use a http server like apache or nginx to deploy your build and then your war or jar for your spring boot project.
But if you want to keep both in the same project, you can do a build of your react project and it should be possible to import those JS files of your build in a thymeleaf or JSP view. Then you would only need to run the project on port 8080.
Here is an example for Angular. I am sure you can look for same in React.
How to include angular2/4 component in JSP page?
Please let me know how it goes.
If you want a good reference implementation you can generate a jhipster project and look at how the frontend plugin is used.

eclipse-che workspace wont recognize new maven dependencies

Tried searching about this but found nothing that could help me and so here i am...
I like the concept of Eclipse on the cloud and started giving it a try with the first basic hello world example. I created the first workspace with java-maven stack with the given console-java-simple project. I was able to run the app, debug it and what not... Next i added a simple maven dependency like apache-commons-math3 to the pom.xml
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6</version>
</dependency>
and initiated the maven build, all good here... was able to see the jar imported to the m2 repo. When i try to import something, the editor doesn't seem to recognize the dependency. It complaints with the following
The import org.apache cannot be resolvedJava(268435846)
I ignored this error in the editor and initiated the maven build, but java compiler had the same issue and the build failed.
So am i missing something that's so obvious that everybody else is able to figure out :-)
Side Note: I was able to import this same dependency in a java-springboot-msql worksapce without any problem by following the same exact steps.....
If build.gradle file exists then Grandle is used as build-automation system.

NoClassDefFoundError: Could not initialize OauthRawGcsServiceFactory on production environment

I'm using appengine-sdk 1.9.3.
In devserver, works in Eclipse and Ant normally.
When I deploy (update) to appengine (production environment), I get this error:
event.getResults(): [<pre>Error for /p7/formPanelServlet
java.lang.NoClassDefFoundError: Could not initialize class
com.google.appengine.tools.cloudstorage.oauth.OauthRawGcsServiceFactory
at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createRawGcsService(GcsServiceFactory.java:42)
at com.google.appengine.tools.cloudstorage.GcsServiceFactory.createGcsService(GcsServiceFactory.java:34)
at com.bitvisio.p7.server.FormPanelServlet.<init>(FormPanelServlet.java:27)
At FormPanelServlet.java:27, the code is:
private final GcsService gcsService = GcsServiceFactory
.createGcsService(new RetryParams.Builder()
.initialRetryDelayMillis(10)
.retryMaxAttempts(10)
.totalRetryPeriodMillis(15000)
.build());
I put the lib appengine-gcs-client-0.3.9.jar in war/WEB-INF/lib. I think there is a problem with this lib.
Thanks for help.
Always use tools like Maven or Ivy to resolve dependencies for you. Copying JARs to war/WEB-INF/lib/ directory and editing .classpath file manually will be painful and may not help you always. If you use Eclipse & Google App Engine plugin, use Add Google APIs... as mentioned here - Google Plugin for Eclipse. In my case, adding Cloud Storage API via Google Plugin for Eclipse helped resolve this NoClassDefFoundError.
I had the same problem. I use Ivy to resolve dependencies and always get the latest.integration (with Maven use RELEASE) for revisions.
However I usually ignore transitive libraries. It looks like Google is expanding the API family - at least splitting out discrete functionality.
There are now quite a few transitive dependencies and it seems they released a new version of the GCS client around the same time as 1.9.3.
Getting all dependencies and packaging them in my deployment fixed my issue. I did not have the issue in development which made it more confusing.
You are facing this issue because you are not adding the some of the jar like
google-api-services-storage-v1-rev78-1.22.0.jar download link
joda-time-2.94.jar download link
guava-19.0.jar link to download
you can use the different version of jar according to your appengine-gcs-client jar file.
Note : Add all these jar and build path with the project and problem will get solve.

Maven problems using GAE and DataNucleus

I'm having trouble retrieving 2 artifacts in my Maven/Java/Google App Engine project:
com.google.appengine.orm:datanucleus-appengine:jar:1.0.7.final
com.google.appengine:appengine-api-1.0-sdk:jar:1.3.4
There's a similar question posted, but each answer brings me back to the same error message.
More detail
I don't know if it is relevant, but rather than a version number, my original dependency for DataNucleus contained a variable. I am using Eclipse.
<groupId>org.datanucleus</groupId>
<artifactId>datanucleus-core</artifactId>
<version>${datanucleus.version}</version>
<scope>runtime</scope>
I did not include my stack trace in Maven for brevity's sake. Please let me know if it would help to post it. Thank you.
UPDATE
I was able to get the DataNucleus artifact by changing the version from 1.0.7.final to 1.0.6.final (check this repo) and rolling back to AppEngine 1.3.3 (thanks, #Taylor!). However, I still can't find the repo for appengine-java-sdk:jar:1.3.3. There are no jar files hosted at Google Code.
Does anyone know where to find the appengine-java-sdk jar?
Version 1.3.4 of the App Engine SDK is not yet supported by the maven-gae-plugin. Please see the issue here.
Also, based on your latest edit to the question you should NOT be using version 1.3.3. Rather, you should be using version 1.3.3.1 (see here). Also, the appengine-java-sdk jar is available in the maven-gae-plugin repo (see here).

Using Maven in Google App Engine application

I'm making Google App Engine project with SpringSource Tool Suite. I made project without maven and added libraries to lib folder and I got Spring Framework work perfectly. But the I tried to make project that uses Maven, adn I when I tried to run my app on development server it cannot find any classes.
So what should I do, so that my dependecies are actually deployed to lib folder?
Example of dependency in pom.xml:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.core</artifactId>
<version>3.0.2.RELEASE</version>
</dependency>
Take a look at the pom.xml in my jappstart project. It's a functional GAE project that uses Spring.
Take a look at the example it covers Sprint 3, Google App Engine and maven.

Resources