Grails Currencies Plugin: Unable to resolve class Money - grails-plugin

I installed the grails currency plugin. I want to use the Money type in my grails domain class as such:
class FOO{
...
Money lunchCost = new Money(amount:0.00, currency:'USD')
Money dinnerCost = new Money(amount:0.00, currency:'USD')
...
}
I get an error when I compile saying "unable to resolve class Money". I traced the package heirchy of the Grails Money Plugin and tried to put in:
cr.co.arquetipos.currencies.Money breakfastCost = new cr.co.arquetipos.currencies.Money(amount:0.00, currency:'USD')
---- That didn't work either.
1) When I generated Foo, grails placed the domain class under "projectName.Foo" as it does for every domain class created.
2) I'm using Grails 1.3.5.
Do you have any ideas as to where the Currencies class is so I can include it in the
"import <....Money> and get rid of this compilation error?

Same here: The plugin does not integrate with the Grails project, at all. Nevertheless, it has been installed to ${user.home}/.grails/1.3.5/projects/${project.name}/plugins/currencies-0.3.
Since the plugin has been last updated in 2008 and doesn't cover too much functionality, I'd suggest to just copy the two domain classes (in the grails-app/domain folder) into your project.
For an evaluation, you may also want to have a brief look at grails-app/conf and test/integration in the plugin's installation folder.

Like ataylor says, don't use this plugin, it's broken. Instead use JScience. Checkout: Best practice to represent Money (value + currency) in Grails

Related

Avro generated class: Cannot access class 'Builder'. Check your module classpath for missing or conflicting dependencies

Running
val myAvroObject = MyAvroObject.newBuilder()
results in a compilation error:
Cannot access class 'MyAvroObject.Builder'. Check your module classpath for missing or conflicting dependencies
I am able to access other MyAvroObject variables. More precisely, methods such as
val schema = MyAvroObject.getClassSchema()
val decoder = MyAvroObject.getDecoder()
compiles fine. What makes it even stranger is that I can access newBuilder() in my test/ folder, but not in my src/ folder.
Why do I get a compile error when using newBuilder()? Is the namespace of the avro-schema used to generate MyAvroObject of importance?
Check your module classpath generally means, that your dependencies (which you didn't provide) are messed up. One of them should read implementation instead of testImplementation, in order to have the method available in the main source-set, instead of only the test source-set - but this may well have to do with the input classes, the output location of generated classes, or annotations alike #VisibleForTesting (just see what it even generates). Command gradlew can also list the dependencies per configuration. The builder seems to be called org.apache.avro.SchemaBuilder... there's only avro-1.11.0.jar & avro-tools-1.11.0.jar. With the "builder" design pattern, .newBuilder() tries to return inner class Builder.
had the same problem today and was able to solve it by adding the following additional source folder
<sourceDir>${project.basedir}/target/generated-sources/avro</sourceDir>
to the kotlin-maven-plugin.

Rally Web Services REST API - Ruby Toolkit

I'm trying to update the Project an artifact belongs to. I am not getting any errors but the artifact's Project does not change. I can successfully change the artifact's notes, name, and other attributes, but not Project. I'm not sure if I'm specifying the Project name correctly in the call:
updated_artifact = #rally.update(:hierarchical_requirement, "FormattedID|" + artifact.FormattedID, {"Project.Name" => "Project A"})
Got help from CA Support and resolved this. If you want to update an associated/referenced field, you'll need to send the URL reference to the Project and supply whatever the OID of the project is, like so:
updated_artifact = #rally.update(:hierarchical_requirement, "FormattedID|" + artifact.FormattedID, {"Project" => "/Project/OID"})

Calling java code from Apache Derby

I've written a simple method in Java:
package com.fidel.extensions;
public class Extensions {
public static String capitalize(String input) {
return input.toUpperCase();
}
}
I then registered it as a function in Apache Derby.
create function capitalize(inputString varchar(255))
returns varchar(255)
parameter style JAVA
no sql language JAVA
external name 'com.fidel.extensions.Extensions.capitalize'
In order to give the database access to that code, this page suggests I have two choices:
Install the jar into the database
Add the jar to CLASSPATH
This is the text from that article:
The compiled Java for a procedure (or function) may be stored in the
database using the standard SQL procedure SQLJ.INSTALL_JAR or may be
stored outside the database in the class path of the application.
If I use the INSTALL_JAR approach to embed the jar into the database, my queries work fine. For example:
select capitalize('hello') from SYSIBM.SYSDUMMY1
However I don't actually want to store the jar in the database. I would like derby to look in my CLASSPATH variable to find it.
So I've added it to my CLASSPATH using the following:
export CLASSPATH=${CLASSPATH}:/home/fidel/dev/DbExtensions/extensions.jar
But when I run the same query, I get this error message:
The class 'com.fidel.extensions.Extensions' does not exist or is
inaccessible.
I'm using Netbean's SQL editor, which I assume would pick up the CLASSPATH I've set.
Has anyone managed to reference code in an external jar, via the CLASSPATH?
ps. I know I can use the UCASE/UPPER methods. But the code above is just an example
pps. I am able to get the query to work by adding the jar to the Driver list, but I don't think that's the correct thing to do.
Services -> Drivers -> Java DB (Embedded) -> Customize -> Add

Using Enunciate in multi-module Maven project

I am using Enunciate to generate documentation for RestEasy services inside multi-module Maven project.
I have some problems with doc generation when trying to get description of response object atributes.
For instance, if my service is defined as:
#GET
#Path("access/account")
#Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
Account getAccount(#Context HttpServletRequest hsr, #Context UriInfo info) throws RestApiException;
when the documentation is generated no atribute description is generated.
name type description
idProfile int (no documentation provided)
idLanguage int (no documentation provided)
idRegion int (no documentation provided)
userType string (no documentation provided)
In all response objects I get only (no documentation provided). One important think is that all response
classes are in different Maven module that the services are. The response classes are situated in the UTIL module. The services are situated in EJB module.
The reason for the problem is definitely multi-module Maven project, because if I define a response object
that class is in the EJB module too, the documentation is perfect (also the description is generated).
The reason and also the solution is described here:
https://github.com/stoicflame/enunciate/wiki/Multi-Module-Projects-%28Version-1%29
Despite all I still don't know what to do exactly and what to set inside different poms (EJB and UTIL) to solve my problem.
Any help is apreciated.
So have you tried to "import" the Account class as described in Multi-Module Projects?
<enunciate ...>
<api-import pattern="com.mycompany.Account" />
<api-import pattern="com.mycompany.*" />
...
</enunciate>
Problem solved !!!
I had to:
import the classes as Ryan said
add maven-source-plugin in the pom.xml of the UTIL class where all response objects are located
add description to get methods in reference class
The result is:
JSON
property type description
idProfile int Description B.
idLanguage int Description A.
idRegion int Description E.
userType string Description D.

How to use a dependency of a module within a Play app

I am writing a Play Framework module in order to share some common logic among multiple Play apps. One of the things I would like my module to do is provide some frequently-used functionality by way of 3rd-party modules, for example the excellent Markdown module.
First of all, is it possible to do this? I want all the apps that include my module to be able to use the .markdown().raw() String extension without needing to explicitly declare the Markdown module as a dependency. The Play Framework Cookbook chapter 5 seems to imply that it is possible, unless I am reading it wrong.
Secondly, if it is possible, how does it work? I have created the following vanilla example case, but I'm still getting errors.
I created a new, empty application "myapp", and a new, empty module "mymod", both in the same parent directory. I then modified mymod/conf/dependencies.yml to:
self: mymod -> mymod 0.1
require:
- play
- play -> markdown [1.5,)
I ran play deps on mymod and it successfully downloaded and installed the Markdown module. Running play build-module also worked fine with no errors.
Then, I modified myapp/conf/dependencies.yml to:
# Application dependencies
require:
- play
- mymod -> mymod 0.1
repositories:
- Local Modules:
type: local
artifact: ${application.path}/../[module]
contains:
- mymod
I ran play deps on myapp and it successfully found mymod, and generated the myapp/modules/mymod file, containing the absolute path to mymod.
I ran myapp using play run and was able to see the welcome page on http://localhost:9000/. So far so good.
Next, I modified myapp/app/views/Application/index.html to:
#{extends 'main.html' /}
#{set title:'Home' /}
${"This is _MarkDown_, by [John Gruber](http://daringfireball.net/projects/markdown/).".markdown().raw()}
I restarted myapp, and now I get the following error.
09:03:23,425 ERROR ~
#6a6eppo46
Internal Server Error (500) for request GET /
Template execution error (In /app/views/Application/index.html around line 4)
Execution error occured in template /app/views/Application/index.html. Exception raised was MissingMethodException : No signature of method: java.lang.String.markdown() is applicable for argument types: () values: [].
play.exceptions.TemplateExecutionException: No signature of method: java.lang.String.markdown() is applicable for argument types: () values: []
at play.templates.BaseTemplate.throwException(BaseTemplate.java:86)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:257)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
at play.mvc.results.RenderTemplate.<init>(RenderTemplate.java:24)
at play.mvc.Controller.renderTemplate(Controller.java:660)
at play.mvc.Controller.renderTemplate(Controller.java:640)
at play.mvc.Controller.render(Controller.java:695)
at controllers.Application.index(Application.java:13)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
at Invocation.HTTP Request(Play!)
Caused by: groovy.lang.MissingMethodException: No signature of method: java.lang.String.markdown() is applicable for argument types: () values: []
at /app/views/Application/index.html.(line:4)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
... 13 more
And just to confirm I'm not crazy, I tried adding the play -> markdown [1.5,) line to myapp/conf/dependencies.yml and restarted the app, and confirmed that it works.
I feel like I'm missing something obvious. Many thanks in advance to anyone who can help! :)
Yes I had the same problem, it seems that transitive dependencies through custom home made modules does not work