I created a project and a service bean.
In my bean, I have
import com.jujuworkflow.PDI.*;
but when I go to start the application server in Studio, it fails. In the log I see the following:
2015-12-14 19:26:14,183 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] :app-core:compileJavaC:\Users\Francis\studio-projects\jujuflow\modules\core\src\com\company\jujuflow\service\PDIServiceBean.java:7: error: package com.jujuworkflow.PDI does not exist
2015-12-14 19:26:14,184 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] import com.jujuworkflow.PDI.*;
2015-12-14 19:26:14,185 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] ^
2015-12-14 19:26:14,241 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] C:\Users\Francis\studio-projects\jujuflow\modules\core\src\com\company\jujuflow\service\PDIServiceBean.java:40: error: cannot find symbol
2015-12-14 19:26:14,244 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] JujuPDI.ExecuteJob(migrationJob, variables,parameters);
2015-12-14 19:26:14,245 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] ^
2015-12-14 19:26:14,247 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] symbol: variable JujuPDI
2015-12-14 19:26:14,248 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] location: class PDIServiceBean
2015-12-14 19:26:14,249 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] Note: C:\Users\Francis\studio-projects\jujuflow\modules\core\src\com\company\jujuflow\service\PDIServiceBean.java uses unchecked or unsafe operations.
2015-12-14 19:26:14,250 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] Note: Recompile with -Xlint:unchecked for details.
2015-12-14 19:26:14,251 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] 2 errors
2015-12-14 19:26:14,259 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] FAILED
2015-12-14 19:26:14,261 DEBUG [com.haulmont.studio.ui.app.ConsolePanel]
2015-12-14 19:26:14,264 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] FAILURE: Build failed with an exception.
2015-12-14 19:26:14,265 DEBUG [com.haulmont.studio.ui.app.ConsolePanel]
2015-12-14 19:26:14,266 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] * What went wrong:
2015-12-14 19:26:14,268 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] Execution failed for task ':app-core:compileJava'.
2015-12-14 19:26:14,269 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] > Compilation failed; see the compiler error output for details.
2015-12-14 19:26:14,271 DEBUG [com.haulmont.studio.ui.app.ConsolePanel]
2015-12-14 19:26:14,272 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] * Try:
2015-12-14 19:26:14,274 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
2015-12-14 19:26:14,275 DEBUG [com.haulmont.studio.ui.app.ConsolePanel]
2015-12-14 19:26:14,277 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] BUILD FAILED
2015-12-14 19:26:14,279 DEBUG [com.haulmont.studio.ui.app.ConsolePanel]
2015-12-14 19:26:14,280 DEBUG [com.haulmont.studio.ui.app.ConsolePanel] Total time: 2.744 secs
Even though in IntelliJ it doesn’t report any errors as I was able to successfully add the JAR, I wonder where it should be placed for a CUBA project.
Perhaps you have directly added your JAR as a module dependency to your project structure in IntelliJ. That’s why it does not report any errors. But Gradle does not know about this dependency and cannot assemble the project. So you have to add the JAR to build.gradle.
If your JAR can be found in a Maven repository (local or Maven Central), just add a dependency for the “core” module:
In Studio, go to Project Properties > Edit > Advanced
Add compile dependency for “core” module and specify its coordinates, like “activemq:activemq-client:5.13.0”
After saving changes, Gradle will recompile the project and recreate IntelliJ files.
If you have a standalone JAR, you have to add a file-based repository to build.gradle manually, for example:
After that, place your JAR into this directory and specify the dependency as described above. The coordinates must contain at least two parts: “mylibrary:myfile”, where “mylibrary” is an arbitrary group (it is ignored) and “myfile” - name of the JAR file (myfile.jar).
correction: the above solved my problem in the sense that now, the application server starts, but I’m encountering this new issue.
when i create my object and save it, I’m trying to invoke my code, but I get the following message:
java.lang.ClassNotFoundException: org.pentaho.di.core.exception.KettleException
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at com.company.jujuflow.service.PDIServiceBean.ExecutePDIJob(PDIServiceBean.java:40)
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:497)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85)
at com.haulmont.cuba.core.sys.ServiceInterceptor.aroundInvoke(ServiceInterceptor.java:64)
at sun.reflect.GeneratedMethodAccessor105.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
My JAR file (jujuPDI.jar) depends on other JAR files. Do I have to put those other JAR files in the same path as my JAR file and add all of those as dependencies as well?
Sure. If you use the directory-based repository, you have to include all dependencies manually.
When you use Maven artifacts with properly configured pom.xml files, transitive dependencies are loaded automatically.