I've set up my database in TomEE such that it works fine with SQL Query.  When 
I attempted to do a simple entityManager.find() as a JPA test, I got the 
following error:
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: The bean 
encountered a non-application exception; nested exception is: 
        java.lang.IllegalArgumentException: Unknown entity: 
com.example.account.Application
I've gotten around this by adding 
<class>com.example.account.Application</class> to my persistence.xml file.  
However, in JBoss everything Just Works thanks to annotations and I don't need 
to use XML to set up my entities at all.  On the one hand it's a bit of a 
bummer to add in all that XML but I can handle it if I have to.  I'm 
experiencing some other issues though so I'm wondering if there's a bigger 
configuration problem that I should address.

I've also tried using 
<exclude-unlisted-classes>false</exclude-unlisted-classes> and <property 
name="hibernate.archive.autodetection" value="class" /> but neither of these 
seems to have made a difference for me.

Because of the custom JNDI naming system in my code, and to keep things simple, 
I've been slowly adding in files into WEB-INF/classes/com/example.  I could 
package them into WEB-INF/lib/example.jar but then I think I'd have to rewrite 
a LOT of JNDI naming, and my (limited) understanding is that it's not necessary 
to package the classes into a JAR for any reason.

Here are some of my other files:

persistence.xml:

<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="ExampleEngine">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>com.example.account.Application</class>

        <properties>
            <property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
            <property name="hibernate.hbm2ddl.auto" value="update"/>
        </properties>
    </persistence-unit>
</persistence>


tomee.xml:

<?xml version="1.0" encoding="UTF-8"?>
<tomee>
        <Resource id="example_db_prod" type="DataSource">
                        JdbcDriver  com.mysql.jdbc.Driver
                        JdbcUrl 
jdbc:mysql://localhost:3306/example_db_prod?autoReconnect=true
                        UserName myusername
                        Password mypassword
                        validationQuery = SELECT 1
                        JtaManaged true
        </Resource>
</tomee>

Thank you very much for any help you can provide.  It's a very steep learning 
curve trying to do this migration and I keep running into roadblock after 
roadblock.

- Andrew.

Reply via email to