Two project's, one compiles, the other gets error: package javax.servlet.http does not exist - javac

I know this is a common question, however my situation is a little different. I have two projects, the first doesn't use beans, the second does.
So when deploying the first project using: ant deploy-web it works, compiles no problem
When deploying the second project using: ant deploy-ear I get: error: package javax.servlet.http does not exist
Any ideas?

Related

MVC RazorGenerator - "Type (...) already defines a member called 'Execute' with the same parameter types"

I've been working on a big MVC Application and now i need to improve application's startup performance (which is bad +1min for the first load).
I installed RazorGenerator nugget and the extension too, but when i compile a lot of errors appear.
May this be caused by not specifying the Generator Type?
Because i didn't find their documentation very helpful about this.
Or maybe because i added the following directive to one of my views (_EditHelperPage.cshtml) because it was rendering as HelperPage instead of WebViewPage:
#* Generator: MvcView *#
After i remove this line and adding it to razorgenerator.directives, it throws me another error:
Edit
And if i search for a class/constructor with the same name, it find results in /obj/CodeGen/(...)
I found the problem.
Before i installed the VS Extension RazorGenerator (not the nugget!), i installed RazorGenerator.MsBuild which does the same as the extension but on build time (right?).
But why was it happening?
I think that the extension builds views before MsBuild, however they were doing the same and therefore creating duplicated .cs files
I just unistalled .MsBuild package and voilá, it works.

'MissingMethodException' in F# project

My unit test project has 'InternalsVisibleTo' access to the project I'm trying to test, but even though it compiles fine, when I run my tests, it fails with a MissingMethodException.
This bug is particularly nasty in that it only happens for some times. The one that was tripping me up was the F# list type, if I changed the signature to array, it was fine.
I eventually found the problem/solution here, which was that my test project was referencing FSharp.Core version 4.3.1.0, and the target project was 4.3.0.0
Setting them both to 4.3.1.0 fixed the problem for me.

Dagger 2 compile time error on CI

I've been using Dagger 2 recently and just did some work with scopes in my android project, adding scopes for Activities. While everything runs, builds and tests fine on my own machine. I'm getting a compile error on Jenkins CI.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Adverts:compile***DebugJava'
.java.lang.ClassCastException: java.lang.String cannot be cast to javax.lang.model.type.TypeMirror
This is strange because the build has worked fine up until now with Dagger 2 just with less code being generated. When I navigate to the generated sources some, but not all of the code is generated. It looks like it's crapping it out somewhere along the way. Both CI and my machine are using the same version of JDK.
Has anybody ran into issues with CI & Dagger 2 before?
For people in the future who encounter this error as well, it's most likely because of a class you deleted or a class that doesn't exist that is being referenced in your Module.
I had the exact same error while compiling when I had code like this:
#Module(includes = {
AModuleThatDoesntExist.class
})
public class YourModule {
}
So what I'm saying is: if you encounter this error, check your Dagger modules and bootstrapper code, there's probably some invalid code there.
As to why it works on your machine and not on the CI server: I don't know. I would guess it's because of some cache issue where the .class file of your deleted .java file is still present on your local filesystem, so Dapper can find it, but it doesn't exist on your CI server. If you can still reproduce the issue, maybe you can try running "Rebuild" and see if the errors occurs locally too.
Whatever happens Dagger 2's annotation processor shouldn't throw an exception so assuming that is coming from the Dagger 2 annotation processor it might be worth raising a bug if you can create a reproducible example, preferably a simple one.
As others have suggested do a clean build (remove the classes yourself to make sure that they are all gone) and check for differences between your machine and the CI one.

"Groovy:unable to resolve class ..." (import error in LoginController.groovy)

I am trying to use the ":spring-security-core:2.0-RC2" (using Grails version 2.3.1), but have my own LoginController.groovy. Following Burt's notes (here and here), I copied the LoginController.groovy from the original location at "myapp\target\work\plugins\spring-security-core-2.0-RC2\grails-app\controllers\grails\plugin\springsecurity" to my project location at "myapp\grails-app\controllers\com\company". Now I get a bunch of import error messages like "Groovy:unable to resolve class ..." (I have attached am image below showing all the imports giving errors). How do I take care of these errors?
Sorry if this is a trivial question (still getting used to Grails), and thank you for the help!
It looks like GGTS/STS isn't entirely aware that the plugin is installed, since those classes are from the two jars that the plugin depends on. Try right-clicking the project node in the tree and running Grails Tools > Refresh Dependencies. If that's not enough, run Project | Clean to force a full recompile.

Grails compiler keeps running again and again, possibly because of syntax error

I got this problem several times: Sometimes when I command : grails run-app, the compiler just running again and again, even though I change nothing after that. It looks like:
Running Grails application..
Server running. Browse to http://localhost:8080/LiningTest
[groovyc] Compiling 1 source file to E:\workspace\W1\LiningTest\target\classes
[groovyc] Compiling 2 source files to E:\workspace\W1\LiningTest\target\classe
s
[delete] Deleting directory C:\Documents and Settings\Long\.grails\1.3.6\proj
ects\LiningTest\tomcat
Running Grails application..
Server running. Browse to http://localhost:8080/LiningTest
[groovyc] Compiling 1 source file to E:\workspace\W1\LiningTest\target\classes
[groovyc] Compiling 2 source files to E:\workspace\W1\LiningTest\target\classe
s
[delete] Deleting directory C:\Documents and Settings\Long\.grails\1.3.6\proj
ects\LiningTest\tomcat
Running Grails application..
Server running. Browse to http://localhost:8080/LiningTest
[groovyc] Compiling 1 source file to E:\workspace\W1\LiningTest\target\classes
...
The compiler succeeded when "Server running", but then it automatically re-compile some files (I don't know which file), and run again, and then recompile again...
I have met this problem once when I have a syntax error
constraint {
number(min:0.50) // the right way is "min: 0..50"
}
The question is why this problem happened, and how I can find the cause of the problem. (I guess that I miss some comma/dot somewhere, but now it's hard to find, because of there's no error message!)
UPDATE: Now I see the problem is that I don't follow the folder structure rules when placing non-domain class in src/groovy.
The first thing to do is to run:
grails compile -verboseCompile
That will at least tell you what the problematic file is.
Apparently this can happen when
The package name does not match the directory (under your source root) the file is in.
The class name is different from the file name.
Have a look at this:
http://www.pubbs.net/201007/grails/58100-grails-user-groovyc-causing-grails-to-loop-.html
And Peter Ledbrook mentioned it in his talk at the Groovy & Grails Exchange last week (at 29:20):
http://skillsmatter.com/podcast/java-jee/talk-by-peter-ledbrook
I can confirm the strange behaviour.
I had two groovy classes in src/groovy belonging to some package com.acme.foobar.
Although for a while all went fine and Grails even compiled the classes and started the application (which was useable without exceptions) - at some point it did not stop to compile, start, delete all over again.
After I put the classes in src/groovy/com/acme/foobar the behaviour stopped instantly.
The remark of using grails compile -verboseCompile was useful. At least you can check if everything is allright as follows:
Call grails compile twice:
If there is the same output of classes being compiled the second time you compile there will be a problem.
If grails splutters something like this:
Running script /Users/ug/Software/grails/scripts/Compile.groovy
Environment set to development
returning to prompt directly afterwards - the problem should be gone.
Ok, it's a strange behavior with Grails that a senior programmer just told it to me:
I put one of my non-domain class in src/groovy/warm.groovy. But the warm.groovy belongs to the package "liningtest". It seems that I must put "Warm" class inside "src/groovy/liningtest/warm.groovy" instead.
There's an implicit rule here:
The non-domain class put in src/groovy, must follow the folder structure that is alike to the package structure.
That's really a strange behavior, because it doesn't report any errors, just repeat compiling again and again... And for the most strange part, that works for me in the first time!

Resources