我安装了一个与PostgreSQL一起工作的JBoss...我正在尝试改用MySQL。
我下载了mysql-connector-java-5.1.36-bin.jar并将其放入jboss_home/module/com/mysql/main,创建了module.xml并更改了standalone.xml。
但是,如果我尝试启动服务器,我就得到了下面的stacktrace:
ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 48) MSC000001: Failed to start service jboss.persistenceunit."myapp.war#myapp": org.jboss.msc.service.StartException in service jboss.persistenceunit."myapp.war#myapp": javax.persistence.PersistenceException: [PersistenceUnit: myapp] Unable to build EntityManagerFactory
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:103)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_20]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_20]
at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar:2.1.1.Final-redhat-1]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: myapp] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:924)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:899)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:76)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.createContainerEntityManagerFactory(PersistenceUnitServiceImpl.java:200)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl.access$600(PersistenceUnitServiceImpl.java:57)
at org.jboss.as.jpa.service.PersistenceUnitServiceImpl$1.run(PersistenceUnitServiceImpl.java:99)
... 4 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Specified JDBC Driver com.mysql.jdbc.Driver could not be loaded
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:111)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.buildJdbcConnectionAccess(JdbcServicesImpl.java:223)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:89)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:85)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:184)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:156)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1825)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1783)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
... 9 more
Caused by: org.hibernate.service.classloading.spi.ClassLoadingException: Unable to load class [com.mysql.jdbc.Driver]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:151)
at org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl.configure(DriverManagerConnectionProviderImpl.java:106)
... 21 more
Caused by: java.lang.ClassNotFoundException: Could not load requested class : com.mysql.jdbc.Driver
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl$AggregatedClassLoader.findClass(ClassLoaderServiceImpl.java:318)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424) [rt.jar:1.8.0_20]
at java.lang.ClassLoader.loadClass(ClassLoader.java:357) [rt.jar:1.8.0_20]
at java.lang.Class.forName0(Native Method) [rt.jar:1.8.0_20]
at java.lang.Class.forName(Class.java:340) [rt.jar:1.8.0_20]
at org.hibernate.service.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:148)
... 22 more
有人能帮忙吗?
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="myapp">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- Annotated entity classes -->
<class>br.com.programadoremjava.ginga.test.myapp.entity.MyClassA</class>
<class>br.com.programadoremjava.ginga.test.myapp.entity.MyClassB</class>
<properties>
<!-- DADOS CONEXAO -->
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.username" value="application" />
<property name="hibernate.connection.password" value="application" />
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/myapp" />
<!-- CONFIGURACAO -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
我的Standalone.xml数据源配置:
<subsystem xmlns="urn:jboss:domain:datasources:1.2">
<datasources>
<datasource jta="true" jndi-name="java:/myapp-ds" pool-name="test" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://localhost:3306/myapp</connection-url>
<driver>com.mysql</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<pool>
<min-pool-size>5</min-pool-size>
<max-pool-size>30</max-pool-size>
<prefill>true</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<user-name>application</user-name>
<password>application</password>
</security>
<statement>
<prepared-statement-cache-size>32</prepared-statement-cache-size>
</statement>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
<driver-class>com.mysql.jdbc.Driver</driver-class>
</driver>
</drivers>
</datasources>
</subsystem>
我的jboss_home/module/com/mysql/main/module.xml
<module xmlns="urn:jboss:module:1.0" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.36-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
您必须引用persistence.xml
中的as数据源,并删除所有hibernate.connection.*属性。连接由应用服务器管理,在该场景中,您不需要它来在Hibernate中重新定义它。
我在eclipse插件中使用Hibernate代码生成工具为world数据库生成pojo类、hbm文件和DAO类。这就产生了城市。爪哇,国家。java,Countrylanguage。java和CountrylanguageId。java,但只有三个hbm文件。hbm。xml国家/地区。hbm。xml和Countrylanguage。hbm。xml。 我已经通过addClass在配置中添加了jav
问题内容: 异常堆栈跟踪 我的redirect.jsp文件内容 问题答案: 在servlet容器的掩护下,JSP在执行之前先编译为Java类。 例外 表示您的webcontent文件夹根目录中的文件无法编译,这通常意味着该文件在 scriptlet中 包含一些原始Java代码,这些代码包含语法错误。您需要修复这些语法错误,以便servlet容器可以编译那些JSP文件。但是,普遍的共识是, scri
问题内容: 当我尝试运行Hibernate时,我在控制台中收到以下消息。 但是hibernate状态很好。我的项目有什么问题吗?我使用Eclipse(Helios),Hibernate 3.6.8。我使用这些jar文件:antlr-2.7.6,commons- collections-3.1,dom4j-1.6.1,hibernate3,hibernate- jpa-2.0-api-1.0.1.F
我试图从groovy脚本调用Oracle存储过程,结果出现了标题中的错误。 以下是我的剧本: 当我删除(它们是OUT parameters)参数时,脚本将被编译,所以我认为它们有问题······ 我找到了一个让我的程序工作的解决方案: 但我想有一个更好的方法来传递这些SQL参数... PS:我正在使用Groovy-2.4.13,并尝试了Oracle JDK9和1.8.0_151
我正试图用PDFBox和Groovy来搞乱一下。我试图使用PDType1Font类的getStringWidth()方法计算字符串的宽度。 我的问题是,每次编译和运行代码时,都会出现这样一个错误: 代码如下: 为了清晰起见,我删除了代码中所有不相关的部分。 问题出在哪里? 更新:我在IntelliJ中搜索了一下如何将外部jar添加到我的类路径,发现我需要转到项目结构- 我试着这样做: 但我仍然收到
我的系统中安装了JMeter 5.2.1。当我尝试执行下面的代码时,我遇到了这个错误。 响应消息:javax。剧本ScriptException:组织。科德豪斯。非常棒。控制MultipleComplationErrorsException:启动失败:类生成期间出现常规错误:java。lang.NoClassDefFoundError:无法加载类com。蔚蓝色的消息传递。事件中心。由于缺少依赖关系