[Management, JMX/JBoss] - Re: auto redeploy dynamic mbean on JBoss restart
by cnsxxx09
Hi,
Three final problems before I have this working 100%.
1. Classloader.
I have all my code neatly contained in a .war package.
Now, when I use the Deployment Service it creates an independent XML
service file in the deploy/ directory. JBoss cannot then find my
MBean class file to load it.
Duplicating my code and my many dependent libraries in JBoss lib/
works but .... it's not ideal. Is there an easier way to make my classes/libraries available from within my war?
2. Default MBean attributes.
When using my web-based scheduler to create these xxx-service.XML
files, I want to pass in some default values upon -initial- deployment.
I amended the xmbean part of the velocity template so I can now 'in
theory' pass in such a default value as follows:
MBean Attribute.
Id
java.lang.String
But when the MBean is deployed it doesn't then set this default
value, it uses the value from the MBean class:
private String id = "";
(The persistence does work ok, if I change the value and restart
JBoss then it is correctly reset from the value in the xmbean-attrs/
directory).
I did think about subsequently looking up the MBean and then invoking
the set method, but this is not so clean and there is an unknown
delay between deploying it and when it is ready to use which would be
ugly to factor in.
3. Remove Module.
I am going to try overriding the MBean destroy() method to physically remove my module (XML file) as follows:
DeploymentServiceMBean.removeModule(myModuleId);
Is there any easy way to get the module Id? (which of course relates
to the name of the XXX-service.XML file, not the object name).
I can kludge this by passing it in as a default MBean value, if I get
2. working that is! But maybe there is a more elegant way?
Thanks
Chris
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983369#3983369
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983369
19Â years, 6Â months
[Persistence, JBoss/CMP, Hibernate, Database] - Unable to Connect to C3P0 Connection Pool with JPA under 4.0
by jantzen
Hi All,
I'm attempting to connect to a PostgreSQL database via a database pool and seeing some odd behavior:
JBoss 4.0.5
c3p0-0.9.1-pre6.jar
PostgreSQL 8.1
It looks to me that the pool is starting correctly, as I see it in the logs
| 22:26:16,920 INFO [C3P0PooledDataSource] Bound C3P0 PooledDataSource to name 'java:EventDBPool'. Starting...
| 22:26:16,951 INFO [PoolBackedDataSource] Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource@5d11c3f0[ ...
| 22:26:16,993 INFO [JmxKernelAbstraction] installing MBean: persistence.units:ear=DataTier.ear,jar=DataTier.jar,unitName=EventDBUnit with dependencies:
| 22:26:16,994 INFO [JmxKernelAbstraction] jboss.jca:name=EventDBPool,service=DataSourceBinding
|
However below I see:
| --- MBeans waiting for other MBeans ---
| ObjectName: persistence.units:ear=DataTier.ear,jar=DataTier.jar,unitName=EventDBUnit
| State: NOTYETINSTALLED
| I Depend On:
| jboss.jca:name=EventDBPool,service=DataSourceBinding
|
| --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
| ObjectName: jboss.jca:name=EventDBPool,service=DataSourceBinding
| State: NOTYETINSTALLED
| Depends On Me:
| persistence.units:ear=DataTier.ear,jar=DataTier.jar,unitName=EventDBUnit
|
Here's my c3p0-service.xml:
<?xml version="1.0" encoding="UTF-8"?>
| <!DOCTYPE server PUBLIC "-//JBoss//DTD MBean Service 4.0//EN" "http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd">
| <server>
| <mbean code="com.mchange.v2.c3p0.mbean.C3P0PooledDataSource" name="jboss:service=EventDBPooledDS">
| <attribute name="JndiName">java:EventDBPool</attribute>
| <attribute name="JdbcUrl">jdbc:postgresql://localhost/EventDB</attribute>
| <attribute name="DriverClass">org.postgresql.Driver</attribute>
| <attribute name="User">myuser</attribute>
| <attribute name="Password">mypass</attribute>
| <attribute name="IdleConnectionTestPeriod">90</attribute>
| <attribute name="MaxPoolSize">15</attribute>
| <attribute name="MinPoolSize">5</attribute>
| <attribute name="TestConnectionOnCheckin">true</attribute>
|
| <depends>jboss:service=Naming</depends>
| </mbean>
| </server>
|
And my persistence.xml
| <?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"
| version="1.0">
| <persistence-unit name="EventDBUnit" transaction-type="JTA">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:EventDBPool</jta-data-source>
| <properties>
| <property name="hibernate.show_sql" value="true" />
| </properties>
| </persistence-unit>
|
Also, if I create an EntityManagerFactory from that persistence unit directly in my code, I'm able to use it. However, if I use dependency injection via @PersistenceContext it doesn't work.
My questions:
1) is there an error in my persistence.xml or c3p0-service.xml preventing startup or connection to the pool?
2) ought I to be using c3p0 still or JBoss's ManagedConnectionPool?
Thanks in advance,
David
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3983368#3983368
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3983368
19Â years, 6Â months