[jboss-user] [Beginners Corner] - Connecting to Hibernate
revof11
do-not-reply at jboss.com
Mon Sep 24 12:15:10 EDT 2007
All,
I have been working on a very simple EJB 3 sample setup for myself and am working on the persistence setup for testing simple data storage via an EntityManager. The problem is that I am unable to connect to the internal HSQL database using my configurations. I would appreciate if someone could help me out.
The following are the steps I took to attempt this database setup:
1. Install JBoss w/ the JEMS Installer (using all the defaults)
2. Start the server
3. Drop my Ejb3Example-ds.xml file into the deploy folde
<?xml version="1.0" encoding="UTF-8"?>
|
| <datasources>
|
| <local-tx-datasource>
| <jndi-name>Ejb3ExampleDB</jndi-name>
| <connection-url>jdbc:hsqldb:${jboss.server.data.dir}${/}hypersonic${/}Ejb3ExampleDB</connection-url>
| <driver-class>org.hsqldb.jdbcDriver</driver-class>
| <user-name>sa</user-name>
| <password></password>
| <min-pool-size>5</min-pool-size>
| <max-pool-size>20</max-pool-size>
|
| <idle-timeout-minutes>0</idle-timeout-minutes>
| <track-statements />
| <security-domain>HsqlDbRealm</security-domain>
|
| <metadata>
| <type-mapping>Hypersonic SQL</type-mapping>
| </metadata>
|
| <depends>jboss:service=Hypersonic,database=Ejb3ExampleDB</depends>
|
| </local-tx-datasource>
|
| <!-- This mbean can be used when using in process persistent db -->
| <mbean code="org.jboss.jdbc.HypersonicDatabase"
| name="jboss:service=Hypersonic,database=Ejb3ExampleDB">
| <attribute name="Database">Ejb3ExampleDB</attribute>
| <attribute name="InProcessMode">true</attribute>
| </mbean>
|
| </datasources>
|
4. Build my application source and package it into a Jar including my persistence.xml (sp?) file within the META-INF directory
<?xml version="1.0" encoding="UTF-8"?>
|
| <persistence xmlns="http://java.sun.com/xml/ns/persistence"
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
| xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
| version="1.0">
|
| <persistence-unit name="Ejb3Example">
|
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/Ejb3ExampleDB</jta-data-source>
| <properties>
| <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
| <property name="hibernate.hbm2ddl.auto" value="create-drop" />
| </properties>
|
| </persistence-unit>
|
| </persistence>
|
5. Drop my Jar into the deploy folder with my DAO class set up as follows:
@Stateful
| public class MyDaoBean implements MyDaoLocal, MyDaoRemote
| {
| @PersistenceContext(unitName = "Ejb3Example")
| private EntityManager entityManager;
|
| private Logger logger;
|
| @PostConstruct
| public void init() {
| // attribute initialization
| logger = Logger.getLogger("Ejb3ExampleStorageManager");
|
| // core logging
| logger.info("EJB 3 Example storage initialized.");
| logger.info("Storage flush mode: " + entityManager.getFlushMode());
| }
|
| public void ping() {
| logger.debug("Object Storage Ping");
| }
|
| public void create(Serializable obj) {
| logger.info("Persis requested for " + obj.getClass().getName());
| entityManager.persist(obj);
| }
|
| public <T> T find(Class<T> objectType, UUID primaryKey) {
| logger.info("Lookup requested for " + objectType.getName() + "/" + primaryKey);
| return entityManager.find(objectType, primaryKey);
| }
| }
The problems that I get are exceptions thrown apparently relating to authentication errors (larger stack trace available upon request):
...
| org.jboss.resource.JBossResourceException: No matching credentials in Subject!
| ...
| org.jboss.util.NestedSQLException: No matching credentials in Subject!; - nested throwable: (org.jboss.resource.JBossResourceException: No matching credentials in Subject!)
| ...
| Caused by: org.jboss.resource.JBossResourceException: No matching credentials in Subject!
| ... etc.
What am I doing wrong?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4088033#4088033
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4088033
More information about the jboss-user
mailing list