Acceleo standalone generation - acceleo

I also need to generate outside eclipse and i didn't figured out how to do it.
I've read this thread but I have another problem to overcome first : I'm unable to start the main !
I tried different ways : export the project as standalone, put the project in a regular or executable jar, and launch directly Generator.class. I would like some help with the last solution. Here's how I launch it :
java -cp "..\testGene\bin\;C:\Program Files\Eclipse\plugins" testGene.main.Generate testModel.uml outputDir
I can't copy the whole console (dev computers are not connected to internet), but it says :
Exception in thread "main" java.lang.NoClassDefFoundError: org/Eclipse/acceleo/engine/service/AbstractAcceleoGenerator
Could not find the main class: testGene.main.Generate.
The generator works well inside eclipse, and I manage to call a simple test class with the same command line. I tried to copy the whole acceleo plugins in my bin directory in case the space in "Program Files" is a problem.
I'm pretty sure this is a simple error I made, any ideas ?

Furthermore, I'm not sure that it's sufficient to use the plugins folder in your classpath. Shouldn't there be a list of the jar files you need?

Since the program does not seem to find the AbstractAcceleoGenerator I would say that you are lacking some dependencies of the generator. Have a look at this screenshot to see the jar used for an UML to Java generator.

Related

Maven Test with Evosuite-generated Test Cases

I am using Evosuite to generate test cases for my app via Maven and I've followed all of the steps that are outlined in the Evosuite documentation.
I see that all of the test classes have been generated and the export copy the classes to the test folder of my project, so I should be able to run mvn test to run the tests, but when I do, I get a series of errors that it cannot find a bunch of classes (it looks like it can't find any of the Evosuite classes from the runtime even though I have the evosuite runtime defined as a dependency in my POM.)
I would love to use Evosuite for all of our apps but if I cannot get the mvn test to run without errors then the product is useless. Can anybody help with this? I have gone over the documentation several times and checked everything and it all appears to be configured correctly. Thank you.
If you have already run mvn evosuite:export to move them to the ./src/test folder then you may need to compile them using javac so they can be executed by maven. Try using this article to compile them all within one command: How to compile multiple Java files when there are Java files in other packages?

How do I disable the test-out folder

Would like to disable the test-out folder means test outputs in my project as it less disk space issues in automation machines. Tried all below options as got it our tool:
SetDefaultListener(false);
setVerbose(0);
command line argument -usedefaultListener false
nothing can work me.I am using maven build tool to generate the jar. We need to give the jar to automachines to run this.
That's not possible by definition if do not want to have that folders, you have to skip tests in process of Jar building.

problems running state machine examples

Congratulations on the spring state machine, I found it yesterday and have been trying it out, specifically the turnstile example running in STS. I found it very easy and intuitive to build a FSM.
Because spring shell doesn't work well in STS I tracked down the instructions to run the examples from the command line in the reference doc,
"java -jar
spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar"
,
but running it got an error
"no main manifest attribute, in spring-statemachine-samples-turnstile-1.0.0.BUILD-SNAPSHOT.jar".
Although not even a novice in using gradle, I tried fixing this by adding this line to build.gradle in the jar section
"manifest.attributes['Main-Class'] = 'demo.turnstile.Application'"
(which doesn't handle the various sub-projects I know) but got this error
"NoClassDefFoundError: org/springframework/shell/Bootstrap".
If it is possible to run the samples from gradle, could you include them in the reference document? I tried running the samples using
gradle run
but it there was no interaction with the shell scripts.
Samples are designed to be run as executable jar and with shell so that you can interact without a need to recompile with every change. Your error indicates that you didn't build that sample jar as mentioned in docs.
./gradlew clean build -x test
This will automatically use spring boot plugin which will add the necessary jar manifest headers to jar meta info to make it a true executable jar. Essentially every every sample is a spring boot app.
Building SM sample projects in Windows Environment:
Open Command prompt (windows key + r -->cmd-->Enter), Change directory to project root folder spring-statemachine-master (Inside the Extracted folder).
Run gradlew install to get all spring dependencies copied to local machine.
Run gradlew clean build -x test to get the spring shell jars built. Courtesy Janne
These steps should ideally get all .jar built, look into \build\libs folder of respective sample project for jar files.
Run the like any other java jar file java -jar [jar-file-name.jar] (make sure to be change directory to jar file directory location).
One more thing where I was stuck was, How to give events to SM:
It's like this sm event EVENT_NAME_AS_DEFINED_IN_CLASS. Ref
E.g.: sm event RINSE --> to washer project

Executing jar from q

I'm trying to run an executable jar from a q process but it gets stuck loading (no error).
When running the jar from cmd it works fine.
In cmd:
java -cp "C:/javaWorkspaces/someDirectory/myJar.jar" myPackage.myClass
In q:
system "java -cp \"C:/javaWorkspaces/someDirectory/myJar.jar\" myPackage.myClass"
Also note that the jar uses external jars (packaged with eclipse), creates a new thread and connects to the internet. It seems like the latter might be the problem (after doing some manual sysout debugging)
What can I do about this?
Solved it by writing a small Java program that executes the full java command in cmd:
q -> runs small Java program 1 -> runs cmd commands to open the dependent Java class
I think the problem was that the jar had external dependencies which also needed to be loaded, eventhough Eclipse says it 'packs' them together with the jar.
I think a plugin such as Fat Jar is the solution for creating an independent executable jar.
But I didn't care about creating a fully independent jar. This solution works evenly well. It's a bit of a workaround but the final code in q is now much cleaner and shorter.

java programs not running due to seting classpath

i wanted to practice developing database programs in java so i set the classpath to E:\software\installed\java\jre\lib by declaring a new environmental variable classpath and gave value as E:\software\installed\java\jre\lib but now i am unable to run any program(not even non-database) i get an error
Error: Could not find or load main class MysqlConnect
but when i delete the classpath variable i am able to run non-database programs. what is the possible problem and please let me know the solution. i have set path to E:\software\installed\java\bin
nothing is helping i tried using class path switch in java which is not helping (java -cp C:\Program Files\MySQL\MySQL Server 5.5 MysqlConnect) nor do setting path is helping (set CLASSPATH=%CLASSPATH%:C:\Program Files\MySQL\MySQL Server 5.5:C:\Program Files\MySQL\MySQL Server 5.5\mysql-connector-java-5.1.20-bin.jar) all are giving the error
Error: Could not find or load main class MysqlConnect
You shouldn't be defining a classpath for your programs using system variables. Standard way is to use the command line -cp or -classpath option. Take a look at what java prints out if you run it with no arguments.
You will find this mentioned in this tutorial. It says:
The preferred way to specify the class path is by using the -cp command line switch. This allows the CLASSPATH to be set individually for each application without affecting other applications. Setting the CLASSPATH can be tricky and should be performed with care
Also, see how the default CLASSPATH environmetn variable has a . in it. If you still decide to add your classes in there, keep the . for other citizens and add your classes after a ;, don't just overwrite the whole value.
Here's a jdbc tutorial for beginners that could help you find your answer. If you skip to step 14 it gives an example of how the classpath is used. It is used as the first respondent is saying, by command line.
Hopefully this will help you in your particular situation. This tutorial is not database-specific so it will work with any type of database you are using.
ok atlast i got the solution it should be typed as
C:\Users\sarad mohanan\Desktop\rose>java -cp .;"c:\Program Files\MySQL\MySQL Server 5.5\mysql-connector-java-5.1.20-bin.jar" MysqlConnect
MySQL Connect Example.
Connected to the database
Disconnected from database
we have to add .; before the original path . holds default classpath. pravel veller had said it previously but i didn't understand it then
I would like to propose using a good tool like Eclipse. You can test the CLASSPATH indirectly and your environment by adding or removing jar files and libraries.
Obviously, the libraries in your default CLASSPATH is different than the one in your E drive. You may compare the files by knowing your CLASSPATH. In Windows, do "echo %CLASSPATH%".
Eclipse can help you by experimenting without rebooting or any annoying steps. And this stuff is not easy.
Crete o set environment variable if you use windows JAVA_HOME=E:\software\installed\java, and after append the Java bin directory %JAVA_HOME%\bin. Note that paths are separated from each other with semicolons (;) I hope help you. That's work for me !!!. I don't understand. What happen?.

Resources