Weird Build issue with Intellij, Maven, Scala pulgins - scala

I am facing really weird build issue with Intellij, Maven and Scala.
We have scala project, when I package it into jar by running mvn clean, mvn scala:compile and mvn install or package, it generates jar file perfectly but when I deploy this jar to our AWS EMR ec2 instance and when I run that jar with spark-submit command sometimes it complains about
"Error: Failed to load class com.OUR_PACKAGE_NAME.ScalaMainClass"
So I tried to check my code which looks perfectly fine, it complies fine, also it runs fine in my local machine. But sometimes that same generated jar works fine and sometime it does not in AWS EMR ec2 instance. It is not consistent.
So I reverted back my code to previous working stage and started adding my code one by one untill I get this "Failed to load class" problem. Then I encounter that one of the scala class having some issue. Visually code looks fine also it compiles great, but somehow that scala class creates problem when mvn creates jar file and when we run it to EC2.
The weird part is that, when I hit enter and add new blank line before or after problematic line of code, maven generated jar works fine. So I believe there is some hidden character which maven does not like or intellij is not able to uncode properly. And when I takeout that blank line that error appears again.
Could you help me on that?

Related

Invalid error messages in Spring Tool Suite

I am running into a problem when trying to duplicate a project in STS.
I am getting lots of error-messages of type
"Import XY cannot be resolved..."
in my code which runs and builds completely fine with maven and which is a more or less exact copy of the original project (with different artifact ID a.s.o. in the corresponding pom) which is shown as error-free.
What I did until now:
I wasn't sure how STS-duplicate works and thought that some configuration may have been duplicated but would have needed some changes, so I created a new project and inserted the code manually in manually new created classes and added the needed dependencies to the pom.
Again this compiles and runs perfectly while still showing the import errors.
Did anyone run into similar problems and has a solution to this?
(I had something similarly strange in the past where STS showed an error on project-level but no file in the project would have an error-indicator.)
Run a Maven -> Update Project..., that should help... :-)

Cannot build/run Scala project in IntelliJ after packaging with Maven

So my Scala project was working perfectly fine in IntelliJ, then I tried to run package in Maven to obtain a .jar file, which was not working because I was missing a dependency. So I tried to edit pom.xml however reverted it back shortly.
Anyhow, thereafter, without any changes I tried to run my Scala project normally locally and it doesn't work anymore. I get the error:
Error: Can not find or load main class Name.Name
I double checked Edit Configurations in IntelliJ and the main class is specified.
What went wrong? There has been no changes at all except that I tried to package my project using Maven, and then my normal program stopped working.
Solved it by recreating the project from scratch, however I'm still unsure what the cause was.

Scalatest building and running in Intellij, but not building the project when run on the command line with maven

I'm able to run my tests in a spec file individually when using intellij, however when I try running with Maven on the command line the project will not build with a
java.lang.RuntimeException: Unable to load a Suite class that was
discovered in the runpath: project.uitest.spec.aTestFile
error. I've tried restarting everything I can think of, and it works fine on my coworkers computer that has been running the tests for a long time. The issue reproduces on two other new coworkers environments however.
We tried copying the .m2 folder from the working environment onto the new environment machines however still run into the same issue.
We are using the same version of the JRE, and the scala and scalatest versions are specified in our pom.xml file.
We can also ignore the test that won't load and are able to run the tests.
Any insight or ideas of ways to fix this will be greatly appreciated.
What version of ScalaTest are you using?
ScalaTest Maven Plugin 1.0 doesn't support ScalaTest 3
https://github.com/scalatest/scalatest-maven-plugin/issues/27

JavaScript Executor not working when running Executable JAR file

When I run the test case in Eclipse, everything works fine, but when I make executable .jar of it, it runs until the command
js.executeScript("arguments[0].scrollIntoView(true);", element);
It returns java.lang.NullPointerException at this line of code
If there is another way to scroll element into view?
When you run from Eclipse IDE, the Run Configuration automatically adds the library you depend on (defined in your Eclipse project if not using another dependency management technology) to the classpath. So in this case, it succeeds at instantiating properly the js variable.
When not in Eclipse IDE, you have to specify the classpath to the command line in order to include dependencies. Otherwise, the dependencies are missing and you don't get a good way to instantiate the js object.

Compile and run a netbeans project with terminal

So I created a project in netbeans and then added a new JFrame form (this is my first gui app). I was wondering if there was any way to open the source code in another app like textedit and compile it using terminal (javac blah.java, java blah).
I managed to create a .jar file (clean and build) and it works perfectly fine when I try to run it (double click). Now I managed to find the .java file in src but when I compile it I receive 36 errors, which makes no sense since it built and ran perfectly fine and the jar file works.
Essentially I want to just take the source code (not the entire project) and compile it, for example on a computer that does not have netbeans using terminal. Can this be done?
I would also like to emphasize that I'm just a beginner. Thanks!
Standard NetBeans projects are based on Apache Ant. So it should be sufficient to install Ant and a JDK to compile/package your project on another computer or CI system.
What i found to be the culprit to this problem is that on your source code make sure it does not have package. So for example:
"package blablah"
All you have to do is get rid of that, and then take your java file and it should compile perfectly. For some reason that causes the nodefclass error.