Configuring the Embedded EJB Container in Netbeans

  10 posts   Feedicon  
Replies: 9 - Last Post: April 05, 2010 22:45
by: duckconfit
showing 1 - 10 of 10
 
Posted: January 06, 2010 09:14 by Gilbert_Ostlethwaite
Hi

I'm running my unit tests using the embedded container. I'm having problems with some of my entity beans and I want to set the jpa logging level to trace the generated SQL. I've tried adding <property name = " javax.persistence.logging.level" value="FINE"/> to my persistence.xml and I've tried creating the EJBContainer with;

Map<String,String> properties = new HashMap<String,String>();
properties.put("javax.persistence.logging.level","FINE");
ejbc = EJBContainer.createEJBContainer(properties);

but neither gives me the detailed SQL output to the console when I run my tests. How do I set the logging level?

Regards
 
Posted: February 18, 2010 17:18 by youness
Hi Gilbert,

It seems you have configured the Embedded EJB Container in a way that it uses a jndi data source other than the JavaDB which is the default.
I am going to use a mysql data source in embedded ejb but nothing has helped yet.
Please tell me how did you do that? I mean how did you set your EJBContainer in your test code?
Note that when I set the <jta-data-source>jdbc/example</jta-data-source> in my persistence context, an error occurs indicating that the jdbc/example is not found.
 
Posted: January 06, 2010 09:37 by Marco
Hi,

I'm not really sure but I think the properties parameter for createEJBContainer() are just configuration options for the container in general.
If you're talking about the SQL logging output for JPA based persistence I guess you must use these properties to configure JPA when creating an EntityManagerFactory for testing purposes or in your persistence.xml descriptor.

Marco
 
Posted: January 06, 2010 09:53 by Gilbert_Ostlethwaite
Hi Marco

I've tried that <property name="javax.persistence.logging.level" value="FINE"/> and no joy

Regards
 
Posted: January 06, 2010 10:12 by Marco
Can you confirm that your persistence unit is created correctly (besides the logging issue)? Sorry, I have not yet used the embedded container. For this I don't know if it works exactly like a "real" container.

Maybe you could also try to use a JPA provider specific property like the following, at least to find the problem. Are you sure that logging level is now one of the default properties which were standardized?

<property name="eclipselink.logging.level" value="FINE"/>

Marco
 
Posted: January 06, 2010 10:47 by Gilbert_Ostlethwaite
The persistence.xml is definitely being read - if I change the name of the persistance unit then the creation of the EJB Container fails or if I change the userId then it also fails.

Regards

<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" 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_2_0.xsd">
<persistence-unit name="Devere" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>jdbc/Devere</jta-data-source>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/Devere?sessionVariables=storage_engine=InnoDB"/>
<property name="javax.persistence.jdbc.user" value="user"/>
<property name="javax.persistence.jdbc.password" value="password"/>
<property name="javax.persistence.logging.level" value="FINE"/>
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.ddl-generation.output-mode" value="database"/>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>
 
Posted: January 06, 2010 10:55 by Marco
OK, that's a little bit strange. Maybe it's a general problem with logging inside an embedded container. But as I already said, I've not yet used this new feature so I can't give you any advices. I could just try myself to get it up and running later to see what's happening but at the moment I don't have enough time. Maybe someone else has a more useful answer in the meantime. Sorry!

Marco
 
Posted: January 06, 2010 13:56 by Gilbert_Ostlethwaite
If anyone else has an idea I'd appreciate it. I'd also like to be able to enable detailed logging for the embedded container as well as the JPA provider - if anyone knows how. I've got two weird things going on - new entity instances being persisted when I haven't called persist() and I'm loosing references to injected EJB's and my tests terminate with a NPE - without detailed logs to see what's going on I'm stuffed.

Regards
 
Posted: January 27, 2010 17:44 by andyferraro
Hi Marco,
how didn't you started your Embedded Glassfish?

1) usingo EE API (javax.ejb.embeddable.* createEJBContainer(),etc.) ?
or
2) using directly Glassfish API (org.glassfish.api.embedded.* Server.Builder builder = new Server.Builder("test"), etc.) ?

Did you read the Glassfish Embedded userguide http://dlc.sun.com/pdf/821-1208/821-1208.pdf ?

Cheers,
Andrea
 
Posted: April 05, 2010 22:45 by duckconfit
I have the same problem and it's frustrating -- I have to use mysql-proxy to see the SQL.

I have a working domain.xml in src/test/resources/org/glassfish/embed and set up the test class using EJBContainer.createEJBContainer(). Without the domain.xml in the obscure location, I have not been able to get a working combination of install/instance roots that worked reliably.

When I use strace -eopen -f java... on linux, I can see logging.properties opened where I expect. I'm about ready to write a custom logger to capture this stuff since the one known bridge to Log4J/Commons-Logging doesn't work with SLF4J/LogBack.

When I deploy the application to full Glassfish, I get tons of output. It just seems like the EJBContainer technique is broken.

I read that document. What would be more helpful is a simple Maven project (no NetBeans) available for download that worked against a freshly installed GlassFish. It would be even better if it didn't use Derby but MySQL instead to make sure there weren't any configurations assumed.
showing 1 - 10 of 10
Replies: 9 - Last Post: April 05, 2010 22:45
by: duckconfit
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120127.ac94057)
 
 
Close
loading
Please Confirm
Close