Grails - Including CAS client JAR dependency causes StackOverflowError, logging conflict? - grails

If I include compile "org.jasig.cas.client:cas-client-core:3.3.3" in my BuildConfig.groovy, I get a stack overflow as seen below. If I change compile to runtime the error goes away, but I do have dependencies at compile time as well as runtime.
It looks like some kind of circular reference related to logging, and just getting a stack dump like this isn't helpful. How would I fix it?
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at org.apache.log4j.Category.<init>(Category.java:52)
at org.apache.log4j.Logger.<init>(Logger.java:35)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
at org.apache.log4j.LogManager.getLogger(LogManager.java:42)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:43)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
at org.apache.log4j.Category.<init>(Category.java:52)
at org.apache.log4j.Logger.<init>(Logger.java:35)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:59)
at org.apache.log4j.LogManager.getLogger(LogManager.java:42)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:43)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:253)
| Error Error executing script RefreshDependencies: null

You may have multiple versions of log4j-over-slf4j in your dependency chain. If you run 'grails dependency-report runtime', you will see a list of libs that your app sucks in.
Using transitive=false will exclude all dependencies of the lib, but you could try 'exclude "log4j-over-slf4j"' as a more focused exclude if you have multiple slf4j versions in your dependency chain. E.g.,
compile("org.jasig.cas.client:cas-client-core:3.3.3") {
exclude "log4j-over-slf4j"
}

adding transitive=false made the error go away:
compile("org.jasig.cas.client:cas-client-core:3.3.3") {
transitive=false
}
I'm not clear what I needed to exclude specifically, or how anyone could have figured that out from the stack overflow.

Related

java.lang.ClassNotFoundException: org.apache.batik.dom.svg.SVGOMDocument

Following up many many questions and answers to use BATIK, I'm having trouble of fixing my error and I couldn't find anything that might help. And this question has no answer.
My problem is when I download the pdf on my application, the error occur(I even tried to include the jar):
java.lang.ClassNotFoundException: org.apache.batik.dom.svg.SVGOMDocument
In my jasper report I have this included:
<image>
<reportElement x="453" y="117" width="246" height="115"/>
<imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[net.sf.jasperreports.renderers.BatikRenderer.getInstance(new java.io.File("C:\\Project\\myProject\\web-app\\images\\tomcat.svg"))]]>
</imageExpression>
</image>
Basically, my BuildConfig.groovy is like this:
inherits("global") {
excludes 'xml-apis', 'xml-apis-ext', 'xercesImpl'
}
and my dependencies:
compile("org.apache.xmlgraphics:fop:0.94",
"org.apache.xmlgraphics:batik-transcoder:1.7",
"org.apache.xmlgraphics:batik-codec:1.7",
"org.apache.xmlgraphics:batik-awt-util:1.7",
"org.apache.xmlgraphics:batik-bridge:1.7",
"org.apache.xmlgraphics:batik-dom:1.7",
"org.apache.xmlgraphics:batik-gvt:1.7",
"org.apache.xmlgraphics:batik-svg-dom:1.7",
"org.apache.xmlgraphics:batik-svggen:1.7",
"org.apache.xmlgraphics:batik-util:1.7",
"org.apache.xmlgraphics:batik-xml:1.7",
"org.apache.xmlgraphics:batik-anim:1.7",
"org.apache.xmlgraphics:batik-css:1.7",
"org.apache.xmlgraphics:batik-ext:1.7",
"org.apache.xmlgraphics:batik-js:1.7",
"org.apache.xmlgraphics:batik-parser:1.7",
"org.apache.xmlgraphics:batik-script:1.7",
"org.apache.xmlgraphics:xmlgraphics-commons:1.2",
"commons-logging:commons-logging:1.0.4",
"org.apache.avalon.framework:avalon-framework-api:4.3.1",
"org.apache.avalon.framework:avalon-framework-impl:4.3.1",
"xalan:xalan:2.6.0",
"xml-apis:xml-apis-ext:1.3.04"
){
transitive = false
Why I can't download? Invalid svg? I got this svg from wiki.
Check your deployed code on either the presence of batik-svg-dom-1.7.jar or batik-all-1.7.jar (using that would shorten your compile configuration considerably too). If it is missing, add it manually just to see if that fixes your issue. If it is missing however something is missing in your deploy configuration.
This is not a good/bad answer nor a fix, but it only runs at grails run-war, I don't know why and it works.

AngularJS with .NET MVC Bundling Minification Error

I have been developing a large AngularJS application inside of a .NET MVC Website. I've gone way to long without testing if it will sucesfully minifiy using the Bundle Optimiazation Features?
BundleTable.EnableOptimizations = True
And of Course, it fails. I've been playing with the Order I bundle my scripts, and ensuring I am using String Literals for my Controller Names (I wasn't, and that is a lot of re-factoring that I will have to do).
But I can not get my Core Scripts to Minifiy without the angular "Unknown Provider" error.
Here is the exact Error:
Uncaught Error: [$injector:modulerr] [http://errors.angularjs.org/1.3.14/$injector/modulerr?p0=ppAccount&p1=Error…redScripts%3Fv%3DknV3wkCOg32ajaw4GwiRSrTXdo8Ue7MRIn65CPYa1b81%3A1%3A379851)]1
Here is my bundle config that is failing:
bundles.Add(new ScriptBundle("~/bundles/PilotPartnerRequiredScripts")
.Include(
"~/UI/js/jquery/jquery-2.1.3.js",
"~/UI/js/plugins/jquery-ui/jquery-ui.js",
"~/UI/js/bootstrap/bootstrap.js",
"~/UI/js/plugins/pace/pace.min.js",
"~/UI/js/plugins/slimscroll/jquery.slimscroll.js",
"~/UI/js/inspinia.js",
"~/UI/js/angular/angular.js",
"~/UI/js/ui-router/angular-ui-router.js",
"~/UI/js/bootstrap/ui-bootstrap-tpls-0.12.1.js",
"~/UI/js/angular/angular-resource.js",
"~/UI/js/angular/angular-sanitize.js",
"~/UI/js/angular/angular-route.js",
"~/UI/js/plugins/switchery/switchery.js",
"~/UI/js/plugins/angular-ui-switch/angular-ui-switch.js",
"~/UI/js/plugins/angularLocalStorage/angular-local-storage.js",
"~/UI/js/plugins/ngDialog/ngDialog.js",
"~/Scripts/ngTags/ng-tags-input.js",
"~/Scripts/uiSortable/sortable.js",
"~/Scripts/kendo/2014.3.1119/kendo.all.min.js",
"~/Scripts/xeditable/xeditable.js"
For the life of me, I can't figure out which dependency isn't being resolved. I feel that if I can narrow it down to a specific dependency I know I can solve the issue.
Is there any way to track down the specific Module that is causing the issue?
Any suggestions on how to make this work?
Thank you for your help.
You should always follow strict di while injecting dependency (Array notation)
Angualar Doc has mentioned that, Do follow strict DI while doing minification, otherwise it could break you app
Eg.(Code)
angular.module('myModule', [])
.factory('serviceId', ['depService', function(depService) {
// ...
}])
.directive('directiveName', ['depService', function(depService) {
// ...
}])
.filter('filterName', ['depService', function(depService) {
// ...
}]);
In above snippet I followed inline array notation of DI, it has been applied on various angular component just to demonstrate it. You should make sure that you follow it wherever you're injecting dependency.

Debugging MirrorsUsed

I'm trying to figure out which libraries I need to pass to #MirrorsUsed to get my app compiled and working. Sometimes, it's easy to figure out which library may be missing since a descriptive error is thrown such as Uncaught Unsupported operation: Cannot find class for: NgAttr .
Other times, I get a more obscure message, such as NullError: Cannot call "$gt" on null with no clue as to which library I may be omitting. Is there a better approach to this, besides trial and error?
In case you're wondering, this is an angular app and this is how I currently have it configured:
#MirrorsUsed(targets: const[
'angular',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',
'todo',
'perf_api',
'List',
'NodeTreeSanitizer',
'PlaybackHttpBackendConfig'
],
override: '*')
import 'dart:mirrors';
Use
pub build --mode=debug
this does tree shaking but retains (mostly) the original Dart names.
Then debugging the generated JavaScript usually lets deduce the source of the exception.
EDIT
IMHO these are not necessary anymore, because they were added to #MirrorsUsed in the Angular libs.
'angular',
'angular.core',
'angular.core.dom',
'angular.filter',
'angular.perf',
'angular.directive',
'angular.routing',
'angular.core.parser.dynamic_parser',
'angular.core.parser.lexer',

Get warnings when programmatically parsing Dart file with analyzer_experimental

I am using analyzer_experimental to parse a Dart file into a CompilationUnit:
import 'package:analyzer_experimental/analyzer.dart';
var unit;
try {
unit = parseDartFile(path);
} on AnalyzerErrorGroup catch(e){
print(e);
}
The above code will catch any parsing errors encountered.
I am also interested in seeing any warnings associated with the file (e.g. 'Undefined name "foo"'). I know that the experimental_analyzer library has the capability to generate these warnings when running from the command line but it does not seem to be possible to get the warnings programmatically, without directly referencing classes in the src folder (which seems like a bad idea).
Is there any way to achieve this?
It's likely this package was very incomplete at the time.
There's now an analyzer package on pub and also a (work-in-progress) STDIN/STDOUT Analyzer Service aimed to help making tooling support easier for IDE extension authors.

Is there a groovyws.jar with all his dependences?

I'm using Grails and want to use groovyws to call an web-service.
But my groovyws.jar (0.5.2) have MANY dependences that I can't solve.
Is there any jar with all dependences included?
Note: I tried put in BuildConfig.groovy, this
dependencies {
'org.codehaus.groovy.modules:groovyws:0.5.2'
}
but I'm getting error:
Error executing script Compile: loader constraint violation: when
resolving overridden method
"org.apache.xerces.jaxp.SAXParserImpl.getParser()Lorg/xml/sax/Parser;"
the class loader (instance of
org/codehaus/groovy/grails/cli/support/GrailsRootLoader) of the
current class, org/apache/xerces/jaxp/SAXParserImpl, and its
superclass loader (instance of ), have different Class
objects for the type org/xml/sax/Parser used in the signature
You can manually exclude xerces by:
dependencies {
runtime('org.codehaus.groovy.modules:groovyws:0.5.2') {
exclude: 'xerces'
}
}
GroovyWS pulls inn CXF, which again pulls in a lot of dependencies, some of them conflicting with classes already present in Java 6. You need to exclude all these dependencies if using Java 6, to avoid errors like the one you mention.
Here's my exclude list:
compile("org.codehaus.groovy.modules:groovyws:0.5.2") {
excludes 'geronimo-servlet_2.5_spec', 'servlet-api', 'jaxb-xjc', 'jaxb-impl', 'xml-apis', 'saaj-impl', 'junit', 'slf4j-jdk14', 'xmlParserAPIs', 'jaxb-api', 'saaj-api', 'xmlbeans', 'jaxen', 'geronimo-stax-api_1.0_spec', 'geronimo-activation_1.0.2_spec', 'abdera-client', 'geronimo-activation_1.1_spec'
}
Note that on Ubuntu you need jaxb-xjc and jaxb-impl after all, don't know why.
I found:
http://docs.codehaus.org/dosearchsite.action?queryString=groovyws+standalone
Tks a lot!
(search for "groovyws standalone")
Note: I saw this tip here.

Resources