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

时间:2016-09-20 11:25:00

标签: maven mule sap munit

嗨我在使用maven代码运行munit时面对下面的问题 我有一个包含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

3 个答案:

答案 0 :(得分:0)

@Ankit Prakash这是SAP maven依赖问题。

您必须按照下面描述的步骤克服SAP JCo和Maven所施加的限制,并获得能够在Studio中运行的项目:

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

下面指定的命令是将jar和本机库安装到本地Maven存储库中所必需的。请注意,我们将展示如何为MaOS 64位,Linux x86 64位和Windows 64位安装本机库。

sapidoc3.jar,版本3.0.12: mvn install:install-file -DgroupId=com.sap.conn.idoc -DartifactId=sapidoc3 -Dversion=3.0.12 -Dpackaging=jar -Dfile=sapidoc3.jar

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

按照上述步骤操作后,包含sapjco3版本3.0.14资源的文件夹将包含以下文件:

〜/ .m2目录/库/ COM / SAP /康恩/ 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-linuxx86_64.so
  • sapjco3-3.0.14.pom

同样,包含sapidoc3版本3.0.12资源的文件夹将包含以下文件:

〜/ .m2目录/库/ COM / SAP /康恩/ IDOC / sapidoc3 / 3.0.12

  • sapidoc3-3.0.12.jar
  • sapidoc3-3.0.12.pom

2 - 使用提供的POM

使用附加的POM作为使用MuleSoft Connector for SAP Solutions的所有应用程序的基础。

请注意,我们正在使用基于操作系统和体系结构自动激活的配置文件来设置将使用的本机库的名称。

我们还创建了一个名为 studio 的配置文件,无论何时需要将所有jar和相应的本机库包含到部署存档中,只要运行命令{{}},就必须激活该配置文件。 1}}。

3 - 将本机库复制到Studio项目

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

4 - 更改Maven设置以激活工作室个人资料

  • 转到“运行” - >运行配置......
  • 选择您的mavenized项目
  • 转到Maven设置标签
  • 输入以下参数:maven clean package

希望这有帮助。

答案 1 :(得分:0)

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

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

答案 2 :(得分:-1)

我通过SAP jars得到了Munit问题的答案。

请按照以下步骤解决此问题: -

  1. 将SAP库添加到类路径中:

    (a)导航至构建路径&gt;配置构建路径

    (b)在“库”选项卡中,单击“添加库...”按钮

    (c)选择Anypoint Connectors Dependencies

    (d)选择SAP Connector选项。

  2. 您可能还需要将java.library.path指向其中的文件夹 本地库位于。 MUnit Studio插件将尝试找到这些 本机库并在您尝试运行时自动配置它们 试验。如果找不到它们,则需要添加以下vm参数 在运行配置中:

    (a)在Studio的顶部导航栏中,点击“运行”

    (b)单击“运行配置...”

    (c)选择Arguments选项卡

    (d)在“VM参数”对话框中,使用

    键入库的路径
    java.library.path argument.
    Example: -Djava.library.path=path/to/lib
    
  3. JVM Argument

    来自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>
    

    我希望上面的描述会有所帮助。

    有关详细信息,请参阅链接: - Munit with SAP jars