play framework unable to run an existing project - java

I'm a rookie developer trying to run an application using play framework. I've followed the tutorial and can successfully create a new project.
However when I go to the directory that has the project I'm supposed to work on and enter the play command I get the following error:
[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: clean)
[error] play
I have very little knowledge regarding the framework and don't know where to start correcting my mistake. Any suggestions ?

You have to run the play command this way:
./play cmd [app_path] [--options]
where in case of running a project, it is
./play run /path/to/projectname

I am facing this problem in the context of sub projects.
This is what worked for me.
Code:
import sbt._
import sbt.Keys._
object ApplicationBuild extends Build {
val helloWorldProj = Project(id = "HelloWorld", base = file("helloworld"))
val appName = "WebApp"
val appVersion = "1.0"
val appDependencies = Seq()
val webAppProj = PlayProject( appName, appVersion, appDependencies, path = file("webapp"), mainLang = PlayProject.SCALA)
.dependsOn(helloWorldProj)
.aggregate(helloWorldProj)
}
On running the play command, I get the following error:
Error:
[info] Set current project to HelloWorld (in build file:/D:/EclipseProjects/HelloWorldPlayMultiProject/)
[error] Not a valid command: play (similar: last, alias, loadp)
[error] Not a valid project ID: play
[error] Not a valid configuration: play
[error] Not a valid key: play (similar: play-hash, play-dist, play-conf)
[error] play
[error] ^
Solution:
Now, if I rename helloWorldProj as zhelloWorldProj, it works!
In this case, play sets the active project to WebApp.(Since webAppProj variable name alphabetically comes before zhelloWorldProj)
I can then change the active project to HelloWorld by giving the command project HelloWorld.
I think this has something to do with how sbt finds the Project objects using reflection.

Need to have more detail about your environment (OS, Play version etc) but if you are getting errors that play is not a valid command, my first course of action would be to check that the path to play.sh (I assume you are using non-windows) is included in your system path?

I delete all directories in the project folder and it works. Do not delete files (build.properties, Build.scala and plugins.sbt)

The problem was the version difference of play. The project I was suppose to work on was developed in play 1.2 where as I installed the version 2.0 .
By the way, working with 2.0 on a project developed by version 1.2 is possible, but I strongly recommend not to do it that way as there are problems on the later stages as well.

Depending on the language you're using, make sure one of the following is in your build.sbt file:
play.Project.playJavaSettings
play.Project.playScalaSettings

I also got the same problem! What happened was in my /user/xxx/project folder there were old projects from 1.x version. Deleting that folder worked for me!

Related

Compiling Java with VS Code, getting "restriction on required library" error message

I have seen this question asked and answered a few times for Java being compiled in Eclipse. In my case, I don't have Eclipse. I want to get my project compiled using VS Code. I'm hoping there is a file I can create or edit to override this error message:
Access restriction: The type 'Pair' is not API (restriction on
required library 'C:\Program
Files\Java\jdk1.8.0_201\jre\lib\ext\jfxrt.jar')Java(16777523)
Any help appreciated.
In my project the .settings\org.eclipse.buildship.core.prefs contains
connection.project.dir=../..
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
PS My project uses gradle.
try this:
1.find .settings\org.eclipse.jdt.core.prefs file in your project
2.change org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
to org.eclipse.jdt.core.compiler.problem.forbiddenReference = ignore
change file ./.settings/org.eclipse.jdt.core.prefs with
org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore
run the command
mvn eclipse:eclipse

How do I use app.yaml with Java runtime in App Engine v1.9.18?

I followed the documentation for using app.yaml with Java which claims that this should work and that it will generate web.xml and appengine-web.xml automatically. However, it doesn't seem to work and it doesn't mention which tool will generate the files.
I first tried a mvn clean install which errors out because the .xml files are missing:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project roger-analytics: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1]
I then tried to run the local development server:
$ gcloud preview app run app.yaml
ERROR: (gcloud.preview.app.run) An error occurred while parsing file: [/Users/blixt/src/roger-api/module_analytics/app.yaml]
Unexpected attribute 'servlet' for object of type URLMap.
in "/Users/blixt/src/roger-api/module_analytics/app.yaml", line 7, column 12
(I get the same error from dev_appserver.py . by the way)
It appears that app.yaml isn't supported after all. Am I missing something, or was support removed without updating the documentation?
Here's my app.yaml file, which is intended to run as a module in my Google Cloud App Engine project (along with other modules that have Python and Go runtimes):
module: analytics
runtime: java
api_version: 1
handlers:
- url: /*
servlet: im.rgr.roger.RogerAnalytics
login: admin
secure: always
system_properties:
java.util.logging.config.file: WEB-INF/logging.properties
There are several issues at play here. I'll describe various facts that group together to create a constellation of SDK edge-case goodness (this information is current as of SDK 1.9.21):
In order to deploy using the Java SDK's appcfg.sh, you'll need to have app.yaml inside the war/WEB-INF/ folder.
appcfg.py complains Unexpected attribute 'servlet' for object of type URLMap..
gcloud preview app deploy uses appcfg.py (or the same codebase) and therefore also complains in the same manner
So, in conclusion, you'll need to use appcfg.sh

Error: Package does not exist

I have a little problem in Eclipse with a package . The error output is Package (name of package ) does not exist .
I have a package called de.baimos.blueid.lockserver.demo.exec . But Eclipse is looking for a package called de.baimos.blueid.lockserver.api.exec . This package is can be found in my Project nowhere .
My current situation is this: I have two projects that work as a project. Now you can in Eclipse under Properties - Add a project to a different > Project -> Java Build Path . But if I want to run Maven install I get the error above. At first I thought it would be in the pom.xml file . But I noticed that it is not possible to merge two pom.xml files. My project was to make the inheritance , however, by themselves , whom I put them together leads . Did anyone of you ever such a problem , or can someone help me ?
Thanks in advance for your help .
That is the error:
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[3,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[4,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[5,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[6,44] error: package de.baimos.blueid.lockserver.api.event does not exist
[ERROR] /home/test/workspace/HeartbeatService/src/main/java/de/baimos/blueid/lockserver/demo/exec/DemoCommandExecutionEventListener.java:[8,59] error: cannot find symbol
Maven can't see what you specify in Eclipse's Java Build Path; it's a command line tool that runs outside / without Eclipse.
Instead, you have to do mvn install in the first project.
Then you can add a dependency to this project in the second project's POM.
Maven will then make sure that Eclipse add the first project to the classpath as well without manually changing the build path in the UI.

Eclipse Error: 'AndroidDataBase' is missing required Java project: 'GoogleMaps'

I am developing an app named "AndroidDataBase".
while am trying to compile in eclipse I am getting this error
Error executing aapt: Return code -1073741819 AndroidDataBase line 1 Android ADT Problem
and
Project 'AndroidDataBase' is missing required Java project: 'GoogleMaps' .
Where GoogleMaps is another androidApp.
I have the GoogleMap.java in AndroidDataBase "Src" folder.
I have tried clean build ,restarting eclipse sort of things ,still no result
Why am i getting this error ,and how to resolve it?
Thanks in advance
I have added the GoogleMap.java
the issue is activity_googlemap its not getting identified
although it is present in res/layout
You need to add the "google-play-services_lib" project as a library project. You will find it in your_sdk_root_path/extras/google/google_play_services/libproject/google-play-services_lib
Set your Project Build Target to Google API Build. From right click on project and go to Preference>Android tab>Select Target build of Google API.
I Dint installed the "Google Play Service" present in the SDK Manager .
Once I did that ,all I need is to follow the solution of # Joan P.S(Stated above I have accepted the ans,thanks to him.).
After that I have to add the Google MAP project(import it to the current work space(another app )) in Properties->Java Build Path->Projects .
That's how it got solved

IntelliJ does not find native libraries for OpenCV when adding jar as a dependency for Play project

I am currently working on a Play 2.1 project, in which requests to the web-service will handle downloading user-supplied images, re-sizing and re-cropping them, and also filtering out known bad photos (for example, we don't want users to upload company logos). We are trying to use OpenCV to handle the back-end work, but I can't seem to get IntelliJ to add the OpenCV jar in a way that works with the java project.
I've been able to build OpenCV from source, without issue. This left me with the following folder:
/home/charles/opencv/release
Inside this folder, I have three files of interest:
bin/opencv-246.jar
lib/cv2.so
lib/libopencv_java246.so
If I try to add the jar file to IntelliJ as a new Java library, it seemingly finds all the classes/methods, and I can write code using the auto-complete. I can also click on the respective classes or methods, and it brings me to the right files.
However, when I try to run the Play project, I get this error:
[info] Loading project definition from /home/charles/Github/ImageProject
[info] Set current project to ImageProject (in build file:/home/charles/Github/ImageProject/)
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
Server started, use Alt+D to stop
[info] Compiling 1 Java source to /home/charles/Github/ImageProject/target/scala-2.10/classes...
[error] /home/charles/Github/ImageProject/app/controllers/Application.java:7: error: package org.opencv.core does not exist
[error] import org.opencv.core.Core;
[error] ^
I've also tried adding a copy of the jar file directly into the project (so putting opencv-246.jar into ImageProject/lib), and then adding the java library from that location instead. But that just leaves me with a different error:
java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
I suspect part of the problem may be related to the native libraries that the Java OpenCV wrapper uses (file 2 or 3 above). In Eclipse, when you add a jar file, you can explicitly set the native library location, which makes OpenCV work fine. I've read suggestions of using this to fix the problem:
-Djava.library.path=/home/charles/opencv/release/lib
But that doesn't seem to work (though maybe I'm setting it in the wrong place? I've tried setting it as a JVM parameter in the run config for the project, and in the IDE settings, but neither seem to be used or respected).
Note: Just to clarify again, this is a Play2 project, not an Android project. There seems to be some Android-specific help out there, that isn't relevant in this case.
This feels like it should be a rather straight forward thing, but I've been spending several days trying to find an answer at this point, and still have nothing. Any ideas?
Additional details:
I also tried following the "Running SBT samples" of the OpenCV documentation here:
http://docs.opencv.org/doc/tutorials/introduction/desktop_java/java_dev_intro.html
And I also get a similar error:
charles#charles-VirtualBox:~/JavaSample$ sbt run
[info] Loading project definition from /home/charles/JavaSample/project
[info] Set current project to JavaSample (in build file:/home/charles/JavaSample/)
[info] Compiling 1 Java source to /home/charles/JavaSample/target/scala-2.10/classes...
[info] Running HelloOpenCV
Hello, OpenCV
[error] (run-main) java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
java.lang.UnsatisfiedLinkError: no opencv_java246 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1856)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at HelloOpenCV.main(HelloOpenCV.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
[trace] Stack trace suppressed: run last compile:run for the full output.
java.lang.RuntimeException: Nonzero exit code: 1
at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 2 s, completed Jul 17, 2013 5:11:39 PM
When you want to use OpenCV or any other native libraries on Playframework, You MUST run your application with "play start" command, not "play run".
"play run" command starts your application in development mode and "play start" command starts in production mode. I don't know every difference between them but one obvious thing is ,
Only when we use "play start", a new JVM for you application is launched and it loads native libraries you specified by System.load("/absolute/path/to/your/so/or/jnilib/inOSX/not/dylib/filename.jnilib");
How to load native lib is following.
Create Global.java which has empty package name. (refer this link )
public class Global extends GlobalSettings {
#Override
public void beforeStart(Application app) {
// TODO Auto-generated method stub
super.beforeStart(app);
String libopencv_java = "/Users/yoonjechoi/git/myFirstApp/target/native_libraries/64bits/libopencv_java246.jnilib";
System.load(libopencv_java);
}
}
then you can use classes of OpenCV in your Play application's controllers.
System.loadLibrary("opencv_java246") doesn't works. I don't know why. I don't have time to dig why. -_-;
Please give hints if you know why.
for windows 64 bit set
-Djava.library.path=/full-path/OpenCV/build/java/x64
I would have used the lib/libopencv_java246.so
It's always important to map the .so file to build library. It's suppose to work out of the box

Categories

Resources