top of page
Search
krramos8732

Native Library Already Loaded In Another Classloader Tomcat



You can see that it is going to use the ClassLoader of the calling class, which in this case is the class of the third-party library. So to solve this you need to align the ClassLoader of the third-party lib with the ClassLoader of what tries to load the native library first. You could try enabling class loading trace and look for when that third-party class is loaded, and back up from there to find the ClassLoader.


Usually a class that uses a native library will have a static initializer that loads the library. This way the class and the native library will always be loaded in the same class loader. With OpenCV the application code loads the native library.




Native Library Already Loaded In Another Classloader Tomcat




Now there's the restriction that a native library can only be loaded in one class loader. Web applications use their own class loader so if one web application has loaded a native library, another web application cannot do the same. Therefore code loading native libraries cannot be put in a webapp directory but must be put in the container's (Tomcat) shared directory. When you have a class written with the usual pattern above (loadLibrary in static initializer of using class) it's enough to put the jar containing the class in the shared directory. With OpenCV and the loadLibrary call in the web application code however, the native library will still be loaded in the "wrong" class loader and you will get the UnsatisfiedLinkError.


I need to have a separate instance of the native library for each of mywebapps as each instance needs to contain data that is unique to thatparticular webapp. I have searched through the mail archives and reademails by Craig McLanahan explaining the classloader hierarchy. But Ihavenot been able to find anything specific to loading a unique instance of anative library for each webapp.


The problem is due to some configurations of your application server which cause to create more than one war or ear files and consequently it creates more than one deployed files. These deployed files attempt to have a concurrent access to your native library which loaded in a static block.


When using the ArcSDE Java API in an environment with multiple classloaders; for example servlet container, the following error occurs:"java.lang.UnsatisfiedLinkError: Native Library jsg83.dll already loaded in another classloader"The error may be returned in a Web client or a log file associated with the container; for example, Tomcat or ServletExec.


The ArcSDE Java API uses Java classes in the jsde83_sdk.jar that call the native library, jsg83.dll or .so on Unix platforms, in the $SDEHOME/bin directory. Due to a limitation of the JVM classloader, these Java classes should only be loaded once per process. See the Related Information article below for additional information on this issue.


  • I received a message asking for further clarification. I try to further explain.\\n\\nBe sure sapjco.jar is not included in the application. Doing so will lead the system to load more than one time the SAP Java Connector. Sapjco.jar has to be loaded only once in the server. \\n\\nTo do so (in Windows & Tomcat environment): \\n1-Be sure sapjco.jar is not included in the WEB-INF folder.\\n2-Put sapjcorfc.dll and librfc32.dll in c:Windowssystem32\\n3-Put sapjco.jar in c:Tomcatcommonlib\\n4-Add a reference to sapjco.jar in the project (In Eclipse: Project/Properties/Java Build Path, Tab Libraries, Add External JARs.\\n5-Compile and deploy the application. Generate War file. If ant gives problems, add proper command to find sapjco.jar (section , )\\n6-Load the WAR file in Tomcat.\\n7-Stop and Start Tomcat.\\n8-Run the application.\\n\\nA related thread: [SAP J2EE engine problemSAP J2EE engine problem]\\n\\nHope this helps.\",\"author\":\"username\":\"jordi.escodaruiz\",\"displayName\":\"Jordi Escoda Ruiz\",\"groupIcons\":[],\"suspended\":false,\"isCurrentUser\":false,\"parentAuthor\":\"username\":\"jordi.escodaruiz\",\"displayName\":\"Jordi Escoda Ruiz\",\"groupIcons\":[],\"suspended\":false,\"isCurrentUser\":false,\"id\":4856254,\"creationDate\":1222970249000,\"activeRevisionId\":6586280,\"lastActivity\":1222970552000,\"parentId\":4338702,\"originalParentId\":3574765,\"likeCount\":0,\"visibility\":\"full\",\"depth\":0,\"attachments\":[],\"canVoteUpOrCancel\":false,\"relations\":\"canReport\":false,\"visibility\":\"full\",\"canEdit\":false,\"canUseDelete\":false,\"isLiked\":false,\"type\":\"comment\",\"canVoteUpOrCancel\":false,\"canConvertToAnswer\":false,\"canBeModerated\":false,\"canViewRevisions\":false,\"showInReply\":false,\"reported\":false,\"canCancelReport\":false,\"canDelete\":false,\"canVoteDownOrCancel\":false,\"canComment\":false,\"canViewReports\":false,\"isCurrentUserAuthor\":false,\"liked\":false,\"moderatorComment\":false}]}}"); const simplifiedQuestionView = JSON.parse("true"); (function() window.pageContext = mergeDeep(pageContext, question: id: 3574765, plug: "java-connector-sapjcorfcdll-already-loaded-in-anot", votes: 0, questionTitle: "Java Connector. \"sapjcorfc.dll already loaded in another classloader\"", isClosed: false, isLocked: false, isRedirected: false, redirectedFromTitle: "", redirectedFromId: "", closedStatusData: JSON.parse(""), userVoted: false, relations: JSON.parse("\"canClose\":false,\"canUnredirect\":false,\"canReport\":false,\"visibility\":\"full\",\"canEdit\":false,\"canUseDelete\":false,\"canReopen\":false,\"type\":\"question\",\"canVoteUpOrCancel\":false,\"canViewRevisions\":true,\"canUnlock\":false,\"reported\":false,\"canVoteDownOrCancel\":false,\"canLock\":false,\"canCancelReport\":false,\"canComment\":true,\"isCurrentUserAuthor\":false,\"canViewReports\":false"), isQuestionAccepted: false , childToViewInfo: id: "" , comments: JSON.parse("\"4338702\":\"rootParentId\":4338702,\"commentsCount\":1,\"comments\":[\"body\":\"I received a message asking for further clarification. I try to further explain.\\n\\nBe sure sapjco.jar is not included in the application. Doing so will lead the system to load more than one time the SAP Java Connector. Sapjco.jar has to be loaded only once in the server. \\n\\nTo do so (in Windows & Tomcat environment): \\n1-Be sure sapjco.jar is not included in the WEB-INF folder.\\n2-Put sapjcorfc.dll and librfc32.dll in c:Windowssystem32\\n3-Put sapjco.jar in c:Tomcatcommonlib\\n4-Add a reference to sapjco.jar in the project (In Eclipse: Project/Properties/Java Build Path, Tab Libraries, Add External JARs.\\n5-Compile and deploy the application. Generate War file. If ant gives problems, add proper command to find sapjco.jar (section , )\\n6-Load the WAR file in Tomcat.\\n7-Stop and Start Tomcat.\\n8-Run the application.\\n\\nA related thread: [SAP J2EE engine problem]"), answerPager: answersCount: 1, page: 1, pageSize: 10, pageCount: 1, sort: "votes" , answers: JSON.parse("[\"body\":\"I close this thread. I solved the problem by removing the SAP Java Connector library from my project, and adding it to the libraries loaded by Tomcat (common libraries),\",\"author\":\"username\":\"jordi.escodaruiz\",\"displayName\":\"Jordi Escoda Ruiz\",\"groupIcons\":[],\"suspended\":false,\"isCurrentUser\":false,\"id\":4338702,\"posted\":1214813684000,\"votes\":0,\"isAccepted\":false,\"isLocked\":false,\"userVoted\":\"\",\"relations\":\"canCancelAccept\":false,\"canUnlock\":false,\"canUseDelete\":false,\"canVoteDownOrCancel\":false,\"canLock\":false,\"canAccept\":false,\"type\":\"answer\",\"canVoteUpOrCancel\":false,\"isCurrentUserAuthor\":false,\"attachments\":[]]"), answerForm: formAction: "/answers/3574765/post.json", textareaName: "body", textareaErrors: "", isAttachmentsEnabled: true, answerEditorialGuideline: title: "Before answering", content: "You should only submit an answer when you are proposing a solution to the poster\'s problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that your answer complies with our Rules of Engagement.", links: [ title: "Rules of Engagement", href: " -of-engagement.html", ] , answerMinBodyLength: '10', answerMaxBodyLength: '20000' , currentUser: sapInternalId: '', permissions: canVoteUpOrCancel: false, canVoteDownOrCancel: false, canModerate: false, , isVotedUp: false, isVotedDown: false , alerts: alertModeratorMinLength : "It should be given a proper explanation about why the content is inappropriate.", alertModeratorMinLengthValue : "10", alreadyReportedMessage : "You already have an active moderator alert for this content." , url: profileApiBaseUrl: ' -api.services.sap.com', followUnfollowQuestion: '/sap/nodeSubscription.json', isFollowingQuestion: '/sap/isFollowingNode.json', vote: voteUp: '/commands/0/voteup.json', voteDown: '/commands/0/votedown.json', cancelVote: '/commands/0/cancelvote.json' , rss: answers: '/feed/3574765/answers.rss', answersAndComments: '/feed/3574765/comments-and-answers.rss' , authorizeUploadContext: type: 'answer' , atMention: userSearchServiceUrl: ' ', currentUserName: '', useNewUSSCORS: true, atMentionDelayMs: 100, showMentionInRedactor: true , attachmentSettings: commentMaxAttachments: '2', answerMaxAttachments: '10', commentMaxAttachmentSizeBytes: '1048576', answerMaxAttachmentSizeBytes: '1048576', commentAttachmentsSizeBytesTotal: '2097152', answerAttachmentsSizeBytesTotal: '10485760' , editor: editorClipboardUploadEnabled: true ) )(); Home

  • Community

  • Ask a Question

  • Write a Blog Post

Login / Sign-up Search Questions and Answers 0 Jordi Escoda Ruiz Feb 04, 2008 at 07:43 AM Java Connector. "sapjcorfc.dll already loaded in another classloader" 1393 Views Follow RSS Feed Dear all:


2ff7e9595c


0 views0 comments

Recent Posts

See All

Comments


bottom of page