Update: This problem has been fixed in Java CAPS 5.1.3 Update 3
I'm getting this error in the log when I'm trying to compile my project that makes use of the BAPI eWay:
[CODELET] com.stc.otd.codegen.OtdCodeGenException: javaClass: BapiOtdGenerator.validateSapJars(): The following .jar file(s) need to be part of the JVM environment before source code can be compiled: sapjco.jar. See documentation for more information.
[CODELET] at com.stc.sapbapi.codegen.bapi.BapiOtdGenerator.validateSapJars(BapiOtdGenerator.java:233)
[CODELET] at com.stc.sapbapi.codegen.bapi.BapiOtdGenerator.compile(BapiOtdGenerator.java:170)
[CODELET] at com.stc.sapbapi.codegen.bapi.BapiOtdGenerator.generate(BapiOtdGenerator.java:312)
[CODELET] at com.stc.otd.codegen.BaseGenerator.generate(BaseGenerator.java:255)
[CODELET] at com.stc.sapbapi.codegen.SAPEWayCodeletBase$OutboundCodelet$SAPOutboundJCECodelet.generateOtdJarFile(SAPEWayCodeletBase.java:873)
[CODELET] at com.stc.sapbapi.codegen.SAPEWayCodeletBase$OutboundCodelet$SAPOutboundJCECodelet.generateFiles(SAPEWayCodeletBase.java:924)
[CODELET] at com.stc.codegen.anttaskImpl.driver.CodeletProcessor.execute(CodeletProcessor.java:89)
[CODELET] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[CODELET] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[CODELET] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[CODELET] at java.lang.reflect.Method.invoke(Method.java:585)
[CODELET] at com.stc.codegen.anttaskImpl.CodeGenAntTaskImpl.execute(CodeGenAntTaskImpl.java:117)
[CODELET] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[CODELET] at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
[CODELET] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[CODELET] at java.lang.reflect.Method.invoke(Method.java:585)
[CODELET] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[CODELET] at org.apache.tools.ant.Task.perform(Task.java:348)
[CODELET] at org.apache.tools.ant.Target.execute(Target.java:357)
[CODELET] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[CODELET] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[CODELET] at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
[CODELET] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[CODELET] at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
[CODELET] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
[CODELET] at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
[CODELET] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[CODELET] at java.lang.reflect.Method.invoke(Method.java:585)
[CODELET] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
[CODELET] at org.apache.tools.ant.Task.perform(Task.java:348)
[CODELET] at org.apache.tools.ant.Target.execute(Target.java:357)
[CODELET] at org.apache.tools.ant.Target.performTasks(Target.java:385)
[CODELET] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
[CODELET] at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
[CODELET] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[CODELET] at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
[CODELET] at org.apache.tools.ant.Main.runBuild(Main.java:698)
[CODELET] at org.apache.tools.ant.Main.startAnt(Main.java:199)
[CODELET] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
[CODELET] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
Whenever you have a classpath problem with ant, run the ant command with the -diagnostics flag.
Here is what I get ("." represents irrelevant stuff that I've removed):
$ /export/apache-ant-1.7.0/bin/ant -verbose -lib compile/lib/ext -Dcommandline.dir=. -propertyfile /export/scripts/buildProps/p2pd/build.SEP_CAS_FirstContDate.properties -diagnostics
.
.
.
-------------------------------------------
ANT_HOME/lib jar listing
-------------------------------------------
.
.
.
sapjco.jar (304078 bytes)
.
.
.
-------------------------------------------
USER_HOME/.ant/lib jar listing
-------------------------------------------
.
.
.
sapjco.jar (304078 bytes)
.
.
.
java.class.path : /export/apache-ant-1.7.0/lib/ant-launcher.jar:/export/commandlinecodegen/compile/lib/ext/ldap.jar:/export/commandlinecodegen/compile/lib/ext/com.stc.antlrimpl.jar:/export/commandlinecodegen/compile/lib/ext/sapjco.jar:/export/commandlinecodegen/compile/lib/ext/openide.jar:/export/commandlinecodegen/compile/lib/ext/log4jProperties.jar:/export/commandlinecodegen/compile/lib/ext/commons-logging.jar:/export/commandlinecodegen/compile/lib/ext/log4j.jar:/export/commandlinecodegen/compile/lib/ext:/home/eaiadmin/.ant/lib/sapjco.jar:/export/apache-ant-1.7.0/lib/ant-jai.jar:/export/apache-ant-1.7.0/lib/ant-antlr.jar:/export/apache-ant-1.7.0/lib/ant-starteam.jar:/export/apache-ant-1.7.0/lib/ant-jdepend.jar:/export/apache-ant-1.7.0/lib/ant-apache-oro.jar:/export/apache-ant-1.7.0/lib/ant-trax.jar:/export/apache-ant-1.7.0/lib/ant-apache-regexp.jar:/export/apache-ant-1.7.0/lib/ant-jmf.jar:/export/apache-ant-1.7.0/lib/ant-jsch.jar:/export/apache-ant-1.7.0/lib/ant-apache-bsf.jar:/export/apache-ant-1.7.0/lib/ant-netrexx.jar:/export/apache-ant-1.7.0/lib/ant-swing.jar:/export/apache-ant-1.7.0/lib/sapjco.jar:/export/apache-ant-1.7.0/lib/xercesImpl.jar:/export/apache-ant-1.7.0/lib/ant-apache-bcel.jar:/export/apache-ant-1.7.0/lib/ant-stylebook.jar:/export/apache-ant-1.7.0/lib/ant-javamail.jar:/export/apache-ant-1.7.0/lib/ant-junit.jar:/export/apache-ant-1.7.0/lib/ant-commons-net.jar:/export/apache-ant-1.7.0/lib/ant-commons-logging.jar:/export/apache-ant-1.7.0/lib/ant-weblogic.jar:/export/apache-ant-1.7.0/lib/ant-apache-log4j.jar:/export/apache-ant-1.7.0/lib/ant.jar:/export/apache-ant-1.7.0/lib/xml-apis.jar:/export/apache-ant-1.7.0/lib/ant-nodeps.jar:/export/apache-ant-1.7.0/lib/ant-testutil.jar:/export/apache-ant-1.7.0/lib/ant-launcher.jar:/export/apache-ant-1.7.0/lib/ant-apache-resolver.jar:/export/jdk1.5.0_15/lib/tools.jar
.
.
.
So the sapjco.jar is definitely on the classpath. But why are we getting this error then:
com.stc.otd.codegen.OtdCodeGenException: javaClass: BapiOtdGenerator.validateSapJars(): The following .jar file(s) need to be part of the JVM environment before source code can be compiled: sapjco.jar. See documentation for more information.
In this case we should have a look at the underlying validation mechanism. This is a bit naughty... don't tell your boss. ;)
I use this command to find the jar that contains the BapiOtdGenerator class.
for jar in $(find /export/commandlinecodegen -name "*jar"); do unzip -l $jar|grep BapiOtdGenerator; if [ $? == 0 ]; then echo $jar; fi; done
After that "jad" can be quite helpful.
http://www.kpdus.com/jad.html
Have a look at the validateSapJars method in the resulting BapiOtdGenerator.jad file.
A while back I posted about my frustration of not being able to use the eWay Development Kit under Linux. The reason I was not able to use is was that the developer of the eDK has hard coded all directory paths to use "\" instead of "/". Well, really he should have used java.io.File.pathSeparator. Here we have a very similar problem of developers never being exposed to the world of Linux.
The method in question uses the StringTokenizer class to split the classpatch by ";". Well, that will of course only work on Windows, because Linux uses ":". So no matter where I put the sapjco.jar the validation will never succeed. How unfortunate.
Since the commandlinecodegen is supported on Linux I have no doubt that this bug will be fixed. It's pretty easy to fix after all. In fact, java.lang.System.getProperties() will give you the right value that is needed.
The thing that annoys me the most is that Java was meant to be platform neutral.
So, no commandlinecodegen in Linux for BAPIs then I guess...