1 2 Previous Next 20 Replies Latest reply: Aug 23, 2012 6:32 AM by wqe wqe RSS

[AS 7.1 / Hibernate 4] Module classpath & DB-Drivers

Ste Gr Newbie

Hello,

 

I'm currently migrating our AS 4 to AS 7 and have a problem with the new module system I'm unable to solve.

We're using the JTDS 1.2.5 library for connecting with the MSSQL-Server. There are 2 possibilities on how to setup the connection

1) persistence.xml + JBoss datasource

Everything works quite well here, but I don't like the JTA transaction style (after a commit I have to merge all Entities with the EM again, to work with them).

 

2) Native Hibernate API + hibernate.cfg.xml

Nothing is working here, because no driver could be found. I added JDTS as a module to JBoss and added jdts and hibernate as a dependencie to the MANIFEST. The only way to get it working is to add jdts as a dependencie to the hibernate module. But that's not really a nice solution.

Is there any other way to "inject" the Driver to hibernates classpath, so it could be found?

 

[code]

10:15:41,900 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Test].[FacesServlet]] (http--127.0.0.1-8080-1) Servlet.service() for servlet FacesServlet threw exception: java.sql.SQLException: No suitable driver found for jdbc:jtds:sqlserver://mssql-luk-test.emea.luk.com/TestDB

    at java.sql.DriverManager.getConnection(DriverManager.java:602) [:1.6.0_30]

    at java.sql.DriverManager.getConnection(DriverManager.java:154) [:1.6.0_30]

    at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:173)

[/code]

 

I hope you understand what I mean. My englisch is not the best

  • 1. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    jaikiran pai Master

    What does your hibernate.cfg.xml look like and what's the entire exception stacktrace? Since you aren't using datasources, I think you should be able to get this working by packaging those driver jars within the .war/WEB-INF/lib folder (or a .ear/lib for .ear applications).

  • 2. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Ste Gr Newbie

    Hi,

     

    I've already tested to deploy the driver within the war, but it didn't work either. The error remains the same...

     

    Hibernate.cfg.xml

     

     

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                             "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory name="TestDBFactory">
            <property name="hibernate.connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
            <property name="hibernate.connection.url">jdbc:jtds:sqlserver://*******/TestDB</property>
            <property name="hibernate.connection.username">AppDB</property>
            <property name="hibernate.connection.password">********</property>
            <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
            <property name="hibernate.default_schema">dbo</property>
            <property name="hibernate.show_sql">true</property>
            <property name="hibernate.listeners.envers.autoRegister">false</property>
            <mapping class="com.luk.emea.weapp.db.TblTest" />
            <mapping class="com.luk.emea.weapp.db.TblRef" />
        </session-factory>
    </hibernate-configuration>

     

    Stacktrace

    10:10:53,101 INFO  [org.hibernate.cfg.Configuration] (http--127.0.0.1-8080-1) HHH000043: Configuring from resource: /hibernate.cfg.xml
    10:10:53,101 INFO  [org.hibernate.cfg.Configuration] (http--127.0.0.1-8080-1) HHH000040: Configuration resource: /hibernate.cfg.xml
    10:10:53,101 WARN  [org.hibernate.internal.util.xml.DTDEntityResolver] (http--127.0.0.1-8080-1) HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
    10:10:53,116 INFO  [org.hibernate.cfg.Configuration] (http--127.0.0.1-8080-1) HHH000041: Configured SessionFactory: TestDBFactory
    10:10:53,132 INFO  [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http--127.0.0.1-8080-1) HHH000402: Using Hibernate built-in connection pool (not for production use!)
    10:10:53,132 INFO  [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http--127.0.0.1-8080-1) HHH000115: Hibernate connection pool size: 20
    10:10:53,132 INFO  [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http--127.0.0.1-8080-1) HHH000006: Autocommit mode: false
    10:10:53,132 INFO  [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http--127.0.0.1-8080-1) HHH000401: using driver [net.sourceforge.jtds.jdbc.Driver] at URL [jdbc:jtds:sqlserver://mssql-luk-test.emea.luk.com/TestDB]
    10:10:53,132 INFO  [org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl] (http--127.0.0.1-8080-1) HHH000046: Connection properties: {user=AppDB, password=****}
    10:10:53,132 WARN  [org.hibernate.engine.jdbc.internal.JdbcServicesImpl] (http--127.0.0.1-8080-1) HHH000342: Could not obtain connection to query metadata : No suitable driver found for jdbc:jtds:sqlserver://mssql-luk-test.emea.luk.com/TestDB
    10:10:53,132 INFO  [org.hibernate.dialect.Dialect] (http--127.0.0.1-8080-1) HHH000400: Using dialect: org.hibernate.dialect.SQLServerDialect
    10:10:53,132 INFO  [org.hibernate.engine.jdbc.internal.LobCreatorBuilder] (http--127.0.0.1-8080-1) HHH000422: Disabling contextual LOB creation as connection was null
    10:10:53,132 INFO  [org.hibernate.engine.transaction.internal.TransactionFactoryInitiator] (http--127.0.0.1-8080-1) HHH000399: Using default transaction strategy (direct JDBC transactions)
    10:10:53,132 INFO  [org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory] (http--127.0.0.1-8080-1) HHH000397: Using ASTQueryTranslatorFactory
    10:10:53,148 INFO  [org.hibernate.internal.SessionFactoryRegistry] (http--127.0.0.1-8080-1) HHH000094: Bound factory to JNDI name: TestDBFactory
    10:10:53,163 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) SQL Error: 0, SQLState: 08001
    10:10:53,163 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (http--127.0.0.1-8080-1) No suitable driver found for jdbc:jtds:sqlserver://mssql-luk-test.emea.luk.com/TestDB
    10:10:53,179 INFO  [org.hibernate.event.internal.DefaultLoadEventListener] (http--127.0.0.1-8080-1) HHH000327: Error performing load command : org.hibernate.exception.JDBCConnectionException: Could not open connection
    10:10:53,194 SCHWERWIEGEND [javax.enterprise.resource.webcontainer.jsf.application] (http--127.0.0.1-8080-1) Error Rendering View[/home.xhtml]: javax.el.ELException: /home.xhtml: WELD-000049 Unable to invoke [method] @PostConstruct public TestBean.reset() on TestBean@1d7803b
        at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:90) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.8.Final.jar:]
        at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.8.Final.jar:]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:155) [jboss-as-web-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.8.Final.jar:]
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.8.Final.jar:]
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.8.Final.jar:]
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.8.Final.jar:]
        at java.lang.Thread.run(Thread.java:662) [:1.6.0_30]
    Caused by: org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke [method] @PostConstruct public TestBean.reset() on TestBean@1d7803b
        at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:508) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:174) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:291) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:107) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.proxies.TestBean$Proxy$_$$_WeldClientProxy.toString(TestBean$Proxy$_$$_WeldClientProxy.java) [weld-core-1.1.5.Final.jar:]
        at org.apache.el.lang.ELSupport.coerceToString(ELSupport.java:386) [jbossweb-7.0.8.Final.jar:]
        at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:397) [jbossweb-7.0.8.Final.jar:]
        at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:191) [jbossweb-7.0.8.Final.jar:]
        at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:227) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:150) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        ... 30 more
    Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_30]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_30]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_30]
        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_30]
        at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:174) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:506) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        ... 43 more
    Caused by: org.hibernate.exception.JDBCConnectionException: Could not open connection
        at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:131) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:304) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at $Proxy44.prepareStatement(Unknown Source)    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1739) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.doQuery(Loader.java:828) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.loadEntity(Loader.java:2058) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3697) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:439) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:420) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:204) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:251) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:148) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:954) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.SessionImpl.get(SessionImpl.java:870) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.SessionImpl.get(SessionImpl.java:863) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at TestBean.reset(TestBean.java:208)    ... 53 more
    Caused by: java.sql.SQLException: No suitable driver found for jdbc:jtds:sqlserver://mssql-luk-test.emea.luk.com/TestDB
        at java.sql.DriverManager.getConnection(DriverManager.java:602) [:1.6.0_30]
        at java.sql.DriverManager.getConnection(DriverManager.java:154) [:1.6.0_30]
        at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:173) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:276) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        ... 78 more

    10:10:53,194 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/Test].[FacesServlet]] (http--127.0.0.1-8080-1) Servlet.service() for servlet FacesServlet threw exception: java.sql.SQLException: No suitable driver found for jdbc:jtds:sqlserver://mssql-luk-test.emea.luk.com/TestDB
        at java.sql.DriverManager.getConnection(DriverManager.java:602) [:1.6.0_30]
        at java.sql.DriverManager.getConnection(DriverManager.java:154) [:1.6.0_30]
        at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.getConnection(DriverManagerConnectionProviderImpl.java:173) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:276) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at $Proxy44.prepareStatement(Unknown Source)    at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1739) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.doQuery(Loader.java:828) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.Loader.loadEntity(Loader.java:2058) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3697) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:439) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:420) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:204) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:251) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:148) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:954) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.SessionImpl.get(SessionImpl.java:870) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at org.hibernate.internal.SessionImpl.get(SessionImpl.java:863) [hibernate-core-4.0.1.Final.jar:4.0.1.Final]
        at TestBean.reset(TestBean.java:208)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_30]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_30]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_30]
        at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_30]
        at org.jboss.weld.util.reflection.SecureReflections$13.work(SecureReflections.java:264) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.util.reflection.SecureReflectionAccess.run(SecureReflectionAccess.java:52) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.util.reflection.SecureReflectionAccess.runAsInvocation(SecureReflectionAccess.java:137) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.util.reflection.SecureReflections.invoke(SecureReflections.java:260) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.introspector.jlr.WeldMethodImpl.invoke(WeldMethodImpl.java:174) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.AbstractClassBean.defaultPostConstruct(AbstractClassBean.java:506) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.ManagedBean$ManagedBeanInjectionTarget.postConstruct(ManagedBean.java:174) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.ManagedBean.create(ManagedBean.java:291) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.context.AbstractContext.get(AbstractContext.java:107) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.proxy.ContextBeanInstance.getInstance(ContextBeanInstance.java:90) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:79) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.jboss.weld.proxies.TestBean$Proxy$_$$_WeldClientProxy.toString(TestBean$Proxy$_$$_WeldClientProxy.java) [weld-core-1.1.5.Final.jar:]
        at org.apache.el.lang.ELSupport.coerceToString(ELSupport.java:386) [jbossweb-7.0.8.Final.jar:]
        at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:397) [jbossweb-7.0.8.Final.jar:]
        at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:191) [jbossweb-7.0.8.Final.jar:]
        at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:227) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.el.ELText$ELTextComposite.writeText(ELText.java:150) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.facelets.compiler.UILeaf.encodeAll(UILeaf.java:183) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at javax.faces.render.Renderer.encodeChildren(Renderer.java:168) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1756) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1759) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:402) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:288) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) [jsf-impl-2.1.5-jbossorg-1.jar:2.1.5-SNAPSHOT]
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.8.Final.jar:]
        at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62) [weld-core-1.1.5.Final.jar:2012-01-06 11:59]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.8.Final.jar:]
        at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:155) [jboss-as-web-7.1.0.Final-SNAPSHOT.jar:7.1.0.Final-SNAPSHOT]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.8.Final.jar:]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.8.Final.jar:]
        at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.8.Final.jar:]
        at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.8.Final.jar:]
        at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.8.Final.jar:]
        at java.lang.Thread.run(Thread.java:662) [:1.6.0_30]

  • 3. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Ste Gr Newbie

    Anyone, that as an idea?

  • 4. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Danjel Nyberg Newbie

    I added the jtds driver to modules/net/sourcefourge/jtds/main and put dependencies to javax.api, and javax.transaction.api

     

    <?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>

     

     

    then i added the datasource to standalone.xml as follows:

           <subsystem xmlns="urn:jboss:domain:datasources:1.0">
                <datasources>
                    <datasource jndi-name="java:jboss/datasources/<#databasejndiname>" pool-name="<#pool_name>" enabled="true">
                        <connection-url>
                            jdbc:jtds:sqlserver://<#ip-address>;DatabaseName=<#db_name>
                        </connection-url>
                        <driver>
                            JTDS
                        </driver>
                        <security>
                            <user-name>
                                <#username>
                            </user-name>
                            <password>
                                <#password>
                            </password>
                        </security>
                    </datasource>
                    <drivers>
                        <driver name="JTDS" module="net.sourceforge.jtds">
                            <driver-class>
                                net.sourceforge.jtds.jdbc.Driver
                            </driver-class>
                            <xa-datasource-class>
                                net.sourceforge.jtds.jdbcx.JtdsDataSource
                            </xa-datasource-class>
                        </driver>
                    </drivers>
                </datasources>
            </subsystem>

    and then i made sure that my application.xml points to my #databasejndiname

     

    And i use the Jtds_1.2.5

     

    Kind Regards

    /Danjel

     

     

  • 5. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Ste Gr Newbie

    Hi Danjel,

     

    thanks for your reply. As long as I configure my connections with JPA and the datasources from JBoss (with JDTS Driver setup in standalone.xml), everything works fine. I wrote that in the first post unter #1

    But I tried to configure Hibernate through hibernate.cfg.xml without using JPA. It's neither  working with the JBoss datasources (configured in standalone.xml) nor with the native way by suppling the login credentials in the hibernate.cfg.xml with the driver-class set to jdts ( => class not found ).

  • 6. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Danjel Nyberg Newbie

    Ah, sorry for that

     

    But it complains about naming, have you looked it over to conform to the correct naming standard?

     

    It seems like adding dependencies to the requiered modules in the manifest would be enough.

    Adding jtds as a depency to hibernate is not as neat as one would prefer, but there are no actual downsides to it rather then it might be harder to maintain.

     

    /Danjel

  • 7. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Carlo de Wolf Master

    It's a JDBC short-coming. java.sql.DriverManager is only allowed access to driver classes which are available to the caller (in this case Hibernate).

     

    getDrivers hints at this as does the rest of the doc, but it is not expliticly mentioned in getConnection.

  • 8. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Ste Gr Newbie

    Thanks. So i have no other possibility than to add the driver-libraries as a dependency for hibernate, right?

  • 9. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Belai Beshah Newbie

    I have the same problem, in my case I am using Hibernate to open an Microsoft Access Database file that can't be configured as a datasource since it varies based on what the user uploaded.

     

    properties.setProperty("hibernate.connection.url", "jdbc:access:///" + filename)

     

    is there any way to make this work. It looks kind of bad to make the shared hibernate module depend on a driver used by a single application.

  • 10. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Scott Marlow Master

    You might want to follow http://lists.jboss.org/pipermail/hibernate-dev/2012-March/007907.html where we are discussing whether Hibernate (in the future) should accomadate referencing JDBC drivers that are accessible to the application deployment. 

     

    I wouldn't want to see you add the JDBC driver to every deployment/module classpath but you could try that if you like.  See the description of configuring Global Modules here.  I would probably change the shared Hibernate module instead (adding the JDBC driver module dependency).  Neither of these hacks will help you access JDBC drivers that are deployed with the application.

  • 11. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Steve Ebersole Apprentice

    Please note that while we probably will add the ability to load JDBC driver classes in this way, there is another related issue you need to be aware of.  Namely you are using a documented non-supported class.  org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.  So even if we do address the classloading, you still have that issue.  You would want to leverage a real Connection pool as well..

  • 12. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Scott Marlow Master

    We need someone here to build Hibernate from source and try the fix for HHH-7169.  The first volunteer will try the following steps to build Hibernate.  Even better, you can all try this:

     

    1.  Install git (source control client on your machine).

    2.  in a dev folder, type command "git clone git@github.com:hibernate/hibernate-orm.git"

    3.  cd hibernate-orm

    4.  export GRADLE_OPTS="-Xmx1024m -Xms512m"

         or

         set GRADLE_OPTS="-Xmx1024m -Xms512m"

    5.  ./gradlew clean install

         or

          gradlew.bat clean install

     

    Then we can discuss putting the built Hibernate jars into your AS7 installation for testing the fix.  Let me know when your ready for this step.

     

    Scott

  • 14. Re: [AS 7.1 / Hibernate 4] Module classpath & DB-Drivers
    Ubaid Butt Newbie

    Check your naming conventions

1 2 Previous Next