使用maven时SAP连接器的Munit问题,

eagi6jfj  于 2023-08-03  发布在  Maven
关注(0)|答案(3)|浏览(139)

你好,我面对下面,而运行munit与maven代码。
我有一个包含SAP连接器的流,然后为流做了munit,并尝试用maven运行munit,得到下面的异常,需要帮助。

[ERROR] Failed to shut down registry cleanly: org.mule.Registry.Spring
org.mule.api.lifecycle.LifecycleException: Failed to invoke lifecycle phase "dispose" on object: SapConnector$$EnhancerByCGLIB$$1f197d8f
{
  name=SAP_08
  lifecycle=not in lifecycle
  this=298e706
  numberOfConcurrentTransactedReceivers=4
  createMultipleTransactedReceivers=true
  connected=false
  supportedProtocols=[sap]
  serviceOverrides=<none>
}

    at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:248)
    at org.mule.lifecycle.phases.MuleContextDisposePhase.applyLifecycle(MuleContextDisposePhase.java:102)
    at org.mule.config.spring.SpringRegistryLifecycleManager$SpringContextDisposePhase.applyLifecycle(SpringRegistryLifecycleManager.java:141)
    at org.mule.lifecycle.RegistryLifecycleCallback.doApplyLifecycle(RegistryLifecycleCallback.java:91)
    at org.mule.lifecycle.RegistryLifecycleCallback.onTransition(RegistryLifecycleCallback.java:67)
    at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(RegistryLifecycleManager.java:140)
    at org.mule.lifecycle.RegistryLifecycleManager.fireLifecycle(RegistryLifecycleManager.java:111)
    at org.mule.registry.AbstractRegistry.dispose(AbstractRegistry.java:68)
    at org.mule.registry.AbstractRegistryBroker$2.onTransition(AbstractRegistryBroker.java:69)
    at org.mule.registry.AbstractRegistryBroker$2.onTransition(AbstractRegistryBroker.java:64)
    at org.mule.lifecycle.RegistryLifecycleManager.invokePhase(RegistryLifecycleManager.java:140)
    at org.mule.lifecycle.RegistryBrokerLifecycleManager.fireDisposePhase(RegistryBrokerLifecycleManager.java:82)
    at org.mule.registry.AbstractRegistryBroker.dispose(AbstractRegistryBroker.java:63)
    at org.mule.registry.MuleRegistryHelper.fireLifecycle(MuleRegistryHelper.java:137)
    at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:91)
    at org.mule.lifecycle.MuleContextLifecycleManager$MuleContextLifecycleCallback.onTransition(MuleContextLifecycleManager.java:87)
    at org.mule.lifecycle.MuleContextLifecycleManager.invokePhase(MuleContextLifecycleManager.java:69)
    at org.mule.lifecycle.MuleContextLifecycleManager.fireLifecycle(MuleContextLifecycleManager.java:61)
    at org.mule.DefaultMuleContext.dispose(DefaultMuleContext.java:345)
    at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:230)
    at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81)
    at org.mule.munit.runner.MunitMuleContextFactory.createMuleContext(MunitMuleContextFactory.java:85)
    at org.mule.munit.runner.MuleContextManager.createMule(MuleContextManager.java:97)
    at org.mule.munit.runner.MuleContextManager.startMule(MuleContextManager.java:56)
    at org.mule.munit.runner.mule.MunitSuiteRunner.<init>(MunitSuiteRunner.java:42)
    at org.mule.MUnitMojo.buildRunnerFor(MUnitMojo.java:311)
    at org.mule.MUnitMojo.doExecute(MUnitMojo.java:173)
    at org.mule.MUnitMojo.execute(MUnitMojo.java:122)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: java.lang.ExceptionInInitializerError: JCo initialization failed with java.lang.ExceptionInInitializerError: Illegal JCo archive "sapjco3-3.0.13.jar". It is not allowed to rename or repackage the original archive "sapjco3.jar".
    at com.sap.conn.jco.rt.MiddlewareJavaRfc.<clinit>(MiddlewareJavaRfc.java:230)
    at com.sap.conn.jco.rt.DefaultJCoRuntime.initialize(DefaultJCoRuntime.java:98)
    at com.sap.conn.jco.rt.JCoRuntimeFactory.<clinit>(JCoRuntimeFactory.java:23)
    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:379)
    at com.sap.conn.jco.ext.Environment.getInstance(Environment.java:155)
    at com.sap.conn.jco.ext.Environment.isDestinationDataProviderRegistered(Environment.java:401)
    at com.mulesoft.mule.transport.sap.jco3.SapJcoFactory.startup(SapJcoFactory.java:198)
    at com.mulesoft.mule.transport.sap.jco3.SapJcoFactory.<clinit>(SapJcoFactory.java:45)
    at com.mulesoft.mule.transport.sap.SapConnector.doDispose(SapConnector.java:198)
    at com.mulesoft.mule.transport.sap.SapConnector$$EnhancerByCGLIB$$1f197d8f.CGLIB$doDispose$4(<generated>)
    at com.mulesoft.mule.transport.sap.SapConnector$$EnhancerByCGLIB$$1f197d8f$$FastClassByCGLIB$$c6f1beab.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
    at org.mule.modules.interceptor.connectors.ConnectorMethodInterceptor.intercept(ConnectorMethodInterceptor.java:48)
    at com.mulesoft.mule.transport.sap.SapConnector$$EnhancerByCGLIB$$1f197d8f.doDispose(<generated>)
    at org.mule.transport.AbstractConnector$4.onTransition(AbstractConnector.java:596)
    at org.mule.transport.AbstractConnector$4.onTransition(AbstractConnector.java:592)
    at org.mule.lifecycle.AbstractLifecycleManager.invokePhase(AbstractLifecycleManager.java:138)
    at org.mule.transport.ConnectorLifecycleManager.fireDisposePhase(ConnectorLifecycleManager.java:89)
    at org.mule.transport.AbstractConnector.dispose(AbstractConnector.java:591)
    at sun.reflect.GeneratedMethodAccessor94.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.mule.lifecycle.phases.DefaultLifecyclePhase.applyLifecycle(DefaultLifecyclePhase.java:237)
    ... 48 more
[INFO] Closing org.mule.munit.runner.spring.config.MunitApplicationContext@53830ac9: startup date [Tue Sep 20 16:30:07 IST 2016]; root of context hierarchy
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 38.910s
[INFO] Finished at: Tue Sep 20 16:30:19 IST 2016
[INFO] Final Memory: 76M/269M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.mulesoft.munit.tools:munit-maven-plugin:1.1.0:test (test) on project mule_onprem_to_sap: Execution test of goal com.mulesoft.munit.tools:munit-maven-plugin:1.1.0:test failed: org.mule.api.config.ConfigurationException: Failed to invoke lifecycle phase "initialise" on object: SapConnector$$EnhancerByCGLIB$$1f197d8f
[ERROR] {
[ERROR] name=SAP_08
[ERROR] lifecycle=not in lifecycle
[ERROR] this=298e706
[ERROR] numberOfConcurrentTransactedReceivers=4
[ERROR] createMultipleTransactedReceivers=true
[ERROR] connected=false
[ERROR] supportedProtocols=[sap]
[ERROR] serviceOverrides=<none>
[ERROR] }
[ERROR] (org.mule.api.lifecycle.InitialisationException): org/mule/module/reboot/EEMuleContainerBootstrap: org.mule.module.reboot.EEMuleContainerBootstrap
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

字符串

6fe3ivhb

6fe3ivhb1#

@Ankit Prakash这是SAP maven依赖性问题。
为了克服SAP JCo和Maven的限制,您必须遵循下面描述的步骤,并获得能够在Studio中运行的项目:

1 -将资源安装到本地Maven存储库

下面指定的命令是将jar和本机库安装到本地Maven存储库中所必需的。请注意,我们将展示如何安装MaOS 64位、Linux x86 64位和Windows 64位的原生库。
sapidoc3.jar,版本3.0.12:第一个月
sapjco3.jar,版本3.0.14:mvn install:install-file -DgroupId=com.sap.conn.jco -DartifactId=sapjco3 -Dversion=3.0.14 -Dpackaging=jar -Dfile=sapjco3.jar
原生库MacOS 64位,版本3.0.14:mvn install:install-file -DgroupId=com.sap.conn.jco -DartifactId=sapjco3 -Dversion=3.0.14 -Dclassifier=darwinintel64 -Dpackaging=jnilib -Dfile=libsapjco3.jnilib
原生库Linux x86 64位,版本3.0.14:mvn install:install-file -DgroupId=com.sap.conn.jco -DartifactId=sapjco3 -Dversion=3.0.14 -Dclassifier=linuxx86_64 -Dpackaging=so -Dfile=libsapjco3.so
原生库Windows AMD 64位,版本3.0.14:mvn install:install-file -DgroupId=com.sap.conn.jco -DartifactId=sapjco3 -Dversion=3.0.14 -Dclassifier=ntamd64 -Dpackaging=dll -Dfile=sapjco3.dll
执行上述步骤后,包含sapjco 3版本3.0.14资源的文件夹将包含以下文件:
~/.m2/repository/com/sap/conn/jco/sapjco3/3.0.14

  • sapjco3-3.0.14-darwinintel64.jnilib
  • sapjco3-3.0.14.jar
  • sapjco3-3.0.14-NTAMD64.dll
  • sapjco3-3.0.14-linux86_64.so
  • sapjco3-3.0.14.pom

类似地,包含sapidoc 3版本3.0.12资源的文件夹将包含以下文件:
~/.m2/repository/com/sap/conn/idoc/sapidoc3/3.0.12

  • sapidoc3-3.0.12.jar
  • sapidoc3-3.0.12.pom
    2 -使用提供的POM

使用附加的POM作为所有使用MuleSoft Connector for SAP解决方案的应用程序的基础。
请注意,我们正在使用基于操作系统和体系结构自动激活的配置文件来设置将要使用的本机库的名称。
我们还创建了一个名为studio的概要文件,每当您需要将所有jar和相应的本地库包含到部署归档文件中时,您必须激活它,而部署归档文件将在您运行maven clean package命令时生成。

3 -将原生库复制到Studio项目中

在mavenized Studio项目的根级别创建一个名为lib的目录,并将本地库复制到那里。在生成和打包应用程序时,该文件夹的内容不会包含在部署归档文件中。

4 -更改Maven设置以激活工作室配置文件

  • 转到运行->运行配置...
  • 选择您的mavenized项目
  • 转到Maven设置选项卡
  • 输入以下参数:-Druntime=studio

希望这对你有帮助。

u2nhd7ah

u2nhd7ah2#

这是一个老问题,但以防万一有人遇到这个问题,然后在下面添加依赖性。请注意,该范围是测试的,因为在运行时不需要它。

<dependency>
        <groupId>com.mulesoft.muleesb.modules</groupId>
        <artifactId>mule-module-boot-ee</artifactId>
        <scope>test</scope>
    </dependency>

字符串

0tdrvxhp

0tdrvxhp3#

  • 我得到了关于SAP jar的Munit问题的答案。*

请按照以下步骤解决此问题:-
1.将SAP库添加到类路径:
(a)导航至构建路径>配置构建路径
(b)在库选项卡中,单击添加库...按钮
(c)选择任意点连接器依赖项
(d)选择SAP连接器选项。
1.您可能还需要使java.library.path指向本地库所在的文件夹。MUnit Studio插件将尝试查找这些本地库,并在您尝试运行测试时自动配置它们。如果没有找到它们,您需要在运行配置中添加以下vm参数:
(a)在Studio的顶部导航栏中,单击运行
(b)单击运行配置...
(c)选择参数选项卡
(d)在“VM参数”对话框中,键入库的路径,并使用

java.library.path argument.
Example: -Djava.library.path=path/to/lib

字符串
x1c 0d1x的数据

来自Maven

将库添加到类路径的一种方法是在maven插件中使用additionalClasspathElements参数。您可以提供要添加的每个SAP库的路径:

<additionalClasspathElements>
    <additionalClasspathElement>/path/to/lib/sapjco3.jar</additionalClasspathElement> 
    <additionalClasspathElement>/path/to/lib/sapidoc3.jar</additionalClasspathElement>
</additionalClasspathElements>

注意:-如果pom中已经存在sap依赖项,但库名称与SAP命名限制不匹配,则可能需要将其排除在测试运行之外。这样,使用additionalClassPathElement参数添加的库将优先:

<classpathDependencyExcludes> 
    <classpathDependencyExclude>com.sap.conn.idoc:sapidoc3</classpathDependencyExclude>  
    <classpathDependencyExclude>com.sap.conn.jco:sapjco3</classpathDependencyExclude>
</classpathDependencyExcludes>


此外,您需要使java.library.path属性指向本机库目录,类似于Studio中的操作。要实现这一点,可以使用argLine参数添加额外的vm参数。

<argLines>
    <argLine>-Djava.library.path=/path/to/native/lib/folder</argLine>
</argLines>

相关问题