Why is IntelliJ saying: Package secure does not exist? - java

I've setup my Play Framework 1.2.1 project to run from within IntelliJ using the instructions from the following post on Google groups:
http://groups.google.com/group/play-framework/msg/54cfe212cbae218e
However, following the tutorial at http://www.playframework.org/documentation/1.2.2/guide8, I'm getting the following error from the IDE:
/Library/WebServer/Documents/devschool.play/app/controllers/Security.java
package Secure does not exist
/Library/WebServer/Documents/devschool.play/app/controllers/Application.java
cannot find symbol class Secure
When I run the application with > play run, everything works fine, but I prefer running it from the IDE. Please note that the project was running perfectly from the IDE before I added the secure module.
Is there a way to fix this? I have a hunch it's to do with an external source, but not being a Java expert, I'm not entirely sure how to do this.
Can anyone please assist?

You should run the following commands:
play dependencies
play idealize
The first one will resolve the dependencies from the Secure module.
The second will update the IntelliJ "classpath" and the red lines/errors regarding the Secure module will disappear.

Okay, so the project is compiling and running okay after unchecking the "Make" checkbox from the Edit Configurations dialog box.
To get the IDE to find the code, you simply need to Attach Sources. On the Mac, press Command + ; and add the sources under the Libraries section.

From the second link you posted, there is a class called Security, it looks like this:
public class Security extends Secure.Security {
static boolean authenticate(String username, String password) {
return true;
}
}
Security extends Secure.Security, which is another class named Security in the Secure package. This error is saying that it cannot find the package Secure. Make sure you are including everything in your classpath properly.

Make sure you run play idealize after adding modules to dependencies.yml or adding dependencies to the application.conf(which is deprecated by the way)

Adding modules in application.conf is deprecated and shouldn't be used anymore. Instead use dependencies.yml and add
- play -> secure
So now my dependencies.yml looks like:
# Application dependencies
require:
- play
- play -> secure
I then ran:
play dependencies
play idealize
and there was a delay but eventually Intellij recognized the module. Not sure exactly if the last commands were necessary.
(Reposting an answer by Sascha Kleiber from the relevant page of the Play tutorial: http://www.playframework.org/documentation/1.2.4/guide8)

Related

Business Objects 'bcm.jar' error when exporting Java app

I have been working on creating a simple Java desktop app using the RESTful API for Business Objects and have run into an issue. Whenever I run my app in Eclipse in works fine; whenever I export it as a 'Runnable Jar' and select the Library handling option 'Package required libraries into generated JAR' it works fine. However, whenever I try to export it using the Library handling option 'Extract required libraries into generated JAR' I get the following error after running the app:
java.lang.NoClassDefFoundError: Could not initialize class com.businessobjects.bcm.BCM
I have the 'bcm.jar' file added under a 'res' Source Folder and have it added to the Build Path. At one point I added all the JARs under the 'SAP BusinessObjects' java folder, and external folder, but it still throws the error. The problem stems from this line of code:
enterpriseSession = CrystalEnterprise.getSessionMgr().logon(userID, password, CMS, auth);
Would anyone know why I am getting said error? I really want to use the Extract option as it will improve performance as my app becomes larger. Any help resolving this issue would be greatly appreciated :)
EDIT: I would be happy to provide clarification or further detail upon request!
Seems this was introduced in SP04 and SAP has no intent of fixing it as the RESTful API wasn't designed to be used with Desktop apps.
Have you included the cryptojFIPS.jar? Leaving it out can cause the error.

Implementing Eclipse WorkbenchAdvisor class for a eclipse plugin project

I am writing an eclipse plugin and I want to implement a "expiration checker" to disable my plugin once a certain date is reached.
I understand that in order to disable the bundle, I need to turn it into UNINSTALL state (FYI - I got this from here: http://www.eclipse.org/forums/index.php/t/210006/). Furthermore, I will need to do this in preStartup() by implementing the WorkbenchAdvisor class (from org.eclipse.ui.application.WorkbenchAdvisor)
I found this answer which has contains everything I need to know (https://stackoverflow.com/a/11726335/2851950) EXCEPT I couldn't find IApplication or WorkbenchAdvisor under my plugin.xml's dependencies page.
Do I need install additional plugins from somewhere? What I am missing here? Thanks

Unable to resolve reverse routing methods in IntelliJ

I'm following one of the play framework tutorials, but I'm getting compile errors whenever I try to use reverse routing. Firstly,
public static Result javascriptRoutes() {
response().setContentType("text/javascript");
return ok(
Routes.javascriptRouter("jsRoutes",
controllers.routes.javascript.Projects.add(),
controllers.routes.javascript.Projects.delete(),
controllers.routes.javascript.Projects.rename(),
controllers.routes.javascript.Projects.addGroup()
)
);
}
where the error shown in intelliJ is 'cannot resolve method javascriptRouter(java.lang.String, ?, ?, ?, ?)'
But also in the a unit test:
#Test
public void notAuthenticated() {
Result result = callAction(
controllers.routes.ref.Application.index(),
fakeRequest()
);
assertEquals(303, status(result));
assertEquals("/login", header("Location", result));
}
where it cannot resolve the index method.
Is this a problem with intelliJ, or am I missing something within play?
For the first part, here is the entry in my routes file:
GET /assets/javascripts/routes controllers.Application.javascriptRoutes()
and my controller, Projects, has got the defined methods.
File -> Project Structure
Select Sources in Right Pane
Add Source folder
target/scala-XXX/classes_managed
target/scala-XXX/src_managed/main
I was running into the same problem and found the solution here: https://github.com/playframework/Play20/issues/969
In short:
Create the directories javascript and ref under the controllers package
Run activator compile and now Intellij should get it // used to be 'play compile'
If you still got the errors try to run activator idea again // used to be 'play compile'*
Pulled from a link provided by #Markus Kittig. Great temporary fix. https://github.com/playframework/playframework/issues/1784#issuecomment-26345523
Synopsis:
Add target/scala-XXX as a managed source and remove the app controllers and views sources flag inside File->Project Structure->Modules->Sources. Then recompile.
Works on IntelliJ Ultimate 12.1.{4|6}. Created the play application with the command line interface and generated a project file using play idea. Used Play 2.2.0.
With IntelliJ 14.1 and Play 2.3.8 nothing of the above worked, but the advice from this mailing list worked. (Almost) blatantly copied:
Locate the target/scala-2.11/src_managed and target/scala-2.11/twirl
directories in the project view, then right click and Mark Directory
As -> Generated Sources (Root).
I bumped the scala version and obviously in newer versions of IntelliJ the Root word has been added. Also, you cannot select this from the Project Structure window, the option is not available. It is possible only through the Project pane in the main window. If it refuses to be marked as Generated Sources, try to unmark thetarget directory (Mark Directory As -> Unmark ).
For people using Play 2.4.x or above, it seems that Play no longer produces reverse routing files for javascript in src_managed et al.
Instead, you need to include scala-2.xx/routes/main directory as Sources.
This question was asked a year ago, but to answer for future queries by other coders, the problem is easily solved by adding a "play.Routes" path like this
public static Result javascriptRoutes() {
response().setContentType("text/javascript");
return ok(
play.Routes.javascriptRouter("jsRoutes",
// Routes for Projects
controllers.routes.javascript.Projects.add(),
controllers.routes.javascript.Projects.delete(),
controllers.routes.javascript.Projects.rename(),
controllers.routes.javascript.Projects.addGroup()
)
);
}
Ensure that you have the proper imports to the class:
import play.mvc.*;
import play.data.*;
I am using Idea 14.1.4 community edition, i managed to remove the index and route not resolved errors by right clicking on the target folder and marking it as not excluded. NB i run my project using the command line i can not find any run configuration in the ide.
I didn't find that folders in my PLay 2.8 build, so as it was a problem with IntelliJ I found an easier solution:
https://stackoverflow.com/a/70339356/2367237

Can I use Lombok with GWT in Development Mode?

I tried to follow the official instructions on running a lomboked GWT project in dev mode, but either I'm doing something wrong, or this doesn't work with current versions of GWT anymore?
The error I get is:
"The method setA(int) is undefined for the type MyData".
MyData is simple:
#Data
public class MyData {
private int a;
}
I'm specifying
-javaagent:/path/to/lombok.jar=ECJ
in my Eclipse Run Configuration (as a VM argument).
I also tried playing around with
-Xbootclasspath/p:/path/to/lombok.jar
, as well as starting dev mode from my ant file, etc.
The problem is, that I'm mostly just guessing how the whole setup should work, so instead of troubleshooting my poor attempts, I'd like to ask how a correct setup would look like?
You've probably got it working by now, but I can confirm it does work with GWT2.4 / Eclipse 3.7 . The only option needed is the -javaagent VM arg, and adding lombok.jar to the classpath/buildpath.
I think there's some issues when you first start to use it, to do with either the gwt-unitCache folder, and the war/WEB-INF/classes folder, clearing these is probably a good step when setting it up !
I think you've stumbled upon Issue 393. If that's the case you can try the latest edge release
Disclosure: I'm one of the project lombok developers.

JumpNote: main type is not specified

I'm doing my 1st steps in Android/GoogleApp, and I'm trying to explore the Jumpnote example:
http://code.google.com/p/jumpnote/
I was able to import the Android and Appengine projects to eclipse, but encountered the following issue when trying to run the Jumpnote-web part (android runs well).
When running the web part there is an error Main type is not specified which AFAIK implied that this project is missing a main function.
Is that indeed the case for jumpnote example and I need to manually add it, or am I missing something else?
Go to run Configuration
select JumpNoteWeb run configuration
You see in the main tab your project name and below it says main class
In the main class, put "com.google.gwt.dev.DevMode"
it should now run
*When I had this problem I also need to make sure that I put the src.shared folder into my project and had to change my build order so the app engine sdk, gwt sdk, and jre would build first

Categories