From b04acfdf53aefc38b62910a1f55d9a9f46a3baa0 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Mon, 29 Apr 2019 23:25:37 +0530 Subject: [PATCH] Fix windows enrollment issue --- .../mgt/mobile/windows/impl/WindowsTokenServiceImpl.java | 1 - .../mgt/mobile/windows/impl/dao/WindowsDAOFactory.java | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java index eddbb4b1a..945dfa1ad 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/WindowsTokenServiceImpl.java @@ -16,7 +16,6 @@ public class WindowsTokenServiceImpl implements WindowsTokenService { public WindowsTokenServiceImpl() { windowsEnrollmentTokenDAO = new WindowsEnrollmentTokenDAOImpl(); - WindowsDAOFactory windowsDAOFactory = new WindowsDAOFactory(); } @Override diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java index 760a8a5fd..a49110e22 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/src/main/java/org/wso2/carbon/device/mgt/mobile/windows/impl/dao/WindowsDAOFactory.java @@ -77,6 +77,15 @@ public class WindowsDAOFactory extends AbstractMobileDeviceManagementDAOFactory if (currentConnection.get() == null) { Connection conn; try { + if (dataSource == null) { + try { + String dataSourceName = "jdbc/MobileWindowsDM_DS"; + Context ctx = new InitialContext(); + dataSource = (DataSource) ctx.lookup(dataSourceName); + } catch (NamingException e) { + throw new MobileDeviceManagementDAOException("Error occurred while initializing datasource", e); + } + } conn = dataSource.getConnection(); currentConnection.set(conn); } catch (SQLException e) {