forge / plugin-hibersap

Hibersap Plugin
GNU Lesser General Public License v3.0
8 stars 12 forks source link

SAP Entity Generator Exception #17

Open gvsrini opened 9 years ago

gvsrini commented 9 years ago

I installed generate-sap-entities in forge and I am able to "list" properties as shown below. After having set my properties, when I go to fetch BAPI's, it is throwing a ClassNotFoundException.

New to Forge, so have no clue if we need to set CLASSPATH somewhere. Any help will be highly appreciated.

[wicketsap] wicketsap $ generate-sap-entities list-properties
jco.destination.pool_capacity=1
jca.connectionspec.factory=org.hibersap.execution.jca.cci.SapBapiJcaAdapterConnectionSpecFactory
session-manager.name=SM001
jco.client.lang=en
jco.client.ashost=192.168.1.10
jco.client.user=user
jco.client.sysnr=00
jca.context=org.hibersap.execution.jco.JCAContext
jco.context=org.hibersap.execution.jco.JCoContext
jco.client.passwd=password
jco.client.client=001
jca.connection.factory=java:jboss/eis/sap/NSP

[wicketsap] wicketsap $ generate-sap-entities --name-pattern BAPI?FLC*
***ERROR*** Exception encountered: (type "set VERBOSE false" to disable stack traces)
java.lang.NoClassDefFoundError: Could not initialize class com.sap.conn.jco.rt.JCoRuntimeFactory
        at com.sap.conn.jco.rt.RuntimeEnvironment.<init>(RuntimeEnvironment.java:43)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        at java.lang.Class.newInstance(Class.java:374)
        at com.sap.conn.jco.ext.Environment.getInstance(Environment.java:155)
        at com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(Environment.java:259)
        at org.hibersap.execution.jco.JCoEnvironment.registerDestinationDataProvider(JCoEnvironment.java:91)
        at org.hibersap.execution.jco.JCoEnvironment.registerDestination(JCoEnvironment.java:57)
        at org.hibersap.execution.jco.JCoContext.configure(JCoContext.java:71)
        at org.hibersap.configuration.ContextFactory.create(ContextFactory.java:47)
        at org.hibersap.configuration.ConfigurationHelper.createContext(ConfigurationHelper.java:42)
        at org.hibersap.configuration.Configuration.buildSessionManager(Configuration.java:120)
        at org.hibersap.configuration.AnnotationConfiguration.buildSessionManager(AnnotationConfiguration.java:95)
        at org.hibersap.forge.GenerateSAPEntitiesPlugin.generateSAPEntities(GenerateSAPEntitiesPlugin.java:174)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.forge.shell.command.Execution.perform(Execution.java:160)
        at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:109)
        at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:47)
        at org.jboss.forge.shell.ShellImpl$ExecutorThread.run(ShellImpl.java:796)
        at org.jboss.forge.shell.ShellImpl.execute(ShellImpl.java:819)
        at org.jboss.forge.shell.ShellImpl.doShell(ShellImpl.java:609)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48)
        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125)
        at org.jboss.forge.shell.ShellImpl$Proxy$_$$_WeldClientProxy.doShell(ShellImpl$Proxy$_$$_WeldClientProxy.java)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305)
        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54)
        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163)
        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299)
        at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188)
        at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59)
        at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198)
        at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282)
        at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265)
        at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234)
        at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635)
        at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622)
        at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616)
        at org.jboss.forge.shell.Bootstrap$1.run(Bootstrap.java:186)
    at java.lang.Thread.run(Thread.java:744)
[wicketsap] wicketsap $
gastaldi commented 9 years ago

Looks like a native library was not loaded, check the logs in ~/.forge/log/forge.log for the stacktace that caused this.

Em 21/02/2015, às 10:35, gvsrini notifications@github.com escreveu:

I installed generate-sap-entities in forge and I am able to "list" properties as shown below. After having set my properties, when I go to fetch BAPI's, it is throwing a ClassNotFoundException.

New to Forge, so have no clue if we need to set CLASSPATH somewhere. Any help will be highly appreciated.

[wicketsap] wicketsap $ generate-sap-entities list-properties jco.destination.pool_capacity=1 jca.connectionspec.factory=org.hibersap.execution.jca.cci.SapBapiJcaAdapterConnectionSpecFactory session-manager.name=SM001 jco.client.lang=en jco.client.ashost=192.168.1.10 jco.client.user=user jco.client.sysnr=00 jca.context=org.hibersap.execution.jco.JCAContext jco.context=org.hibersap.execution.jco.JCoContext jco.client.passwd=password jco.client.client=001 jca.connection.factory=java:jboss/eis/sap/NSP

[wicketsap] wicketsap $ generate-sap-entities --name-pattern BAPI?FLC* _ERROR Exception encountered: (type "set VERBOSE false" to disable stack traces) java.lang.NoClassDefFoundError: Could not initialize class com.sap.conn.jco.rt.JCoRuntimeFactory at com.sap.conn.jco.rt.RuntimeEnvironment.(RuntimeEnvironment.java:43) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at java.lang.Class.newInstance(Class.java:374) at com.sap.conn.jco.ext.Environment.getInstance(Environment.java:155) at com.sap.conn.jco.ext.Environment.registerDestinationDataProvider(Environment.java:259) at org.hibersap.execution.jco.JCoEnvironment.registerDestinationDataProvider(JCoEnvironment.java:91) at org.hibersap.execution.jco.JCoEnvironment.registerDestination(JCoEnvironment.java:57) at org.hibersap.execution.jco.JCoContext.configure(JCoContext.java:71) at org.hibersap.configuration.ContextFactory.create(ContextFactory.java:47) at org.hibersap.configuration.ConfigurationHelper.createContext(ConfigurationHelper.java:42) at org.hibersap.configuration.Configuration.buildSessionManager(Configuration.java:120) at org.hibersap.configuration.AnnotationConfiguration.buildSessionManager(AnnotationConfiguration.java:95) at org.hibersap.forge.GenerateSAPEntitiesPlugin.generateSAPEntities(GenerateSAPEntitiesPlugin.java:174) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.forge.shell.command.Execution.perform(Execution.java:160) at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:109) at org.jboss.forge.shell.command.fshparser.FSHRuntime.run(FSHRuntime.java:47) at org.jboss.forge.shell.ShellImpl$ExecutorThread.run(ShellImpl.java:796) at org.jboss.forge.shell.ShellImpl.execute(ShellImpl.java:819) at org.jboss.forge.shell.ShellImpl.doShell(ShellImpl.java:609) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:48) at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:125) at org.jboss.forge.shell.ShellImpl$Proxy$$$WeldClientProxy.doShell(ShellImpl$Proxy$$$_WeldClientProxy.java) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:305) at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:54) at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:163) at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:299) at org.jboss.weld.introspector.jlr.WeldMethodImpl.invokeOnInstance(WeldMethodImpl.java:188) at org.jboss.weld.introspector.ForwardingWeldMethod.invokeOnInstance(ForwardingWeldMethod.java:59) at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:198) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:282) at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:265) at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:234) at org.jboss.weld.manager.BeanManagerImpl.notifyObservers(BeanManagerImpl.java:635) at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:622) at org.jboss.weld.manager.BeanManagerImpl.fireEvent(BeanManagerImpl.java:616) at org.jboss.forge.shell.Bootstrap$1.run(Bootstrap.java:186) at java.lang.Thread.run(Thread.java:744) [wicketsap] wicketsap $ — Reply to this email directly or view it on GitHub.

gvsrini commented 9 years ago

Thanks for the quick response. I am using forge-distribution-1.4.2.Final and I don't see the log file you mentioned. There is only a runtime.log in this specific version.

The latest version of forge-distribution-2.14.0.Final-offline however produces the log file you mentioned. But the latest version does not seem to support forge git-plugin git://github.com/forge/plugin-hibersap.git, hence I am using the older version. This older version looks to be tested by the plugin as per the plugin's git commit history, hence I am more leaning towards the older version of forge.

There is no additional error log generated by the older version of forge. I seem to be stuck. Forge is making my life difficult!

If it's indeed the native library issue, where do I have to put the sapjco3.dll? Can I copy it manually over to the .forge plugin directory? Do I need to add it to some XML as well?

Really appreciate your help. I am completely stuck at the fag-end of this whole effort.

gvsrini commented 9 years ago

Did further investigation and in summary, older version of Forge installs plugin but fails loading the dependent class with ClassNotFoundException at run-time whereas Forge 2 is not even able to install the same plugin.

I tried to install it using Forge 2 (forge-distribution-2.14.0.Final-offline) using following command:

[wicketsap]$ addon-install-from-git --url https://github.com/gvsrini/plugin-hibersap.git --ref master
...
...
[INFO] --- maven-install-plugin:2.4:install (default-install) @ hibersap-plugin
---
[INFO] Installing C:\Users\PCUser\AppData\Local\Temp\1424584823894-0\target\hibersap-plugin.jar to C:\Users\PCUser\.m2\repository\org\hibersap\forge\hibersap-plugin\1.1.0-SNAPSHOT\hibersap-plugin-1.1.0-SNAPSHOT.jar
[INFO] Installing C:\Users\PCUser\AppData\Local\Temp\1424584823894-0\pom.xml to C:\Users\PCUser\.m2\repository\org\hibersap\forge\hibersap-plugin\1.1.0-SNAPSHOT\hibersap-plugin-1.1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.301 s
[INFO] Finished at: 2015-02-21T22:00:41-08:00
[INFO] Final Memory: 50M/254M
[INFO] ------------------------------------------------------------------------
***INFO*** Installing Addon from Git:Removing previous addon installation (org.hibersap.forge:hibersap-plugin,1.1.0-SNAPSHOT)   [2/4] ...
***INFO*** Installing Addon from Git:Installing addon (org.hibersap.forge:hibersap-plugin,1.1.0-SNAPSHOT)       [3/4] ...
***ERROR*** Addon org.hibersap.forge:hibersap-plugin,1.1.0-SNAPSHOT could not be installed: org.eclipse.aether.resolution.DependencyResolutionException: Failure  to find org.hibersap.forge:hibersap-plugin:jar:forge-addon:1.1.0-SNAPSHOT in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
gastaldi commented 9 years ago

The plugin is not compatible with Forge 2. @ivannov is the lead maintainer of this plugin and can give you more information

Em 21/02/2015, às 14:34, gvsrini notifications@github.com escreveu:

Did further investigation and in summary, older version of Forge installs plugin but fails loading the dependent class with ClassNotFoundException at run-time whereas Forge 2 is not even able to install the same plugin.

I tried to install it using Forge 2 (forge-distribution-2.14.0.Final-offline) using following command:

[wicketsap]$ addon-install-from-git --url https://github.com/gvsrini/plugin-hibersap.git --ref master ... ...

[INFO] --- maven-install-plugin:2.4:install (default-install) @ hibersap-plugin

[INFO] Installing C:\Users\PCUser\AppData\Local\Temp\1424584823894-0\target\hibersap-plugin.jar to C:\Users\PCUser.m2\repository\org\hibersap\forge\hibersap-plugin\1.1.0-SNAPSHOT\hibersap-plugin-1.1.0-SNAPSHOT.jar [INFO] Installing C:\Users\PCUser\AppData\Local\Temp\1424584823894-0\pom.xml to C:\Users\PCUser.m2\repository\org\hibersap\forge\hibersap-plugin\1.1.0-SNAPSHOT\hibersap-plugin-1.1.0-SNAPSHOT.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.301 s [INFO] Finished at: 2015-02-21T22:00:41-08:00 [INFO] Final Memory: 50M/254M [INFO] ------------------------------------------------------------------------ _INFO_ Installing Addon from Git:Removing previous addon installation (org.hibersap.forge:hibersap-plugin,1.1.0-SNAPSHOT) [2/4] ... _INFO_ Installing Addon from Git:Installing addon (org.hibersap.forge:hibersap-plugin,1.1.0-SNAPSHOT) [3/4] ... _ERROR_ Addon org.hibersap.forge:hibersap-plugin,1.1.0-SNAPSHOT could not be installed: org.eclipse.aether.resolution.DependencyResolutionException: Failure to find org.hibersap.forge:hibersap-plugin:jar:forge-addon:1.1.0-SNAPSHOT in http://repo1.maven.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced

— Reply to this email directly or view it on GitHub.

gvsrini commented 9 years ago

I reverted back to the Forge 1.4.2 and this is the exception shown. This appears to be a problem from SAP library, not a Forge plugin issue.

Based on info from here (http://stackoverflow.com/questions/24765243/sapjco-3-0-11-with-maven-it-is-not-allowed-to-rename-or-repackage-the-original), SAP does not seem to be allowing renaming the jar (to suit Maven notations). My SAP JCo version is 3.0.12 and the problem mentioned in SO refers to 3.0.11. My hunch is that this "feature" has been introduced in newer versions of SAP JCo.

Can someone suggest how we can use a Non-mavenized SAP JCo jar in Forge environment.

***ERROR*** Exception encountered: JCo initialization failed with java.lang.ExceptionInInitializerError: Illegal JCo archive "sap-jco-3.0.12.jar". It is not allowed to rename or repackage the original archive "sapjco3.jar". (type "set VERBOSE true" to enable stack traces)
gvsrini commented 9 years ago

Confirmed. The generator runs fine with sap-jco 3.0.7 version, but not with 3.0.12. It appears sapjco3.jar file name is not supposed to be changed [to sap-jco-3.0.xx.jar] in the new scheme of things.

cerker commented 9 years ago

This is an issue starting with SAP JCo 3.11.0. It now checks if the jar name is sapjco3.jar. See also https://sourceforge.net/p/hibersap/discussion/813164/thread/52913577/

Handling the JCo dependencies with Maven already was a bit complicated since they can not be found in any public Maven repo, now they made it even worse. Hope it works with the suggestion in the above mentioned sourceforge discussion topic.