Play 2.2.0 - How to create a war file - java

I am using play 2.2.0 for my application so inorder to host the application i need to create a war file so i can host in my Tomcat7 server. So is there any method to
Clean and Build as we have options in netbeans with console.
Create war file so i can host.
The method to create a war file as in normal jsp hosting i paste all my class files in WEB_INF folder but here how can i do please tell the procedure. I just gave few try this i have mentioned below i know i am wrong please show me the right way.
F:\Play_workspace\ThemePractice>play war
[info] Loading project definition from F:\Play_workspace\ThemePractice\project
[info] Set current project to ThemePractice (in build file:/F:/Play_workspace/Th
emePractice/)
[error] Not a valid command: war (similar: start)
[error] Not a valid project ID: war
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: war (similar: watch, run, apiUrl)
[error] war
[error] ^

There is a plugin for creating a war file, however Play 2.2.x is currently not supported.
Although a branch exists on Github for this feature, it looks like it is still being worked on. You'd have to contact the maintainers for a time line.
Update: It is now possible to create a war file with Play 2.2.x, see Paul D. Eden's comment.

Play 2.1.4 onwards, support for packaging into a war file has been withdrawn. There is a workaround for the same which can help you in generating war file. You fool the compiler and let it think that we are using earlier version of Play. For details refer to the following link :-
Create War from Play 2.2.1 application
It is working till day for me :)

Add addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.2-beta4") to your plugins.sbt
Add the following to your build.sbt
import com.github.play2war.plugin._
libraryDependencies ++= Seq(
"com.github.play2war" % "play2-war_2.9.1" % "0.8.2"
)
Play2WarPlugin.play2WarSettings
Play2WarKeys.servletVersion := "2.5"
Now you can freely use the "play war" command.

Related

Spring boot on IntelliJ

this is my first time ever working with a framework, I decided to learn Spring Boot to create a web app project.
I have followed some tutorials, and the steps were (for most of the videos):
go to start.spring.io, add the "Spring Web" dependency, select Maven project and then download the zip file.
import the project on IntelliJ as a Maven project.
But the problem is that, as shown in the screenshots:
it says: Cannot resolve symbol 'springframework'
screenshot 1
and as for the POM file,
"Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.5.2 from https://repo.maven.apache.org/maven2 was cached in the local repository"
as well as: Project '...' not found
Dependency '...' not found
Plugin '...' not found
screenshot 2
Please let me know, what steps did I miss.
Thank you
Make sure that you can access "https://repo.maven.apache.org/maven2". And check the HTTP proxy settings from Preferences | Appearance & Behavior | System Settings | HTTP Proxy. Select No proxy if you don't need it for accessing the Maven repo. Also, try to disable the downloaded 3rd party plugins temporarily and restart your IDE.

Sonar analysis abort because 'No files nor directories matching 'target/classes'

I'm performing an analysis with Sonar but I get the following error:
Error during SonarQube Scanner execution
java.lang.IllegalStateException: No files nor directories matching 'target/classes'
In my project I've the target directory but no classes directory or files, what should be in there for the analysis to work?
One of the reasons might be that Sonar cannot find that directory if you do analysis before building your project.
The target/classes directory does not exist before you started building the project using maven.
Try this value to workaround:
sonar.java.binaries=target
or
sonar.java.binaries=.
Sometimes some modules could not generate sources, for example, working with Maven, those modules packaging as 'pom'.
To avoid sonar analysing them, specify in your sonar.properties the property sonar.modules with the ones are generating sources.
I'm sure that you figured this out already. However, here's what you need to do for Java projects built using Maven.
If you're using the path "**/target/classes" then let's assume that you're using Maven for your builds. You would perform a "mvn clean package" for your Sonarqube Scanner to work.
Once you have used maven to compile and package into the standard directory ("./target/classes") then just pass the appropriate setting to the scanner (either through a configuration file or the command line). An example of passing through the command line is below.
${scanner_home}/bin/sonar-scanner
-Dsonar.login=<SONAR KEY>
-Dsonar.projectKey=<PROJECT KEY>
-Dsonar.branch.name=<BRANCH_NAME>
-Dsonar.branch.target=<RELEASABLE BRANCH>
-Dsonar.sources=./src
-Dsonar.java.binaries=./target/classes
Notice that I'm using a relative path for the sonar.sources and sonar.java.binaries settings. I do this in a Jenkins build pipeline and made this configurable since I also build PHP and use Composer, Gulp, npm, and other tool in my build process. (If you're using the SonarQube Scanner for Maven, then you would put this into a property file.)
for the poor lost soul who finds themselves on this thread, you may encounter this error when migrating from gradle 4.x to 5.x as the classes folder is renamed from classes to app_classes and it's no longer variant/flavor it's variantFlavor - you can verify by building your app and looking in the build folder
I had to change this sonarqube property in my build.gradle
property "sonar.java.binaries", "build/intermediates/app_classes/betaDebug,build/tmp/kotlin-classes/betaDebug"
The Answer from #bsaunter works.
I have to add that you may encounter this error also when migrating from gradle 5.x to 6.x,
got to your build/intermediate/javac/debug folder and look what is generating sonarqube, the name of the folder could be "classes"
Look for this property "sonar.java.binaries" on wherever file in your project folder and replace the value for the correct generated folder by sonarqube.

How to identify and build a JBoss java application from 2007?

I have a java application written in 2007-2010 that I need to build and run.
I am unable to open it in netbeans or eclipse.
Some identifying features of the source code:
It has a maven.xml and project.xml file (not pom.xml) in root
It has a jndi.properties, launch.properties and project.properties file in root
it has a .project and .jupiter file in the root directory
It is currently running in prod in a Jboss container
Are these indicators of some application framework from the late 2000s that someone can identify?
I am hoping to be able to open it in an IDE and build it.
It's a Maven 1 architecture.
[project.xml] Project Object Model (POM) definition
[maven.xml] Custom build scripts
[project.properties] general build settings
[build.properties] local build settings
Here you can see some more information and how to migrate it to Maven 2: Maven 1 to Maven 2
And here is some information on Maven's website about Maven 1: Quick start to Maven 1
Notice that it isn't supported anymore.
.project possibly indicates it's been built with Eclipse
.jupiter probably indicates that they used the code reviewer plugin Jupiter
All that said, I believe you could import it as an Eclipse project. Just pay attention on which Java version to use and which Eclipse and Maven as well.
I'd strongly recommend you to migrate to a newer version of Maven, but I also know how legacy software can be impacted by such migration, so it's up to you which way to go through.

Play 2.1.1 building dependencies

I'm new to Play framework and working on a Java webapp using it. I understand to build play 2.1.1 applications, we need to use SBT.
Questions:
Is this the default build system for Play? Don't we have any Play framework commands which will build, test, resolve dependencies etc?
Can I use Play framework with Maven / Maven repository, or if i need to use SBT only, can I use SBT with Maven repository? Is this a good practice?
I tried installing SBT. Extracted the downloaded zip file and added the <SBT_HOME>\bin directory to Windows path variable. When I execute sbt command, I'm getting the following error:
The system cannot find the file C:\installations\sbt\bin\sbtconfig.txt. java.io.FileNotFoundException: C:\Windows\system32\config\systemprofile\.sbt\boot\update.log (The system cannot find the path specified)
Am I doing anything wrong in the installation?
Is this the default build system for Play?
Yes, sbt is the default build system for Play application.
Can I use Play framework with Maven / Maven repository?
Yes, by default, Play uses Maven2 repository and Typesafe repository. Here's the default resolver:
resolvers ++= Seq(
"Maven Repository" at "http://repo1.maven.org/maven2/",
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
)
If you need to find add a dependency, you can simply go to the Maven2 repository.
For example, this is the repository for Google Guice
http://mvnrepository.com/artifact/com.google.code.guice/guice/1.0
You should be able to see a sbt tab, and find the code you need to write in Build.scala
libraryDependencies += "com.google.code.guice" % "guice" % "1.0"
There's no need to install sbt if you have installed play.
Simply cd to your project directory and run play.

IzPack error : Invalid base directory on jenkins-ci

first I am not sure if this question belong here or on serverfault.
I am using IzPack for our project. Everything is working fine on my local machine. Unfortunately on my jenkins I have the following error:
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] com.izforge.izpack.api.exception.CompilerException: Invalid base directory: /root/.jenkins/jobs/installer-izpack/workspace/target/staging
I am using:
<groupId>org.codehaus.izpack</groupId>
<artifactId>izpack-maven-plugin</artifactId>
<version>5.0.0-beta8</version>
The jenkins is installed on a debian squeeze.
When i log remotely on the server and verify the target/ directory the jar created from maven is there but there is no "staging" directory. In my honest opinion i think the problem is that jenkins is unable to create the stagging repository. As usual thank you for your time.
How I proceed: I am building some other jar (other jenkins job), then launch the installer to package everything. I don't know if this is enough information. If you need more information or if something is not clear enough please let me know.
This was a permission problem, be sure that jenkins have the permission to create the stagging directory.

Categories