1. 程式人生 > 其它 >javax.naming.OperationNotSupportedException: Context is read only

javax.naming.OperationNotSupportedException: Context is read only

技術標籤:工作中的點點滴滴這是知識點tomcat容器java

場景:

最近幫忙升級Tomcat版本時發現日誌有這個異常:

javax.naming.OperationNotSupportedException: Context is read only

原因:

容器必須確保應用程式元件例項僅具有對其命名上下文的讀訪問權。
因此,修改環境命名上下文及其子上下文的javax.naming.Context介面的所有方法都會丟擲該異常

The container must ensure that the application component instances have only read access to their naming context. The container must throw the javax.naming.OperationNotSupportedException from all the methods of the javax.naming.Context interface that modify the environment naming context and its subcontexts.


解決方案:

針對以上異常原因,我們可以修改Tomcat的conf下的context.xml配置檔案,修改如下:

<Context jndiExceptionOnFailedWrite="false">

關注Github:1/2極客

關注部落格:御前提筆小書童

關注網站:開發者的花花世界

關注公眾號:開發者的花花世界