NoMethodError at convertFIle

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

NoMethodError at convertFIle

amraalic
Hi all,

I got an error

org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `convertFile' for #<AsciidoctorModule:0x180e2dd3>
        at org.jruby.gen.InterfaceImpl1387798675.convertFile(org/jruby/gen/InterfaceImpl1387798675.gen:13)

and I could not find any similar error on the forums.

I am working on Java project that is using Asciidoctor for creating .adoc file and converting it to .pdf.

Also, all required jar files are added.  I tested it on another computer and it works, but not on my PC.

Can anyone help me, please?

Thank you very much.
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

mojavelinux
Administrator
Could you provide a sample project or a test case. Otherwise, it's going to be very hard for anyone to help you debug this issue.

We find the best way to share sample projects is just to create a repository on GitHub (which you can delete later).

-Dan

On Sat, Feb 13, 2016 at 4:34 AM, amraalic [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi all,

I got an error

org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `convertFile' for #<AsciidoctorModule:0x180e2dd3>
        at org.jruby.gen.InterfaceImpl1387798675.convertFile(org/jruby/gen/InterfaceImpl1387798675.gen:13)

and I could not find any similar error on the forums.

I am working on Java project that is using Asciidoctor for creating .adoc file and converting it to .pdf.

Also, all required jar files are added.  I tested it on another computer and it works, but not on my PC.

Can anyone help me, please?

Thank you very much.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/NoMethodError-at-convertFIle-tp4301.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

amraalic
Of course. I guess I forgot to write a sample of code.


public class GenerateFile extends Window implements View,Serializable{

        /**
         *
         */
        private static final long serialVersionUID = 1L;
        private String fileName;
        private FileWriter fw ;
        private BufferedWriter bw;
        private String basepath;

        public GenerateFile(){
                         
                         fileName = Document.getName();
                        File file = new File(fileName + ".adoc");
                       
                        if (!file.exists())
                        {
                                file.createNewFile();
                        }
                       
                        basepath =  "C:\\Brochures\\";
       
                        fw = new FileWriter(basepath + fileName + ".adoc");
                        bw = new BufferedWriter(fw);
                        bw.write("===testing"); // just an example
       
                        bw.close();
                        Asciidoctor asciidoctor  = Asciidoctor.Factory.create();

                        HashMap<String, Object> options = new HashMap<String, Object>();
                        options.put("backend", "pdf");
                        options.put("in_place", true);

                        asciidoctor.convertFile(file,options);

                        try
                        {
                               
                                Resource resource = new FileResource(new File("C:\\Brochures\\" + fileName + ".pdf"));
                                FileDownloader fileDownloader = new FileDownloader(resource);
                                fileDownloader.extend(MasterBrochureTab.getDownloadBrochureButton());
                        }
                        catch(Exception e)
                        {
                                        Notification.show("You need to generate a brochure, and then download it.");
                        }
        }

It does not say at what line the error is. The code is working on Linux, but on the Windows system.

Maybe something needs to be installed additionally on Windows?
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

abelsromero
I have adapted your code and created a project with it https://github.com/abelsromero/asciidoctorj-gradle/blob/master/src/main/java/org/asciidoctor/demos/GenerateFile.java.

But so far I cannot reproduce the issue.
Is there anything else you can say?
· Asciidoctorj version?
· Is there a Ruby environment installed? With any asciidoctor gem?
. Building tool? gradle/maven/ant/other?

Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

mojavelinux
Administrator
I strongly recommend instantiating Asciidoctor as follows:

Asciidoctor asciidoctor  = Asciidoctor.Factory.create((String) null);

This isolates Asciidoctor from the system gems. This is the default planned for 1.6.0.

-Dan

On Sat, Feb 13, 2016 at 1:59 PM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I have adapted your code and created a project with it https://github.com/abelsromero/asciidoctorj-gradle/blob/master/src/main/java/org/asciidoctor/demos/GenerateFile.java.

But so far I cannot reproduce the issue.
Is there anything else you can say?
· Asciidoctorj version?
· Is there a Ruby environment installed? With any asciidoctor gem?
. Building tool? gradle/maven/ant/other?




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/NoMethodError-at-convertFIle-tp4301p4306.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

amraalic
In reply to this post by abelsromero
Hi,

Thank you for your effort.

Please, find below the installed versions:

Asciidoctor PDF 1.5.0.alpha.11 using Asciidoctor 1.5.4 [http://asciidoctor.org]
Runtime Environment (ruby 2.2.4p230 (2015-12-16 revision 53155) [x64-mingw32]) (lc:CP850 fs:Windows-1252 in:- ex:CP850)

and I have tried almost everything, but without success.

The only error that is occurring is
org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `convertFile' for #<AsciidoctorModule:0x5aff2485>
        at org.jruby.gen.InterfaceImpl741784564.convertFile(org/jruby/gen/InterfaceImpl741784564.gen:13)

and that's all. The error seems to be in the line with asciidoctor.convertFile(file, options);
I have tried with other backends too, just to check if that could be the issue, but the same problem occurs.
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

amraalic
In reply to this post by mojavelinux
Dan,

Tried that too .. No changes, unfortunately.

I will try to build another project from the beginning and see if there is any progress.

Thanks.  
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

abelsromero
Have you tried any of the other `convert` methods?
Maybe it has something to do with being unable to open the file or something. Maybe permissions, or some other process has a hold on it.
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

amraalic
Tried that too, without success.

It works on Linux, I just have to figure out what installation is missing on Windows platform.
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

abelsromero
amraalic wrote
It works on Linux, I just have to figure out what installation is missing on Windows platform.
The thing is that you can use Asciidoctorj (and asciidoctor-pdf) without installing anything else. Just declaring the proper dependencies is enough. Following the advice of Dan about the Asciidoctor instance creation should create an independent execution environment.
But if you instantiate it in another way or use the require method incorrectly, it can become messy and installed gems can get in the way.

Without more information and being unable to reproduce the issue myself, the only thing I can think of is to check the classpath. Maybe an old version of asciidoctorj is included?
Btw, were you able to download the demo project I created and execute it? I run it on a Win8.1 machine and it worked.
Reply | Threaded
Open this post in threaded view
|

Re: NoMethodError at convertFIle

mojavelinux
Administrator

On Sun, Feb 14, 2016 at 9:21 AM, abelsromero [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Btw, were you able to download the demo project I created and execute it? I run it on a Win8.1 machine and it worked.

This is very sound advice. Whenever you are debugging something, it's always good to start from something that works and move towards what you're trying to create. That way, you can detect the culprit as soon as it appears. It's almost impossible to figure out what is wrong just by moving knobs and switches. In other words, the key to debugging is finding out what is different between your environment and the environment that works.

-Dan


--
Dan Allen | @mojavelinux | http://google.com/profiles/dan.j.allen