ddtalk / HarleyCorp

企业接入的Demo
76 stars 72 forks source link

解决Jboss上无法正常运行的问题“在包[com.dingtalk.open.client.api]下未扫描到任何钉钉开放平台API” #7

Open doveyh opened 7 years ago

doveyh commented 7 years ago

Jboss下运行此Demo,会提示如下错误:

com.dingtalk.open.client.common.SdkInitException: 在包[com.dingtalk.open.client.api]下未扫描到任何钉钉开放平台API

经分析,发现是由于“com.dingtalk.open.client.utils”中的 PackageScan.scan 方法,在读取jar包时少了vfs的判断引起的(ps: Jboss在运行时默认将所有的部署的资源统一放到vfs目录中),修改之前的代码如下: `>......

if ("file".equals(protocol)){ String filePath = URLDecoder.decode(url.getFile(), "UTF-8"); findAndAddClassesInPackageByFile(packageName, filePath, recursive, classes); } else if ("jar".equals(protocol)){ try { JarFile jar = ((JarURLConnection)url.openConnection()).getJarFile(); ......`

修改后的代码如下: `>......

if ("file".equals(protocol)) { String filePath = URLDecoder.decode(url.getFile(), "UTF-8"); findAndAddClassesInPackageByFile(packageName, filePath, recursive, classes); } else if ("jar".equals(protocol) || "vfs".equals(protocol)) { try { JarFile jar = null; URLConnection conn = url.openConnection(); if (conn instanceof JarURLConnection) { jar = ((JarURLConnection) conn).getJarFile(); } else { jar = getAlternativeJarFile(url); } Enumeration entries = jar.entries(); ...... `

doveyh commented 7 years ago

无源代码,无法提交,建议在sdk中修复。