Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. javax.naming.NameNotFoundException: SpecOpsDB -- service jboss.naming.context.java.jboss.exported.SpecOpsDB
  2. at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:97)
  3. at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:177)
  4. at org.jboss.naming.remote.protocol.v1.Protocol$1.handleServerMessage(Protocol.java:124)
  5. at org.jboss.naming.remote.protocol.v1.RemoteNamingServerV1$MessageReciever$1.run(RemoteNamingServerV1.java:70)
  6. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
  7. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
  8. at java.lang.Thread.run(Thread.java:745)
  9.  
  10. <datasources>
  11. <datasource pool-name="SpecOpsDB" jndi-name="java:/SpecOpsDB"
  12. enabled="true" use-java-context="true">
  13. <connection-url>jdbc:mysql://localhost:3306/spec_ops_schema</connection-url>
  14. <driver>com.mysql</driver>
  15. <pool>
  16. <min-pool-size>5</min-pool-size>
  17. <max-pool-size>20</max-pool-size>
  18. <prefill>true</prefill>
  19. </pool>
  20. <security>
  21. <user-name>root</user-name>
  22. <password>root</password>
  23. </security>
  24. </datasource>
  25. <drivers>
  26. <driver name="com.mysql" module="com.mysql">
  27. <datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlDataSource</datasource-class>
  28. </driver>
  29. </drivers>
  30. </datasources>
  31.  
  32. <module xmlns="urn:jboss:module:1.0" name="com.mysql">
  33. <resources>
  34. <resource-root path="mysql-connector-java-5.1.34-bin.jar"/>
  35. </resources>
  36. <dependencies>
  37. <module name="javax.api"/>
  38. </dependencies>
  39. </module>
  40.  
  41. DataSource jBossDataSource = null;
  42. try {
  43. Properties props = new Properties();
  44. props.put(Context.INITIAL_CONTEXT_FACTORY,
  45. "org.jboss.naming.remote.client.InitialContextFactory");
  46. props.put(Context.PROVIDER_URL, "remote://localhost:4447");
  47. props.put(Context.SECURITY_PRINCIPAL, "admin");
  48. props.put(Context.SECURITY_CREDENTIALS, "password");
  49. Context ctxt = new javax.naming.InitialContext(props);
  50. log.debug("Context Initialized");
  51. Object lookup = ctxt.lookup("java:/SpecOpsDB");
  52. jBossDataSource = (javax.sql.DataSource) lookup;
  53. log.info("Got JBoss DataSource");
  54. } catch (Exception e) {
  55. // TODO Auto-generated catch block
  56. e.printStackTrace();
  57. }
  58.  
  59. 11:01:09,105 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-4) JBAS010400: Bound data source [java:/SpecOpsDB]
  60.  
  61. Context context = new InitialContext();
  62. DataSource ds = (DataSource) context.lookup("java:/SpecOpsDB"); //using only "SpecOpsDB" should also work
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement