User ae3dd76263
06-06-2012 18:56:51
Hello,
We are attempting to render a molecule image using Molecule class, but are receiving this error - what cache file is being created? Are there permissions on the file system that we need to change for this?
chemaxon.marvin.io.MolExportException: Can't create cache file!
at chemaxon.struc.Molecule.exportToBinFormat(String fmt)
at chemaxon.struc.Molecule.toBinFormat(String fmt)
Thanks in advance!
Mark
ChemAxon bd13b5bd77
06-06-2012 19:22:21
Hi Mark,
moved this issue to the Marving team.
Viktor
ChemAxon 7c2d26e5cf
08-06-2012 11:40:01
Please, provide more information.
- Which Marvin version do you use?
- Which image format did you use at toBinFormat?
They help me a lot to clarify the problem.
User ae3dd76263
08-06-2012 15:44:43
Hi Tamas,
We are using JChem for .NET version 5.7.0.712 (which I guess I forgot to mention).
We've wrapped the code in a .NET handler in code that looks something like this:
public void ProcessRequest(HttpContext context)
{
String structure = context.Request.QueryString[SMILE_STRING_URL_PARAM];
if (!String.IsNullOrEmpty(structure))
{
Molecule mol = MolImporter.importMol(structure);
Byte[] molecule = mol.toBinFormat("jpeg:h200,w200");
context.Response.ContentType = "image/jpeg";
context.Response.OutputStream.Write(molecule, 0, molecule.Length);
}
}
Also, (I'm not sure if this has anything to do with the error but...) a different version of JChem for SharePoint is also installed on the server, but we were told that this should not cause any conflicts.
ChemAxon 7c2d26e5cf
11-06-2012 12:56:12
I assume it may be a configuration issue. The temporary folder does not exist or it is not a writable.
It seems that certain internal Java classes that the JPEG export of Marvin invokes, attempt to create temporary files.
(I have tested it under Java platform. If system temporary folder does not exist, Java cannot complete JPEG export.)
Please check that temporary folder is available at runtime.
User ae3dd76263
11-06-2012 13:38:32
Hi Tamas,
Thank you for this information - where is this temporary folder? And how can we ensure that the directory is properly created upon installation should we need to install this again?
ChemAxon eb65a25631
11-06-2012 14:32:27
Hi Mark,
Can you query the cache directory by using:
javax.imageio.ImageIO.getCacheDirectory()
?
What happens if you try to set a (valid) cache directory, by using:
javax.imageio.ImageIO.setCacheDirectory(new javai.io.File(<path>))
?
ChemAxon bd13b5bd77
11-06-2012 20:14:43
Hi Mark,
could you please try out what Andras suggested and also you can use ChemAxon.NET libraries:
private static Image ConvertMoleculeToImage(string moleculeString) {
// Bitmap type
var molecule = MolImporter.importMol(moleculeString);
var structureDrawingInfo = new MarvinStructureDrawingInfo();
structureDrawingInfo.Size = new Size(300, 300);
var imageCreator = new BitmapMoleculeImageCreator();
return imageCreator.CreateImage(molecule, structureDrawingInfo);
// EMF type
//var molecule = MolImporter.importMol(moleculeString);
//var structureDrawingInfo = new MarvinStructureDrawingInfo();
//structureDrawingInfo.Size = new Size(300, 300);
//var imageCreator = new EMFMoleculeImageCreator();
//byte[] imageBytes = imageCreator.CreateImageBytes(molecule, structureDrawingInfo);
//return Image.FromStream(new MemoryStream(imageBytes));
}
Viktor
User ae3dd76263
11-06-2012 21:23:40
Hi Viktor, Andras,
Is there a way for me to find out what the cache folder is currently set to without using Java? We're not really set up to do Java development, so anything I can do in C# or the Windows command console would be helpful.
ChemAxon eb65a25631
12-06-2012 08:14:49
Hi Mark,
That cache directory certainly has to be some system temp folder, so it is not strcitly java specific.
The suggested calls result could help the investigation.
Regards,
András
User ae3dd76263
12-06-2012 18:03:44
Hello,
I've tried finding the location of the cache directory using the commands you mentioned, but I can not find the javac.exe or java.exe commands to either compile or run the command. The JChem libraries are installed under c:\Program Files (x86)\ChemAxon\, but I can not find either the JDK or JRE locations to execute the java command.
I've also looked at attempting to run the C# code that was provided, but if I'm not mistaken, that will just produce the same error we're getting before, will it not?
ChemAxon eb65a25631
12-06-2012 19:20:18
Hi Mark,
Oh, I see why you had opposition against 'java' code.
There is no need for any kind of JDK.
The JChem.NET contains assemblies that provide java functionality converted to .NET code.
(Thus making JChem/Marvin to run on .NET platform.)
(These are the IKVM.*.dll assemblies, you hopefully referenced in your project earlier.)
So, you can try the mentioned methods right in your code.
Regards,
Andras
ChemAxon 9751c82584
12-06-2012 19:27:34
You can change the location of the cache folder in the following way in C#:
- Add a reference to the following assembly:
IKVM.OpenJDK.Media.dll
- Use this line somewhere before generating the image:
javax.imageio.ImageIO.setCacheDirectory(new java.io.File(@"c:\temp"));
User 249192efae
05-02-2014 02:43:45
I received the "Can't create cache file" error while using Tomcat.
In case anyone else get's that error, it turns out my error was because I'd removed the TOMCAT_BASE\temp dir.
Unfortunately it seemed safe to delete, since the only file in there was the "safeToDelete.tmp"
But after restoring that empty temp directory, my Marvin image exports worked again.
(Using MarvinBeans 6.1.x in Tomcat 7.0.41 on Linux)
ChemAxon f052bdfe3c
06-02-2014 12:49:46
Thank you for this suggestion!
Efi