I'm new to buildr, so I might be missing something obvious.
According to this page, it should be fairly simple:
Download explode.rb
At the top of your buildfile, add the following:
require 'explode.rb'
Define explode task on your web application:
package(:war).explode :target => "jetty/webapps/myApplication"
Run the task
buildr myApp:explode
However, but I can't get it to work. If I just go through the steps in that article, I get the following error:
RuntimeError : Don't know how to build task 'myApp:explode'
I tried all sorts of combinations, but nothing worked.
Turns out the instructions were 100% correct. My problem was that myApp was a sub-project, and I needed the fully qualified name when running the task, i.e.:
buildr myProject:myApp:explode
I was confused because just running buildr myApp worked fine.
Related
My project is a Gradle dependent JavaFX project using Java JDK 11. The project was made using the default structure of a Gradle project. So under src it has "main" and "test", each consisting of a "java" and a "resource" directory.
For setting up a CI pipeline with Jenkins it is a requirement that gradlew test runs all tests in the same way my IDE (IntelliJ) so far has. The funny thing is, I have not been able to get this to work after hours of trying.
In the IntelliJ run configuration it tests "all in package", within the .test package, and this works just fine (click for screenshot) Below are all the relevant parts of the build.gradle file, please note that I have left out all unrelated parts for simplicity.
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.1.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.1.0'
}
test {
useJUnitPlatform()
}
application {
mainClassName = 'FP.EDM.main/edm.Main'
}
Whenever I run the gradlew test command I get the following two errors:
java.lang.RuntimeException: Unable to parse --add-opens <module>/<package>: FP.EDM.main/
Could not write standard input to Gradle Test Executor 1.
java.io.IOException: The pipe is being closed
at java.base/java.io.FileOutputStream.writeBytes(Native Method)
at java.base/java.io.FileOutputStream.write(FileOutputStream.java:354)
at java.base/java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:81)
at java.base/java.io.BufferedOutputStream.flush(BufferedOutputStream.java:142)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.forwardContent(ExecOutputHandleRunner.java:67)
at org.gradle.process.internal.streams.ExecOutputHandleRunner.run(ExecOutputHandleRunner.java:52)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
at java.base/java.lang.Thread.run(Thread.java:834)
Another approach I have tried is to use the useJUnit() command instead of useJUnitPlatform(). At first sight this seems to work perfectly fine however when I use this no tests are found at all. My assumption is that the default module for tests is not set correctly. However I have found no way to set this or no mention of this anywhere online. Please let me know what your thoughts are :)
PS. I would much rather not downgrade to JUnit 4.x since that would require me to rewrite all these (working) tests.
Alright I solved the issue, I'm not quite sure what exactly caused it but it had something to do with the module-info for both the main and test modules. I decided to remove both for the time being and it runs like it should.
Edit:
After days of looking around I got it figured out at last. Adding a module-info.java encapsulates a module and it's dependencies. Because this project applies the gradle-modules-plugin I wouldn't recommend using the same plugin again as it could cause issues though I have not experimented with this myself.
What is the way to go then? Well there are two options:
-Ignore the module-info.java > this can be done in the build.gradle file, for an example of that solution have a look at this
-Specify a module-info.test > this is a way to apply certain dependencies, mine looks like the following:
--add-modules
org.junit.jupiter.api
--add-reads
FP.EDM.main=org.junit.jupiter.api
Please do keep in mind: this file format should go in the root of your source, all my test files were in a different directory in the root, as I didn't get it to work in the root (though that could just be me).
For further reading there is this Git issue which helped me solve it in the first place or this excellent blog by Sormuras which explains a lot
I'm making a runnable jar for my project, and i keep getting this error when it starts generating the benchmark report:
Exception in thread "main" java.lang.IllegalStateException: The websiteResource (twitterbootstrap/css/bootstrap-responsive.css) does not exist.
at org.optaplanner.benchmark.impl.report.WebsiteResourceUtils.copyResource(WebsiteR esourceUtils.java:57)
at org.optaplanner.benchmark.impl.report.WebsiteResourceUtils.copyResourcesTo(WebsiteResourceUtils.java:33)
at org.optaplanner.benchmark.impl.report.BenchmarkReport.writeHtmlOverviewFile(BenchmarkReport.java:738)
at org.optaplanner.benchmark.impl.report.BenchmarkReport.writeReport(BenchmarkReport.java:287)
at org.optaplanner.benchmark.impl.DefaultPlannerBenchmark.benchmarkingEnded(DefaultPlannerBenchmark.java:315)
at org.optaplanner.benchmark.impl.DefaultPlannerBenchmark.benchmark(DefaultPlannerBenchmark.java:109)
Everything else works fine since i added "resources/" infront of the drools and the benchmarkConfig paths.
Since there are a few more resources just for the benchmark, i probably would need to do the same for them also.
How can i get access to the resources for the benchmarks?
Sounds like you're building from source with an IDE (Eclipse/IntelliJ/NetBeans/...) and your project isn't set up correctly to also copy *.css files as classpath resources (so it has a specific exclude for css somewhere).
With a modern IntelliJ IDEA version, opening the pom.xml file, this definitely doesn't happen. With a modern Eclipse/NetBeans version, I'd presume the same.
I have developed a little program for myself. After testing and
finishing it locally I now wanted to put it on my server.
I get this error:
Compilation error The file /app/controllers/Links.java could not be
compiled. Error raised is : Secure cannot be resolved to a type
It is thrown at this line:
#With(Secure.class)
In the Class Links I have:
import play.mvc.With;
import controllers.*;
#With(Secure.class)
public class Links extends CRUD {
}
I have installed play 1.2.2 on my server. Play is running probably. I
type in the terminal "play start appname" and opened serverIp:9010 to
see this error. If I type "play precompile appname" everything seems
to work.
In the subfolder /modules of the app I have two text files, one "crud"
and one "secure" which point to the modules location on the server. I
also have defined the modules in dependencies.yml like this:
require:
- play
- crud
- secure
In the application.conf I have a Production definition for my server
with the proper Server-ID like this:
%server1.application.mode=PROD
Any idea why this isn't working?
I have solved it. For future reference:
I had an old process of play running. Found it with ps -aux and then kill PID. After that I started the application again with play start.
It's now running fine :)
Thanks for you help!
Declaring the secure module in dependencies.yml file is the first step.
Next you have to type the shell command "play dependencies" in order to resolve them.
Just have a glance on the documentation here : http://www.playframework.org/documentation/1.2.2/dependency#Theplaydependenciescommand
Have fun with Play!
Sometimes you have to refesh the classpath settings by using play eclipsify again. (depends on the IDE you are using)
I had to insert this line to application.config
module.secure=${play.path}/modules/secure
I had the same problem in my development environment, but not in my production server. I tried to solve by the module documentation, the accepted answer here, and many others with no success.
My solution was to download again play framework (1.2.7) and replacing it in the path where I installed first.
Hope this can guide someone else with the same issue.
Regards.
I might be doing something wrong, cuz I'm using buildr for not so long, so all comments are welcome.
My project structure is:
define :proj do
define :web do
task :run do
# runs the web part of the project in a jetty
end
end
end
now if I want to start my project I have to type
buildr proj:web:run
I'd like to type simply
buildr run
instead. How do I achieve that?
At the top level of your buildfile (i.e., outside of any defines), add
task :run => 'proj:web:run'
This defines a task named run whose sole prerequisite is the proj:web:run task.
You can also make the task a 'local task',
Project.local_task 'run'
which means that whenever you are inside the web directory, typing buildr run will look for a locally-scoped that of that name.
Note that Buildr 1.4.3 added a standard run task so you typically wouldn't need to make run a local task; see http://buildr.apache.org/more_stuff.html#run for details.
I have a Java (6) application which uses Hibernate (V3.3.2) to read data from HSQLDB, which i build and debug/run with Eclipse (V3.5.1), and it works fine.
I then created a GWT (V1.7) Servlet web app, copied my hibernate classes into it, and added the same User Libraries dependencies. However when i run the servlet and try to access a URL which invokes my code i get this:
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:152)
at xxx.daoimpl.DAOSession.initialise(DAOSession.java:40)
where DAOSession.java:40 is :
AnnotationConfiguration config = new AnnotationConfiguration ();
Googling for this error suggests i am missing slf4j-api.jar from the classpath, however if i look at the command line for the Debug properties i can see this jar there:
C:\java\jsedk_6\jre\bin\javaw.exe
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:54541
-Xmx512m -Dfile.encoding=Cp1252
-classpath
D:\dev\workspace\xxx\src;
D:\dev\workspace\xxx\resources;
D:\dev\workspace\xxx\war\WEB-INF\classes;
C:\java\eclipse\plugins\com.google.gwt.eclipse.sdkbundle.win32_1.7.1.v200909221731\gwt-windows-1.7.1\gwt-user.jar;
C:\java\eclipse\plugins\com.google.gwt.eclipse.sdkbundle.win32_1.7.1.v200909221731\gwt-windows-1.7.1\gwt-dev-windows.jar;
C:\java\hibernate-annotations-3.4.0.GA\hibernate-annotations.jar;
C:\java\hibernate-annotations-3.4.0.GA\lib\ejb3-persistence.jar;
C:\java\hibernate-annotations-3.4.0.GA\lib\hibernate-commons-annotations.jar;
C:\java\hibernate-distribution-3.3.2.GA\hibernate3.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\antlr-2.7.6.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\commons-collections-3.1.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\dom4j-1.6.1.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\javassist-3.9.0.GA.jar;
C:\java\hibernate-distribution-3.3.2.GA\lib\required\jta-1.1.jar;
C:\java\hibernate-validator-4.0.1.GA\hibernate-validator-4.0.1.GA.jar;
C:\java\hibernate-validator-4.0.1.GA\lib\validation-api-1.0.0.GA.jar;
C:\java\hibernate-validator-4.0.1.GA\lib\log4j-1.2.14.jar;
C:\java\hsqldb\lib\hsqldb.jar;
C:\java\restlet-jse-2.0m5\lib\org.restlet.jar;
C:\java\restlet-jee-2.0m5\lib\org.restlet.ext.servlet.jar;
C:\java\restlet-jse-2.0m5\lib\org.restlet.ext.xml.jar;
C:\java\slf4j-1.5.8\slf4j-api-1.5.8.jar;
C:\java\slf4j-1.5.8\slf4j-log4j12-1.5.8.jar
com.google.gwt.dev.HostedMode
...
If i open the jar i can see the LoggerFactory class in there.
Any idea why it isn't being found by the class loader?
Edit 1: If try to access org.slf4j.LoggerFactory from my code, Eclipse compiles it ok, but i get the same error at runtime.
Edit 2: If i add a Test class with a main which calls the same code and run it, it works. So this classpath problem seems specific to the Servlet.
thanks,
jon
It seems that copying the two slf4j jars to the war/WEB-INF/lib sub-project/dir fixed the problem. I'm not really sure why i should need to do this for these two jars and not for all the other Hibernate, Restlet etc jars that the project also uses, though i suppose for consistency i will do that anyway - i guess it will make deployment easier as well.
If someone can provide some sort of explanation as to why this worked and why exactly i need to do it i will select it as the "correct" answer, otherwise i'll select this one.
Can you please reconfirm that you have at least two slf4j.jar files in the classpath, the slf4j-api.jar and exactly one implementation, such as slf4j-jdk14.jar?
You must not have multiple sflj4-implementations in the classpath.
You have a runtime dependency issue so everything compiles fine but the dependency is in your jars. You need to visit the Hibernate site and look at the compatibility matrix and make sure you are matched up correctly then check the dependencies for annotations and core. You log4J jars look fine so it's definitely some quirk.
If it works in Eclipse then logically it's definitely some diff between the 2 runtimes (eclipse and non-eclipse), if the matrix checks out fine then see if you can factor out the commonalities in the 2 then work out the differences -- your answer should be in there.
I had a similar issue except I was using Tomcat and the NoClassDefFound error was on the juli logger. I fixed it by removing the Tomcat dependencies from my classpath when running in hosted mode because hosted mode embeds a Tomcat server that was conflicting. So I would see what happens if you remove some or all of the restlet jars from your classpath to see if they conflict.