Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
andreshume
Contributor II
Contributor II

Main class not found on Build Project

Hi community,

 

I'm using Talent Open Studio 7.1 in a Mac OS X Mojave with JDK 1.8.

On the editor my jobs work like magic, but when I build the Job and export it to a jar file; I get an error while trying to execute the .sh file.

 

It is a classic Java error saying that there is no main class.

 

I've been reading several posts, some outdated (TOS v5, v6) but none of those solutions worked out for me. Can anyone help me?

 

I'm attaching the return information from the console.

0683p000009M2Vn.png

Switching to a Java perspective I can see that there are some issues with the pom.xml; is this of any help?

0683p000009M2Oi.png

 

Thanks to everyone!

 

Labels (2)
1 Solution

Accepted Solutions
andreshume
Contributor II
Contributor II
Author

Sabrina,

 

Thank you very much for your time. I will try your solution so as to give feedback on this matter.

The original problem was with a custome Code I wrote for a project; at least this was the module that was causing the problem. Whether is right or wrong, adding a

public static void main(){}

to the class made the trick, the project compiled ok and I was able to run the jar file from the command line as well as from a script I wrote for an application.

 

Let me know if this is Ok or if there is another way of solving this.

 

Thank you very much,

Andrés

View solution in original post

6 Replies
Anonymous
Not applicable

Hello,

Before building your Job, could you please go to Window > Preferences, select Talend > Import/Export, and then select the Add classpath jar in exported jobs check box to wrap the Jars in a classpath.jar file added to the built Job?

Let us know if it is OK with you.

Best regards

Sabrina

Anonymous
Not applicable

Hello,

Is there any update for your issue?

Best regards

Sabrina

andreshume
Contributor II
Contributor II
Author

Sabrina,

 

Thank you very much for your time. I will try your solution so as to give feedback on this matter.

The original problem was with a custome Code I wrote for a project; at least this was the module that was causing the problem. Whether is right or wrong, adding a

public static void main(){}

to the class made the trick, the project compiled ok and I was able to run the jar file from the command line as well as from a script I wrote for an application.

 

Let me know if this is Ok or if there is another way of solving this.

 

Thank you very much,

Andrés

Fish3
Contributor
Contributor


@xdshi wrote:

Hello,

Before building your Job, could you please go to Window > Preferences, select Talend > Import/Export, and then select the Add classpath jar in exported jobs check box to wrap the Jars in a classpath.jar file added to the built Job?

Let us know if it is OK with you.

Best regards

Sabrina


I had been looking for a couple of days on this one. Thanks!

john_cornelius
Contributor II
Contributor II

OP was on a mac your suggestion to go to window would not work.

I have a similar problem.

I'm working on a Mac OS X High Sierra with version 7.2 of TOS for Data Integration.

Everything appears to work fine in studio.  I can create design new jobs and open existing ones.

When I try to export a job using build job I'm able to pick an archive directory and start to build the job.  Before the build process finishes I get an error message 'An error occurred. Failed to generate code.'

Hope you have some suggestions.

Thanks in advance.

John

 

org.talend.commons.exception.PersistenceException: org.talend.designer.runprocess.ProcessorException: Failed to generate code.
at org.talend.repository.ui.wizards.exportjob.scriptsmanager.BuildJobManager.buildJob(BuildJobManager.java:303)
at org.talend.repository.ui.wizards.exportjob.scriptsmanager.BuildJobManager.buildJob(BuildJobManager.java:211)
at org.talend.repository.ui.wizards.exportjob.scriptsmanager.BuildJobManager.buildJobs(BuildJobManager.java:126)
at org.talend.repository.ui.wizards.exportjob.JobScriptsExportWizardPage.buildJobWithMaven(JobScriptsExportWizardPage.java:1561)
at org.talend.repository.ui.wizards.exportjob.JobScriptsExportWizardPage$9.run(JobScriptsExportWizardPage.java:1446)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.talend.designer.runprocess.ProcessorException: Failed to generate code.
at org.talend.designer.runprocess.java.JavaProcessor.generateCode(JavaProcessor.java:637)
at org.talend.designer.runprocess.maven.MavenJavaProcessor.generateCode(MavenJavaProcessor.java:82)
at org.talend.designer.runprocess.ProcessorUtilities.generateContextInfo(ProcessorUtilities.java:890)
at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:1175)
at org.talend.designer.runprocess.ProcessorUtilities.generateNodeInfo(ProcessorUtilities.java:1521)
at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:1135)
at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:961)
at org.talend.designer.runprocess.ProcessorUtilities.generateCode(ProcessorUtilities.java:1774)
at org.talend.repository.ui.wizards.exportjob.handler.BuildJobHandler.generateJobFiles(BuildJobHandler.java:181)
at org.talend.repository.ui.wizards.exportjob.handler.AbstractBuildJobHandler.prepare(AbstractBuildJobHandler.java:404)
at org.talend.repository.ui.wizards.exportjob.scriptsmanager.BuildJobManager$1.run(BuildJobManager.java:263)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2295)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2322)
at org.talend.repository.ui.wizards.exportjob.scriptsmanager.BuildJobManager.buildJob(BuildJobManager.java:297)
... 5 more
Caused by: org.talend.designer.codegen.exception.CodeGeneratorException: org.eclipse.emf.codegen.jet.JETException: InvocationTargetException
at org.talend.designer.codegen.CodeGenerator.instantiateJetProxy(CodeGenerator.java:476)
at org.talend.designer.codegen.CodeGenerator.generateTypedComponentCode(CodeGenerator.java:464)
at org.talend.designer.codegen.CodeGenerator.generateTypedComponentCode(CodeGenerator.java:421)
at org.talend.designer.codegen.CodeGenerator.generateTypedComponentCode(CodeGenerator.java:407)
at org.talend.designer.codegen.CodeGenerator.generatesTreeCode(CodeGenerator.java:779)
at org.talend.designer.codegen.CodeGenerator.generateComponentsCode(CodeGenerator.java:537)
at org.talend.designer.codegen.CodeGenerator.generateComponentsCode(CodeGenerator.java:511)
at org.talend.designer.codegen.CodeGenerator.generateProcessCode(CodeGenerator.java:231)
at org.talend.designer.runprocess.java.JavaProcessor.generateCode(JavaProcessor.java:634)
... 18 more
Caused by: org.eclipse.emf.codegen.jet.JETException: InvocationTargetException
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:466)
at org.talend.designer.codegen.config.TalendJetEmitter.generate(TalendJetEmitter.java:684)
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:438)
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:429)
at org.talend.designer.codegen.proxy.JetProxy.generate(JetProxy.java:54)
at org.talend.designer.codegen.CodeGenerator.instantiateJetProxy(CodeGenerator.java:473)
... 26 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.eclipse.emf.codegen.jet.JETEmitter.generate(JETEmitter.java:458)
... 31 more
Caused by: java.lang.Error: Unresolved compilation problem:
The method contains(CharSequence) from the type String refers to the missing type CharSequence

at org.talend.designer.codegen.translators.common.Subtree_beginJava.generate(Subtree_beginJava.java:63)
... 36 more

john_cornelius
Contributor II
Contributor II

To be clear I tried the suggestion to add classpath jar in exported jobs but am still getting the same error.

Additionally this is what my log looks like

eclipse.buildId=unknown
java.version=1.8.0_171
java.vendor=Oracle Corporation
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Framework arguments: -keyring /Users/johncornelius/.eclipse_keyring -showlocation
Command-line arguments: -os macosx -ws cocoa -arch x86_64 -keyring /Users/johncornelius/.eclipse_keyring -showlocation

!ENTRY org.eclipse.compare.win32 4 0 2020-01-21 09:01:11.595
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.eclipse.compare.win32 [4]
Unresolved requirement: Require-Capability: eclipse.platform; filter:="(osgi.os=win32)"

at org.eclipse.osgi.container.Module.start(Module.java:451)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1783)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1762)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1725)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1656)
at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:343)