1

I am having issues to use the java program https://github.com/antonydeepak/ResumeParser/ in Django project in a localserver in MAC OS.

I have installed ResumeParser in the Django Project like:

-- Django Project -- app1 -- app2 -- ResumerParser

Here is my code but it says "Could not find or load main class".

if form.is_valid():
 f = form.save(commit=False)
 resume = form.cleaned_data['resume']
 cmd = ['java', '-cp', 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*', 'code4goal.antony.resumeparser.ResumeParserProgram %s textOutput.json' % resume]
 subprocess.Popen(cmd)

Any clues of how to solve this? I've tried every post related to this theme in StackOverflow no success.

Thanks in advance

asked Nov 8, 2016 at 22:56

2 Answers 2

1

You're mixing up well-delimiter parameters with parameters grouped with spaces.

cmd = ['java', '-cp', 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*', 'code4goal.antony.resumeparser.ResumeParserProgram %s textOutput.json' % resume]

Your last parameter is seen as a single parameter and is protected by spaces by subprocess:

"code4goal.antony.resumeparser.ResumeParserProgram resume_value textOutput.json"

=> The whole "class<space>param1<space>param2" is seen as your class: no wonder why it's not found.

Split all your parameters and it will work, subprocess won't group your parameters, no quoting (note the forced conversion of the resume object to str):

cmd = ['java', '-cp', 'bin/:../GATEFiles/lib/:../GATEFiles/bin/gate.jar:lib/*', 'code4goal.antony.resumeparser.ResumeParserProgram', str(resume),'textOutput.json']
answered Nov 8, 2016 at 23:05
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the fast answer. Now I have a new error: execv() arg 2 must contain only strings
sorry! the resume object needed to be converted to a string, see my edit.
0

After two weeks I got it working. All files must be copied to the ResumeParser/ResumeTransducer dir.

Also, there's a need to inform the current dir for file parsing.

Here is the implementation:

# first save the file
if form.is_valid():
 f = form.save(commit=False)
 resume = form.cleaned_data['resume']
 f.resume = resume
 f.save()
 # copy file to the CV parser dir so java can parse the file
 cf = "." + f.resume.url
 shutil.copy2(cf, 'ResumeParser/ResumeTransducer')
 # get file to convert
 fl_name = str(f.resume).split('/')[-1]
 # get file name to make json output
 base_name = os.path.splitext(fl_name)[0]
 cmd = "java -cp 'bin/*:../GATEFiles/lib/*:../GATEFiles/bin/gate.jar:lib/*' code4goal.antony.resumeparser.ResumeParserProgram %s %s.json" % (fl_name, base_name)
 # get the current working dir 
 os.chdir("ResumeParser/ResumeTransducer")
 # call java
 subprocess.Popen(cmd, shell=True)

Thanks Jean-François Fabre!

answered Nov 9, 2016 at 20:22

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.