i have a grails project with an Image Domain Class and Controller.
I just installed the grails ImageTools 1.0.4 Plugin and i would like to generate thumbnails for images wich will be uploaded.
My Image-Domain-Class:
class Image {
byte[] data
//String name
byte[] thumbnail
static constraints = {
//name()
data()
}
}
The "safe"-action in my Controller:
def save = {
def imageInstance = new Image(params)
def imageTool = new ImageTool()
imageTool.load(imageInstance.data)
imageTool.thumbnail(320)
imageInstance.thumbnail = imageTool.getBytes("JPEG") //Here is my problem!
if(!imageInstance.hasErrors() && imageInstance.save()) {
flash.message = "Image ${imageInstance.id} created"
redirect(action:show,id:imageInstance.id)
}
else {
render(view:'create',model:[imageInstance:imageInstance])
}
}
When I start my Grails-application and uploading an image I'm getting the following error-message:
Error 200: groovy.lang.MissingMethodException: No signature of method: ImageTool.getBytes() is applicable for argument types: (java.lang.String) values: {"JPEG"}
Servlet: grails
URI: /grailsproject/grails/image/save.dispatch
Exception Message: No signature of method: ImageTool.getBytes() is applicable for argument types: (java.lang.String) values: {"JPEG"}
Caused by: groovy.lang.MissingMethodException: No signature of method: ImageTool.getBytes() is applicable for argument types: (java.lang.String) values: {"JPEG"}
Class: GrailsAuthenticationProcessingFilter
At Line: [57]
It says that the Method getBytes() is missing but the method is still available. My IDE intelliJ also recognizes no errors.
So what can I do? Could someone help me please?
Sorry for my bad english. If you are german, please look at http://support-network.info/board/problem-mit-imagetools-getbytes-t3008.html .
I use Grails 1.0.4.
I could fix this error message. I just copied the getBytes() method from the git Repository of Ricardo (the plugin developer) and replaced the old one with the new one. Now everything works! I don't know where the bug was but i'm happy that i solved it.
Thank you both very much!
Looks like that method is a fairly new addition to the class (3/6/2009). If you have verified that that method is in the ./plugins/imagetools/src/groovy/ImageTool.groovy file I'd recommend running:
grails clean
If you had been using this plugin prior it might be a cache problem.
The reply that you received from John sounds about right - if you have installed the new plugin and can see the code, but keep getting this error only outside IntelliJ, you should try cleaning your grails cache - it's very possible that an older copy of the plugin is precompiled on the cache.
Are you using Grails 1.1? I haven't yet tested it with the latest grails, but I understand it keeps the plugins not under the project but in a separate directory. Do let me know and I'll try it out.
I don't know what the plugin is really giving you over using JAI directly, IMHO it isn't doing much.
I use ImageMagick out of process for my image conversion and the results are superior to what can be done with JAI from what I have seen. Of course if your doing as much traffic as Amazon running out of process is not an option, however if you need to get to revenue as quickly as possible then you might want to consider what I've done.
I use apache-commons-exec to have a nice interface around handling opening an external process and reading data from std in and out. The only thing I'm using JAI for is to read the sizes of images.
try this one http://support-network.info/board/gel%C3%B6st-problem-mit-imagetools-getbytes-t3008.html
Related
I'm currently developing a project in java using the Ilog Cplex libraries, I'm using the Intellij-Idea IDE.
I'm having troubles importing a model from MPS file, this is the piece of code that gives me problems
IloCplex iloCplexInstance = new IloCplex();
iloCplexInstance.importModel(fileName);
It fires this exception:
ilog.cplex.CpxException: CPLEX Error 1423: Could not open file 'models\20_70_45_05_100.mps' for reading.
at ilog.cplex.CplexI.CALL(CplexI.java:5204)
at ilog.cplex.CplexI._readModel(CplexI.java:5584)
at ilog.cplex.CplexI.importModel(CplexI.java:1032)
at ilog.cplex.IloCplex.importModel(IloCplex.java:902)
at heuristics.ziround.LPUtils.fromMPS(LPUtils.java:34)
at heuristics.test.LPUtilsTestCompile.main(LPUtilsTestCompile.java:13)
I tried running it in unit tests using junit4, junit.runners.Parameterized, and in a simple class from its main method. Same result in each case. I've also tried to set the full path to the file and it gives the same result.
I know that the file I used is ok, I'm able to read it using the cplex terminal commands, I also tried other files.
The code that uses the Ilog's libraries can compile, I'm not sure if it can run though since I'm not able to import a model I can't try to solve one.
I'm using windows, launching the IDE as admin sorts no effects, and the file is not blocked from reading (nor writing).
I'm following the documentation from IBM:
https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.0/ilog.odms.cplex.help/refjavacplex/html/ilog/cplex/IloCplex.html#importModel(java.lang.String)
In the official support pages, I found this about the error: http://www-eio.upc.es/lceio/manuals/cplex-11/html/refcallablelibrary/html/macros/CPXERR_FAIL_OPEN_READ.html
But I can't find anything useful.
Also, the IBM forum is currently closed and no one seems to have had this kind of problem :(
Does anyone know what could be the trouble? What can I do? Do you know of any other alternative?
Thanks to anyone that will stop by!!
The exception message says:
ilog.cplex.CpxException: CPLEX Error 1423: Could not open file
'models\20_70_45_05_100.mps' for reading.
Try using an absolute path instead, like c:\path\to\your\models\20_70_45_05_100.mps.
You can also add code to your program to make sure the path exists. Something like:
import java.nio.file.Files;
...
IloCplex iloCplexInstance = new IloCplex();
if (!Files.exists(fileName))
throw new AssertionError("path does not exist: " + fileName);
iloCplexInstance.importModel(fileName);
Following #rkersh answer i did this:
String modelsPath = "absolute\\folder\\path";
Collection<Object[]> models = new ArrayList<>();
File folder = new File(modelsPath);
for (final File fileEntry : Objects.requireNonNull(folder.listFiles())) {
if (fileEntry.isFile())
models.add(new String[]{fileEntry.getAbsolutePath()});
}
return models;
This makes sure that the absolute path is correct and now iloCplexInstance.importModel(fileName); accepts it fine
I'm attempting to use an online timestamp authority (rfc3161) with the Digital Signature Service Java library. However, the following snippet (from their test cases, and similar to the one from their Cookbook):
String tspServer = "http://tsa.belgium.be/connect";
OnlineTSPSource otsp = new OnlineTSPSource(tspServer);
/* tried setting otsp.setDataLoader(new TimestampDataLoader());
too, as it defaults to otsp.setDataLoader(new
NativeHTTPDataLoader()); the exception happens in both cases */
byte[] digest = DSSUtils.digest(DigestAlgorithm.SHA1, "Hello world".getBytes());
TimeStampToken timeStampResponse =
otsp.getTimeStampResponse(DigestAlgorithm.SHA1, digest);
always ends with the following exception:
eu.europa.esig.dss.DSSException:
java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError:
org.apache.commons.io.IOUtils.closeQuietly(Ljava/io/Closeable;)V
Already tried many different public rfc3161 servers (some listed here). Sure there's something wrong going on there, but, as a beginner, I cannot understand what is wrong (what method should be there).
If anyone could put me in the right direction to get the snippet working (or even be kind enough to comment a reliable startup guide on cades/xades/pades with Java's bouncycastle) I would be really grateful.
As stated in the comments by Marteen Bodewes and Mark Rotteveel, there was something wrong with the version of Apache Commons-IO in the classpath. The project is set using Apache Maven and there was an old Commons-IO version declared there as a dependency. In this case, it was enough to remove that declaration, so Maven could download the appropriate version that was declared as an esig/DSS dependency.
esig/DSS version was 5.4 at the time.
Basically I have started updating a lot of Heroes spells to 1.7.2 and this update broke the .getHealth() and .getMaxHealth(). I am trying to fix it but I do not know how to. If anyone has some advice or samples I will be in debt. I will place some code where I use the .getHealth() method.
this is the link of the error: http://puu.sh/7BrEP.png. It is saying this method is ambigous for that type.
public void tickHero(Hero hero) {
if ( hero.getPlayer().getHealth() - damage > 1) {
addSpellTarget(hero.getPlayer(), plugin.getCharacterManager().getHero(caster));
damageEntity(hero.getPlayer(), caster, damage, DamageCause.MAGIC);
//hero.getPlayer().damage(damage, caster);
}
}
As of 1.7.2, there are two getHealth() and getMaxHealth() methods. This is becaue of the way Bukkit handled Minecraft changing the way entity health is stored in 1.6. You can read more about this here.
If you aren't using any NMS code, you should use the bukkit.jar in your build path as opposed to craftbukkit.jar. This should resolve your issue easily enough.
If you do need NMS code, you need to have both bukkit.jar AND craftbukkit.jar in your build path. Furthermore, you have to have bukkit.jar above craftbukkit.jar in the build path for it to work.
I am trying to save a file using write.xslx (when saving with write.csv some row got shift in more columns so I am trying to save the file as xlsx directly).
If I type this command:
write.xlsx (old.data, file ="Documents/new.xlsx", sheetName="Sheet1",col.names=TRUE, row.names=TRUE, append=FALSE)
or
write.xlsx (old.data, "Documents/new.xlsx", sheetName="Sheet1",col.names=TRUE, row.names=TRUE, append=FALSE)
I get this error:
Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") :
Java Exception <no description because toString() failed>.jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook")<S4 object of class "jobjRef">
Can anyone help me sort it out?
I don't think that this question can easily be answered. Is <working_directory>/Documents writeable to you? Can you create the file
write.xlsx ( data.frame( a = 1:10, row.names = letters[ 1:10 ] ), "Documents/new.xlsx", sheetName="Sheet1",col.names=TRUE, row.names=TRUE, append=FALSE)
If this works, but with old.data it doesn't you have to provide a reproducible example.
However, I experienced every here and again weird problems with the xlsx package. From my experience XLConnect is much more robust and bug-free:
library("XLConnect")
writeWorksheetToFile( "Documents/newxlsx", old.data, "Sheet1", header=TRUE, rownames = "rownames.header" )
write_xlsx() from the writexl package works great for me and is way faster! It also works fine with tibbles and does not have the annoying errors or resctrictions from the xlsxpackage. It is also completely written in C so no Java, Perl or Rtools are required.
For more info see https://ropensci.org/technotes/2017/09/08/writexl-release/
I just had this same problem. I think there might be a bug with openXL but I love working with it. So I open and close R and then change the wd, saved the file exactly where the wd was and then I run the exact same code again. It worked.
Today I had that problem after deployment.
At this moment I didn't need to change package and stick to xlsx
I updated dplyr, xlsx, and the one that did the trick was updating rjava.
Since it was a conflict with java and xlsx calls it, I gave it a shot.
Hope this work for you too
I created my own new R library (called "Media"). There is no problem when I try to load it with RGui, and I can call the functions defined in the new package. This is how I load it:
> library(Media)
But, I'm also trying to call that functions from Java/JRI code, and when I load the new R package, Java doesn't seem to find the pacakge, throwing the message "Error in library(Media) : object 'Media' not found"
This is my current code using JRI:
REXP rexpSetFolder = re.eval("setwd('C:/Users/Albert/Documents')");
REXP rexpFolder = re.eval("getwd()");
System.out.println(rexpFolder.asString());
REXP rexpLoad = re.eval("library(Media)"); // fails
It also fails without the 'setwd' command, and simple calls to existing R functions work fine. I'm using R 2.10 and the latest JRI 0.5-0 under Windows.
Any help would be appreciated.
Thank you very much.
Edit:
The parameter lib.loc seems to work, at least this sentence does not return an error:
library("Media", lib.loc = "c:/Users/Albert/Documents")
But after that, calling a function in the package with re.eval("myfunction()"); still fails, as the function is not properly found.
You can modify the library path - see ?.libPaths in R, you simply want to add your private library to the path. The GUI does that for you, but if you are outside it doesn't happen. For example:
re.eval(".libPaths('c:/users/foo/Documents/R')");
Then load your package.
Did you install the library properly first? You might want to try using the lib.loc parameter.
library("Media", lib.loc = "c:/Users/Albert/Documents")
My work-around was to copy the package from my personal library (%USERPROFILE%\Documents\R) to the global library (%R_HOME%\library).
It's not the best because this requires Administrator privileges which not all users will have...