Error Creating Initialcontext With Environment
Contents |
and SafetyAsset NetworkAsset failed to create initialcontext using factory specified in hashtable Operations and MaintenanceCommerceOverviewSubscription Billing and Revenue ManagementMaster
Noinitialcontextexception
Data Management for CommerceOmnichannel CommerceFinanceOverviewAccounting and Financial CloseCollaborative Finance OperationsEnterprise jndi Risk and ComplianceFinancial Planning and AnalysisTreasury and Financial Risk ManagementHuman ResourcesOverviewCore Human Resources and PayrollHuman Capital AnalyticsTalent ManagementTime and Attendance ManagementManufacturingOverviewManufacturing NetworkManufacturing OperationsResponsive ManufacturingMarketingOverviewMarket with Speed and AgilityUnique Customer ExperiencesReal-Time Customer InsightsR&D/EngineeringOverviewDesign NetworkDesign OrchestrationProject and Portfolio ManagementSalesOverviewCollaborative Quote to CashSales Force AutomationSales Performance ManagementSelling Through Contact CentersServiceOverviewEfficient Field Service ManagementOmnichannel Customer ServiceTransparent Service Process and OperationsSourcing and ProcurementOverviewContingent Workforce ManagementDirect ProcurementSelf-Service ProcurementServices ProcurementStrategic Sourcing and Supplier ManagementSupply ChainOverviewDemand ManagementDemand NetworkLogistics NetworkManufacturing Planning and SchedulingResponse NetworkResponse and Supply ManagementSales, Inventory, and Operations PlanningTransportation ManagementWarehouse ManagementSustainabilityOverviewEnvironment, Health, and SafetyProduct Safety and Stewardship NetworkBrowse by IndustryAerospace and DefenseAutomotiveBankingChemicalsConsumer ProductsDefense and SecurityEngineering, Construction, and OperationsHealthcareHigh TechHigher Education and ResearchIndustrial Machinery and ComponentsInsuranceLife SciencesMediaMill ProductsMiningOil and GasProfessional ServicesPublic SectorRetailSports and EntertainmentTelecommunicationsTravel and TransportationUtilitiesWholesale DistributionBrowse Platform and TechnologyAnalyticsOverviewBusiness IntelligencePredictive AnalyticsGovernance, Risk, and ComplianceEnterprise Performance ManagementApplication Platform and InfrastructureOverviewApplication PlatformContent and CollaborationInterface ManagementProcess Management and IntegrationData ManagementOverviewBig Data on HadoopData WarehousingDatabase ManagementEnterprise Information ManagementIT ManagementOverviewApplication Lifecycle
This Site Careers Other all forums Forum: BEA/Weblogic Error creating Initial Context Nupur Gupta Ranch Hand Posts: 45 posted 9 years ago Hi, I am a http://scn.sap.com/thread/3602247 J2EE newbie.I am running Weblogic 7.0. My Client code is like - Hashtable env = new Hashtable(5); env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory"); env.put(Context.PROVIDER_URL, "t3://myServer:7001"); Context ctx = new InitialContext(env); However, I get https://coderanch.com/t/68996/BEA-Weblogic/Error-creating-Initial-Context an error javax.naming.ServiceUnavailableException [Root exception is java.net.UnknownHostException: myServer] at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:41) at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.jav a:636) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.jav a:333) at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.jav a:222) at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:149) at javax.naming.spi.NamingManager.getInitialContext(Unknown Source) at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source) at javax.naming.InitialContext.init(Unknown Source) at javax.naming.InitialContext.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://stackoverflow.com/questions/20359483/initialcontext-in-a-standalone-java-program the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions https://docs.oracle.com/javase/7/docs/api/javax/naming/InitialContext.html Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. error creating Join them; it only takes a minute: Sign up Initialcontext in a standalone Java program up vote 15 down vote favorite 3 I'm using a JNDI for creating tomcat connection pool. It works great in a web application. I believe the InitialContext is provided by the tomcat server. Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); dataSource error creating initialcontext = (DataSource)envContext.lookup("jdbc/testdb"); But when I try to call the same utility from a standalone Java program, the initContext object is null. How can I explicitly provide all the necessary properties that Context object is expecting. Error : javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial java java-ee tomcat jndi connection-pooling share|improve this question edited Dec 3 '13 at 19:04 Zong Zheng Li 4,46351734 asked Dec 3 '13 at 19:03 Satish Jonnala 1403316 If an answer was helpful, you can accept it. –Paul Vargas Dec 5 '13 at 14:10 add a comment| 4 Answers 4 active oldest votes up vote 4 down vote accepted You could also create your own custom context. LocalContext ctx = LocalContextFactory.createLocalContext(); ctx.addDataSource("jdbc/testdb", driverName, url, usr, pwd); See Running Beans Locally that use Application Server Data Sources for more details. UPDATE You can use the class org.springframework.mock.jndi.SimpleNamingContextBuilder of Spring. e.g.: Setup: SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder(); builder.bind("jdbc/Oracle", ods); builder.activate(); Use: DataSource ds = InitialContext.doLo
Method javax.naming Class InitialContext java.lang.Object javax.naming.InitialContext All Implemented Interfaces: Context Direct Known Subclasses: InitialDirContext public class InitialContext extends Object implements Context This class is the starting context for performing naming operations. All naming operations are relative to a context. The initial context implements the Context interface and provides the starting point for resolution of names. When the initial context is constructed, its environment is initialized with properties defined in the environment parameter passed to the constructor, and in any application resource files. In addition, a small number of standard JNDI properties may be specified as system properties or as applet parameters (through the use of Context.APPLET). These special properties are listed in the field detail sections of the Context and LdapContext interface documentation. JNDI determines each property's value by merging the values from the following two sources, in order: The first occurrence of the property from the constructor's environment parameter and (for appropriate properties) the applet parameters and system properties. The application resource files (jndi.properties). For each property found in both of these two sources, or in more than one application resource file, the property's value is determined as follows. If the property is one of the standard JNDI properties that specify a list of JNDI factories (see Context), all of the values are concatenated into a single colon-separated list. For other properties, only the first value found is used. The initial context implementation is determined at runtime. The default policy uses the environment property "java.naming.factory.initial", which contains the class name of the initial context factory. An exception to