I was struggling with my webapp (wsesupport) on Openshift with Wildfly 10 and MySQL 5.5. Each time I published from within eclipse, (In server view, right click on wsesupport at Openshift) my project was not deployed, and in the log files I could find the error message:
2016-03-10 17:32:56,740 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "ROOT.war")]) - failure description: {"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.persistenceunit.\"ROOT.war#wsesupport\".__FIRST__PHASE__ is missing [jboss.naming.context.java.wsesupport]",
"jboss.persistenceunit.\"ROOT.war#wsesupport\" is missing [jboss.naming.context.java.wsesupport]"
I re-added many times my datasource online through the admin console of myapp. I did this through the rhc port-forward wsesupport command and then in the browser localhost:9990. I noticed after the publishing, the entry I made in the Non XA datasources always disapeared.
In Mac, i searched for Resources (cmd-shift-r) and searched for standalone.xml. I did this because in the past I remembered I could deploy the standalone.xml with my web app and the config would be added to the default Wildlfy config (or something like that). So i thought to give it a try, maybe I was unaware of such a file in the project...
Surprisingly, it found it in an hidden openshift folder. If you are using eclipse (for sure) and the openshift plugin it will find it right away. There I copied the current MySqlDS configuration like this:
<datasource jndi-name="java:/wsesupport" enabled="true"
use-java-context="true" pool-name="wsesupport" use-ccm="true">
<connection-url>jdbc:mysql://${env.OPENSHIFT_MYSQL_DB_HOST}:${env.OPENSHIFT_MYSQL_DB_PORT}/wsesupport
</connection-url>
<driver>mysql</driver>
<security>
<user-name>${env.OPENSHIFT_MYSQL_DB_USERNAME}</user-name>
<password>${env.OPENSHIFT_MYSQL_DB_PASSWORD}</password>
</security>
<validation>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
<background-validation>true</background-validation>
<background-validation-millis>60000</background-validation-millis>
<!--<validate-on-match>true</validate-on-match> -->
</validation>
<pool>
<flush-strategy>IdleConnections</flush-strategy>
</pool>
</datasource>
I then published my project again and it was working!
PS do not delete the ExampleDS! WildFly apparently needs it!
PS2 do not format the standalone.xml within Eclipse! When i did it, I received this weird error: java.lang.IllegalStateException: You have to start the service first!
Good luck!
Related
We developed a Oracle ADF web app using
jDeveloper 11.1.2.4
MySql 5.5
and after a lot of google help we deployed our app onto tomcat this post.Oracle ADF onto Tomcat 6.x
In the above post he used Oracle Db. We deployed a test app with Oracle. Its running fine. But our original app has to work with MySql. We have setup our connection configuration as follows.
In conf/context.xml
<ResourceLink global="jdbc/webApp" name="jdbc/MySqlCOnDSDS" type="javax.sql.DataSource"/>
conf/server.xml
<Resource name ="jdbc/webApp" auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/easyrun"
username="teja" password="teja"
maxActive="20" maxIdle="10" maxWait="10000"/>
when we are trying to run our page(first.jsf) we are getting the following error.
javax.servlet.ServletException: Servlet execution threw an exception
oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)
oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:125)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
root cause
java.lang.AbstractMethodError: org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.isClosed()Z
oracle.jbo.server.QueryCollection.setResultSetState(QueryCollection.java:5624)
oracle.jbo.server.QueryCollection.hasNextInResultSet(QueryCollection.java:4859)
oracle.jbo.server.ViewObjectImpl.hasNextForCollection(ViewObjectImpl.java:7306)
oracle.jbo.server.QueryCollection.hasNext(QueryCollection.java:4768)
oracle.jbo.server.QueryCollection.buildResultSet(QueryCollection.java:1294)
oracle.jbo.server.QueryCollection.executeQuery(QueryCollection.java:913)
oracle.jbo.server.ViewObjectImpl.executeQueryForCollection(ViewObjectImpl.java:7282)
oracle.jbo.server.ViewRowSetImpl.execute(ViewRowSetImpl.java:1227)
oracle.jbo.server.ViewRowSetImpl.executeQueryForMasters(ViewRowSetImpl.java:1413)
oracle.jbo.server.ViewRowSetImpl.executeQueryForMode(ViewRowSetImpl.java:1319)
oracle.jbo.server.ViewRowSetImpl.executeQuery(ViewRowSetImpl.java:1304)
oracle.jbo.server.ViewObjectImpl.executeQuery(ViewObjectImpl.java:7211)
oracle.adf.model.bc4j.DCJboDataControl.executeIteratorBindingIfNeeded(DCJboDataControl.java:1366)
oracle.adf.model.binding.DCIteratorBinding.executeQueryIfNeeded(DCIteratorBinding.java:2219)
oracle.jbo.uicli.binding.JUCtrlHierBinding.getRootNodeBinding(JUCtrlHierBinding.java:92)
oracle.adfinternal.view.faces.model.binding.FacesCtrlHierBinding$FacesModel.addRowKeyChangeListener(FacesCtrlHierBinding.java:616)
oracle.adfinternal.view.faces.renderkit.rich.TableRendererUtils.registerRowKeyChangeListener(TableRendererUtils.java:2715)
oracle.adfinternal.view.faces.renderkit.rich.TableRenderer.encodeAll(TableRenderer.java:758)
oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
org.apache.myfaces.trinidad.component.UIXCollection.encodeEnd(UIXCollection.java:617)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1681)
org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:641)
oracle.adf.view.rich.render.RichRenderer.encodeAllChildrenInContext(RichRenderer.java:3062)
oracle.adfinternal.view.faces.renderkit.rich.FormRenderer.encodeAll(FormRenderer.java:274)
oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1681)
org.apache.myfaces.trinidad.render.CoreRenderer.encodeChild(CoreRenderer.java:624)
oracle.adf.view.rich.render.RichRenderer.encodeChild(RichRenderer.java:3201)
org.apache.myfaces.trinidad.render.CoreRenderer.encodeAllChildren(CoreRenderer.java:641)
oracle.adf.view.rich.render.RichRenderer.encodeAllChildrenInContext(RichRenderer.java:3062)
oracle.adfinternal.view.faces.renderkit.rich.DocumentRenderer.encodeAll(DocumentRenderer.java:1275)
oracle.adf.view.rich.render.RichRenderer.encodeAll(RichRenderer.java:1452)
org.apache.myfaces.trinidad.render.CoreRenderer.encodeEnd(CoreRenderer.java:511)
org.apache.myfaces.trinidad.component.UIXComponentBase.encodeEnd(UIXComponentBase.java:923)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1681)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:1677)
oracle.adfinternal.view.faces.component.AdfViewRoot.encodeAll(AdfViewRoot.java:91)
com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:399)
org.apache.myfaces.trinidadinternal.application.ViewDeclarationLanguageFactoryImpl$ChangeApplyingVDLWrapper.renderView(ViewDeclarationLanguageFactoryImpl.java:350)
com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:273)
org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:165)
oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._renderResponse(LifecycleImpl.java:1035)
oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:342)
oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:236)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:509)
oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)
oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:125)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)
org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)
org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
Please help us..
Thanks in advance.
Tomcat 6 datasource implementation is not upgraded to work with Java 1.6.
You can switch to Apache Datasource implementation by following the steps:
Download and copy commons-dbcp 1.4 to $CATALINA_HOME/lib
Download and copy commons-pool 1.5.5 to $CATALINA_HOME/lib
Change your "Resource" tag to include the following attribute:
factory="org.apache.commons.dbcp.BasicDataSourceFactory"
I've upgraded my grails application from 1.3.9 to 2.2.3 and then to 2.3.3. I read the release and upgrade notes for 1.3.9->2.2.3 and then from 2.2.3->2.3.3
I am using OpenJDK 6, Jetty 6 and the plugin jetty 1.1, MySQL 5.5 and I have the connector library under lib
Now my issue is if I run grails clean and then grails run-app the application runs without any problems but if I stop it and run grails run-app again I get a gigantic error (see here: http://pastebin.com/36MpXhir)
I also found that changing something like adding a space somewhere in BuildConfig.groovy (anything that makes it be recompiled) makes the application run normally.
Looking at the stacktrace the first thing that puzzles me is
[02.12.13 16:13:59.919] [main] pool.ConnectionPool Unable to create initial connections of pool.
java.sql.SQLException: com.mysql.jdbc.Driver
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:486)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:144)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
at org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy.afterPropertiesSet(LazyConnectionDataSourceProxy.java:162)
There are references to org.apache.tomcat even though I'm using jetty (and removed tomcat from BuildConfig.groovy).
Did anyone else encounter such a problem?
Don't put jar files in the lib directory if they're available in a public Maven repo. It's far better to download jars once and keep them in a local cache, and reuse them as needed.
The MySQL driver is used as the commented-out example in the generated BuildConfig.groovy - just un-comment it :) You might want to bump up the version to the latest, e.g.
dependencies {
runtime 'mysql:mysql-connector-java:5.1.27'
}
This is a good site for finding Maven artifacts: http://mvnrepository.com/artifact/mysql/mysql-connector-java
If you do have a jar that's not in a Maven repo (e.g. one with shared code at your company) then you can put it in the lib directory, but it's not auto-discovered. Run grails compile --refresh-dependencies to get it added to the classpath.
For me same error has occurred while running the Grails Application.Then I debug and view the code history of my code which was committed recently.
From that I found the issue that was:
Inside the controller file I send the instance with-out properly
Eg:
**def list=[personInstance.]---> error occurred.**
**render list as JSON**
Then I correct my mistake-->clean the app --> run the app
Now its working fine.
I'm fighting with this problem for several days and I has not been able to solve it. I've got a server with an instance of SQL Server 2008 R2 and a JBoss 7.1 installed (I'm using standalone configuration). I was trying to configure a datasource in the application server to connect to database, using JTDS drivers. The application server starts correctly but when I tried to test the datasource through the admin console it spools out the following error:
17:49:42,117 WARN [org.jboss.jca.core.connectionmanager.pool.strategy.OnePool] (HttpManagementService-threads - 1) IJ000604: Throwable while attempting to get a new connection: null: javax.resource.ResourceException: Co
uld not create connection
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:277) [ironjacamar-jdbc-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.createManagedConnection(LocalManagedConnectionFactory.java:235) [ironjacamar-jdbc-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManagedConnectionPool.java:761) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.
9.Final]
at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.getConnection(SemaphoreArrayListManagedConnectionPool.java:343) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getSimpleConnection(AbstractPool.java:397) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.getConnection(AbstractPool.java:365) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.AbstractPool.internalTestConnection(AbstractPool.java:627) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.jca.core.connectionmanager.pool.strategy.OnePool.testConnection(OnePool.java:88) [ironjacamar-core-impl-1.0.9.Final.jar:1.0.9.Final]
at org.jboss.as.connector.pool.PoolOperations$TestConnectionInPool.invokeCommandOn(PoolOperations.java:121) [jboss-as-connector-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.connector.pool.PoolOperations$1.execute(PoolOperations.java:60) [jboss-as-connector-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.connector.pool.PoolOperations.execute(PoolOperations.java:74) [jboss-as-connector-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.ModelControllerImpl$DefaultPrepareStepHandler.execute(ModelControllerImpl.java:466) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.executeStep(AbstractOperationContext.java:385) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.doCompleteStep(AbstractOperationContext.java:272) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.AbstractOperationContext.completeStep(AbstractOperationContext.java:200) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.ModelControllerImpl.execute(ModelControllerImpl.java:121) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.ModelControllerImpl$1.execute(ModelControllerImpl.java:309) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.controller.ModelControllerImpl$1.execute(ModelControllerImpl.java:299) [jboss-as-controller-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.as.domain.http.server.DomainApiHandler.processRequest(DomainApiHandler.java:294)
at org.jboss.as.domain.http.server.DomainApiHandler.doHandle(DomainApiHandler.java:201)
at org.jboss.as.domain.http.server.DomainApiHandler.handle(DomainApiHandler.java:208)
at org.jboss.as.domain.http.server.security.SubjectAssociationHandler.handle(SubjectAssociationHandler.java:51)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)
at org.jboss.sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:69)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)
at org.jboss.sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:710)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:78)
at org.jboss.as.domain.http.server.RealmReadinessFilter.doFilter(RealmReadinessFilter.java:54)
at org.jboss.com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:81)
at org.jboss.sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:682)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [rt.jar:1.7.0_11]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [rt.jar:1.7.0_11]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_11]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.0.0.GA.jar:2.0.0.GA]
Caused by: java.sql.SQLException: Cannot open database "SQLEXPRESS" requested by the login. The login failed.
at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
at net.sourceforge.jtds.jdbc.TdsCore.login(TdsCore.java:603)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:345)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at org.jboss.jca.adapters.jdbc.local.LocalManagedConnectionFactory.getLocalManagedConnection(LocalManagedConnectionFactory.java:249) [ironjacamar-jdbc-1.0.9.Final.jar:1.0.9.Final]
... 39 more
It seems a simple authentication problem, but the user/pwd is absolutely correct! Through SQL Server Management Studio I'm able to correctly connect to the db using the following:
Server name: DAN-Aladino-vs.usersad.everis.int\SQLEXPRESS
Authentication: SQL Server Authentication
Login: aladinoDs
Password: aladinoDs
To configure the datasource I've made the following steps:
1) In JBoss I've created the directory "modules\net\sourceforge\jtds\main".
Inside it I've put the jtds-1.2.5.jar and a new module.xml with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="net.sourceforge.jtds">
<resources>
<resource-root path="jtds-1.2.5.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
2) I've modified the standalone.xml configuration file adding the followings:
<datasource jndi-name="java:jboss/datasources/AladinoDS" pool-name="AladinoDS" enabled="true" use-java-context="true">
<connection-url>jdbc:jtds:sqlserver://DAN-Aladino-vs.usersad.everis.int:1433/SQLEXPRESS</connection-url>
<driver>JTDS</driver>
<new-connection-sql>select 1</new-connection-sql>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>50</max-pool-size>
</pool>
<security>
<user-name>aladinoDs</user-name>
<password>aladinoDs</password>
</security>
<validation>
<check-valid-connection-sql>select 1</check-valid-connection-sql>
</validation>
<timeout>
<set-tx-query-timeout>true</set-tx-query-timeout>
<blocking-timeout-millis>5000</blocking-timeout-millis>
<idle-timeout-minutes>15</idle-timeout-minutes>
</timeout>
<statement>
<track-statements>false</track-statements>
</statement>
</datasource>
and, in the <drivers> section:
<driver name="JTDS" module="net.sourceforge.jtds">
<driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>
</driver>
According to what I've found on the web, it should be correct, but it still not work. By the way, I don't want to use Windows Authentication for the datasource but I tried also that way, unsuccessfully.
I hope someone can find something wrong in my caonfiguration. If it's correct, could be a problem of the database server/instance configuration? I'm puzzled... through SQL Server Mgmt Studio all seems to work.
Thank you all,
Luca
(Answered in comments and edits. See Question with no answers, but issue solved in the comments (or extended in chat) )
The OP wrote:
#Jon Skeet: The SQL Server error log shows the following:
01/25/2013 09:47:02,Logon,Unknown,Login failed for user 'aladinoDs'. Reason: Failed to open the explicitly specified database.
So, the problem should be that I'm not using the proper database name.
#CoolBeans: I'm not used to SQL Server (usually I work with Oracle DB), and I'm not familiar with its distinction between databases/instances/logins, but if I'm using the credentials above to successfully logon into db through SQL Server Mgmt Studio, why am I not able to use them for datasource? When I connect to db server, I can see in SQL Server Mgmt Studio, into "databases" folder, two objects: System Databases and AladinoSFA2. Should I use the latest one as server name in the connection string? This will be my next try. I'll post an update.
SOLVED:
I corrected the connection string: <connection-url>jdbc:jtds:sqlserver://DAN-Aladino-vs.usersad.everis.int:1433/AladinoSFA2</connection-url>
It seems that i would have to use the single database name and not the database server name into the connection string. I don't really understand why using SQL Server Mgmt Studio I do not need to specify db instance name, but only db server name, and in the datasource, on the contrary, the database instance name is the only one needed.
However now it all works.
I get the following error message when trying to connect a web app running on EAP6 to MySQL in OpenShift.
javax.persistence.PersistenceException: org.hibernate.exception.JDBCConnectionException: Communications link failure
How do I fix this?
The same issue was discussed at https://community.jboss.org/thread/202318.
The solution is to append "?autoReconnect=true" to the connection URL. You do this in the standalone.xml file, found in the .openshift/config folder in your OpenShift Maven project.
EDIT
This is actually a known bug: https://community.jboss.org/thread/177144. Validating the connection can be used as a workaround.
<validation>
<check-valid-connection-sql>SELECT 1</check-valid-connection-sql>
</validation>
Can we configure database connection from JBOSS? If it is possible, than is there any configuration file in JBOSS to configure database connection from JBOSS?
You need two things:
Make the JDBC driver available to your Applications Server
Write a Data Source configuration
For #1, you can download the JAR containing JDBC driver and put it in the following directory:
$JBOSS_HOME/server/default/lib
Assuming that $JBOSS_HOME points to your JBoss installation, and you are using default installation.
For #2, you will find a lot of examples here:
$JBOSS_HOME/docs/examples/jca
There are examples for most of database products around. Here's PostgreSQL's:
<datasources>
<local-tx-datasource>
<jndi-name>PostgresDS</jndi-name>
<connection-url>jdbc:postgresql://[servername]:[port]/[database name]</connection-url>
<driver-class>org.postgresql.Driver</driver-class>
<user-name>x</user-name>
<password>y</password>
<!-- sql to call when connection is created. Can be anything, select 1 is valid for PostgreSQL
<new-connection-sql>select 1</new-connection-sql>
-->
<!-- sql to call on an existing pooled connection when it is obtained from pool. Can be anything, select 1 is valid for PostgreSQL
<check-valid-connection-sql>select 1</check-valid-connection-sql>
-->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
<metadata>
<type-mapping>PostgreSQL 7.2</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
Well, this looks like a good guide for configuring a datasource for JBoss.
A JDBC driver is needed for your database (a jar file, refer to your db's documentation) and afterwards, configuration. You should be able to configure it using JBoss admin console.
After your datasource is configured, you can use JNDI or some other mechanism for obtaining it in your application. Then you use JDBC for actually interacting with your database. Another popular alternative is using JPA since JBoss already has Hibernate built in.
Follow the following steps:
Add my sql connector jar in main folder (eg. \modules\system\layers\base\com\mysql\main).
Add a module.xml file to this folder consisting of the following config:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.17-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
Now in stanalone.xml file add mysql driver under drivers tag as following:
<driver name="mysql" module="com.mysql">
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
start the jboss server from command prompt by going to location of the jboss/bin folder and executing standalone.bat
Now in a browser, open localhost:8080, click on administration console and under create a datasource click datasource. Then click on add.
Add the following details:
Name: MysqlDS5
JNDI Name : java:/mysql
click next and under "detected driver" select mysql.
click next
Connection url : jdbc:mysql://localhost:3306/sampledb
UserName:****
Password:****
click done, select the MysqlDS and click on enable.
click on test connection and it will successfully connect.