Could not initialize class com.microsoft.cognitiveservices.speech.SpeechConfig on contos7
在本机win10 上 运行是 正常的
但是 软件打war包 后 到服务器上centos运行报错
Could not initialize class com.microsoft.cognitiveservices.speech.SpeechConfig
看了很多说明,尝试各种方式步骤 还是不行。
有没有详细点的检查教程啊?
研究了快一个月了。崩溃。。。。。
Azure AI Speech
-
navba-MSFT 24,625 Reputation points • Microsoft Employee
2023-11-20T04:36:48.34+00:00 @迪迪 徐 Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
I understand that you are reporting an error message
Could not initialize class com.microsoft.cognitiveservices.speech.SpeechConfig
when trying to run a software on a CentOS server.Make sure all the dependencies are installed correctly. These are mentioned clearly in this article.
Then you need to follow the pre-requisites and platform requirements for the
com.microsoft.cognitiveservices.speech
JAVA SDK inorder to use on CentOS7. Follow this article.I am able to successfully use the JAVA Speech SDK on CentOS 7 by following the above 2 articles.
Hope this helps. If you have any follow-up questions, please let me know. I would be happy to help.
**
Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members. -
迪迪 徐 0 Reputation points
2023-11-21T15:09:45.4233333+00:00 however still report error
java.lang.UnsatisfiedLinkError: com.microsoft.cognitiveservices.speech.SpeechConfig.setTempDirectory(Ljava/lang/String;)V
i found this mistake maybe throw in theses codes
com.microsoft.cognitiveservices.speech.SpeechConfig
static { // First choice is to load the binaries from // the resources attached to the jar file. On Android, // this is not possible, so falling back to loading it // from disk. try { // This is a loose coupling since the class might not be available // when running on Android. Therefore, use reflection to find the // helper class and call the load function. // Fall back to standard loadLibrary, in case that fails. Class<?> ncl = Class.forName("com.microsoft.cognitiveservices.speech.NativeLibraryLoader"); // Note: in case the class exists, we call it, ignoring ANY error it raises. // This is on purpose as ONLY the native loader is responsible for loading // the native binding. // In case the loader does not exist, fall back to depending on the runtime // to locate the library for us. This is e.g. necessary on Android. if (ncl != null) { try { java.lang.reflect.Method nclm = ncl.getMethod("loadNativeBinding"); nclm.invoke(null); // static. } catch (Exception ex) { // ignored. // in particular, we DON'T want to fallback to the platform // loader here as the native loader has already failed and // we don't want to pick up some random library. } } else { // trigger an exception so the handler below calls the // default loader. throw new NullPointerException("no native loader available"); } } catch(java.lang.Error ex) { // In case, we cannot load the helper class, fall back to loading // the binding just by binding name. // TODO name of library will depend on version System.loadLibrary("Microsoft.CognitiveServices.Speech.java.bindings"); System.loadLibrary("Microsoft.CognitiveServices.Speech.core"); } catch(java.lang.Exception ex2) { // In case, we cannot load the helper class, fall back to loading // the binding just by binding name. // TODO name of library will depend on version System.loadLibrary("Microsoft.CognitiveServices.Speech.java.bindings"); System.loadLibrary("Microsoft.CognitiveServices.Speech.core"); } // setup native tmpdir setTempDirectory(System.getProperty("java.io.tmpdir")); // prevent classgc from freeing this class speechConfigClass = SpeechConfig.class;}
xxxx/lib/centos7-x64 in this directory i found not have ’libMicrosoft.CognitiveServices.Speech.java.bindings.so‘ this file。so i upload and restart tomcat still error。。。。
-
navba-MSFT 24,625 Reputation points • Microsoft Employee
2023-11-21T15:22:52.5933333+00:00 @迪迪 徐 Thanks for the your reply. Could you please confirm if you have followed by below suggestion ?
Make sure all the dependencies are installed correctly. These are mentioned clearly in this article.
Then you need to follow the pre-requisites and platform requirements for the
com.microsoft.cognitiveservices.speech
JAVA SDK inorder to use on CentOS7. Follow this article. -
迪迪 徐 0 Reputation points
2023-11-21T15:25:50.46+00:00 I am an integrated environment and have not configured JAVA_HOME. Is there a problem with this?
-
navba-MSFT 24,625 Reputation points • Microsoft Employee
2023-11-21T15:30:25.9833333+00:00 @迪迪 徐 The JAVA_HOME environment variable is often used by applications to locate the Java installation directory. If you’re using an Integrated Development Environment (IDE) like IntelliJ IDEA or Eclipse, they usually handle the Java path configurations internally, and you might not need to set JAVA_HOME.
However, some tools and scripts require JAVA_HOME to be set to function correctly. If you’re encountering issues with tools that rely on JAVA_HOME, or if you’re running Java applications from the command line, you might need to set this variable.
I see that initially you had reported the error
Could not initialize class com.microsoft.cognitiveservices.speech.SpeechConfig
. Is this resolved ??Could you please confirm if you are getting just this error now
java.lang.UnsatisfiedLinkError: com.microsoft.cognitiveservices.speech.SpeechConfig.setTempDirectory(Ljava/lang/String;)
? -
迪迪 徐 0 Reputation points
2023-11-21T15:31:28.6433333+00:00 I have already followed two documents and have been working back and forth, which is a bit confusing. But it never worked, and I don't understand why Microsoft's SDK needs to be installed on Linux? Isn't my local program imported and packaged?
-
迪迪 徐 0 Reputation points
2023-11-21T15:35:02.9533333+00:00 When I restart Tomcat, the first visit will report 'java. lang. UnsatisfiedLinkError: com. microsoft. cognitiveseervices. speech. SpeechConfig. setTempDirectory (Ljava/lang/String;) V'; In the future, we will continue to report 'Could not initialize class com. microsoft. cognitiveseervices. speech. SpeechConfig'
-
迪迪 徐 0 Reputation points
2023-11-21T15:37:09.7266667+00:00 What I mean by access is the interface that calls your synthesized speech
-
迪迪 徐 0 Reputation points
2023-11-21T15:38:04.2566667+00:00 What I mean by access is the interface that calls your synthesized voice, and all other functions of my program are normal
-
navba-MSFT 24,625 Reputation points • Microsoft Employee
2023-11-21T15:48:57.2433333+00:00 @迪迪 徐 Thanks for getting back and clarifying. It seems like the issue is related to the native libraries. The
java.lang.UnsatisfiedLinkError
error is thrown when the Java Virtual Machine (JVM) cannot find the native library required by the Java code. To resolve this issue, you can try the following steps:- Check if the native libraries are present in the correct location. The native libraries are located in the lib folder of the Speech SDK. Make sure that the lib folder is included in the
LD_LIBRARY_PATH
environment variable. - Check if the
libssl.so.1.0.0
andlibcrypto.so.1.0.0
libraries are installed on your system. These libraries are required by the Speech SDK. You can install them by running the following command:sudo yum install openssl-devel
- Make sure that the user running the Tomcat server has read and execute permissions on the lib folder and its contents.
- If the issue persists, you can try setting the
java.library.path
system property to the path of the lib folder. You can set this property by adding the following line to your Tomcat startup script:export JAVA_OPTS="-Djava.library.path=/usr/tomcat/shared/lib"
Replace /usr/tomcat/shared/lib with the actual path to the lib folder. Hope this helps.
- Check if the native libraries are present in the correct location. The native libraries are located in the lib folder of the Speech SDK. Make sure that the lib folder is included in the
-
迪迪 徐 0 Reputation points
2023-11-21T17:04:17.96+00:00 i have excute "yum install openssl-devel" once more
i try to set like this, maybe it's wrong.
I don't know how to perform the last two steps
I'm trying to print something in the program
I feel like there is a problem with the setting of this java. library. path
Is there any way to check it out?
-
迪迪 徐 0 Reputation points
2023-11-21T17:55:58.31+00:00 I am a beginner and I don't quite understand many basic principles. Please forgive me
-
迪迪 徐 0 Reputation points
2023-11-21T17:56:24.4866667+00:00 I am a beginner and I don't quite understand many basic principles. Please forgive me
-
navba-MSFT 24,625 Reputation points • Microsoft Employee
2023-11-22T06:19:24.9366667+00:00 @迪迪 徐 Thanks for getting back. This issue requires a closer troubleshooting. Please let me know if you have a support plan to open a support ticket with Microsoft, so that our Support professional and get in touch with you and assist you further.
-
迪迪 徐 0 Reputation points
2023-11-22T09:30:38.57+00:00 This support plan is too expensive. I'm just a developer alone
There is a problem with using your interface and we need your technical investigation. Why do we need to charge for it...
-
navba-MSFT 24,625 Reputation points • Microsoft Employee
2023-11-22T09:35:31.0433333+00:00 @迪迪 徐 Thanks for getting back. I understand your concern. I will create a free support ticket enablement for your subscription, so that you can create a one-time free ticket with Microsoft support.
Please share your subscription-id over email to azcommunity[at]microsoft[dot]com with subject as "Attn: NAVBA "
-
迪迪 徐 0 Reputation points
2023-11-22T11:44:54.0166667+00:00 I have sent an email and provided my subscription-id
Looking forward to further communication
-
navba-MSFT 24,625 Reputation points • Microsoft Employee
2023-11-22T12:59:50.6466667+00:00 @迪迪 徐 Thanks for your email. I have enabled one-time free support ticket for your subscription and replied to your email with the steps to open a support ticket. Please open the support ticket and our support professionals will assist you further.
Sign in to comment