[Persistence, JBoss/CMP, Hibernate, Database] - Re: Trying to get JBoss and Hibernate to integrate
by thetikigod
I tried moving the hibernate.cfg.xml to the root directory and I get the stack trace:
| Cause: org.hibernate.HibernateException: /hibernate.cfg.xml not found
| Message: /hibernate.cfg.xml not found
| StackTrace:
|
| org.hibernate.HibernateException: /hibernate.cfg.xml not found
| at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
| at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
| at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
| at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
| at com.burris.ssapp.user.views.MainView.prepare(MainView.java:330)
| at com.burris.ssapp.user.portlet.UserPortlet.doView(UserPortlet.java:80)
| at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:133)
| at javax.portlet.GenericPortlet.render(GenericPortlet.java:306)
| at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.invokeRender(PortletContainerImpl.java:483)
| at org.jboss.portal.portlet.impl.jsr168.PortletContainerImpl.dispatch(PortletContainerImpl.java:405)
| at org.jboss.portal.portlet.container.PortletContainerInvoker$1.invoke(PortletContainerInvoker.java:86)
| at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:131)
| at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.org$jboss$portal$core$aspects$portlet$TransactionInterceptor$invokeNotSupported$aop(TransactionInterceptor.java:86)
| at org.jboss.portal.core.aspects.portlet.TransactionInterceptor$invokeNotSupported_N4547270787964792031.invokeNext(TransactionInterceptor$invokeNotSupported_N4547270787964792031.java)
| at org.jboss.aspects.tx.TxPolicy.invokeInNoTx(TxPolicy.java:66)
| at org.jboss.aspects.tx.TxInterceptor$NotSupported.invoke(TxInterceptor.java:112)
| at org.jboss.portal.core.aspects.portlet.TransactionInterceptor$invokeNotSupported_N4547270787964792031.invokeNext(TransactionInterceptor$invokeNotSupported_N4547270787964792031.java)
| at org.jboss.aspects.tx.TxPolicy.invokeInNoTx(TxPolicy.java:66)
| at org.jboss.aspects.tx.TxInterceptor$NotSupported.invoke(TxInterceptor.java:102)
| at org.jboss.portal.core.aspects.portlet.TransactionInterceptor$invokeNotSupported_N4547270787964792031.invokeNext(TransactionInterceptor$invokeNotSupported_N4547270787964792031.java)
| at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.invokeNotSupported(TransactionInterceptor.java)
| at org.jboss.portal.core.aspects.portlet.TransactionInterceptor.invoke(TransactionInterceptor.java:56)
| at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
| at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
| at org.jboss.portal.core.aspects.portlet.HeaderInterceptor.invoke(HeaderInterceptor.java:50)
| at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
| at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
| at org.jboss.portal.portlet.aspects.portlet.ProducerCacheInterceptor.invoke(ProducerCacheInterceptor.java:58)
| at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
| at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
| at org.jboss.portal.core.aspects.portlet.AjaxInterceptor.invoke(AjaxInterceptor.java:51)
| at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
| at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
| at org.jboss.portal.portlet.aspects.portlet.ModesInterceptor.invoke(ModesInterceptor.java:62)
| at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
| at org.jboss.portal.common.invocation.Invocation.invokeNext(Invocation.java:115)
| at org.jboss.portal.portlet.bridge.BridgeInterceptor.invoke(BridgeInterceptor.java:47)
| at org.jboss.portal.portlet.invocation.PortletInterceptor.invoke(PortletInterceptor.java:38)
|
Before I moved the cfg to the root level, I got these messages in the console a few seconds after deploy:
| 10:18:57,867 INFO [Configuration] configuring from resource: /hibernate.cfg.xml
| 10:18:57,867 INFO [Configuration] Configuration resource: /hibernate.cfg.xml
|
This leads me to believe it was finding it in the META-INF folder.
http://www.hibernate.org/66.html
As far as the jars go, the above site lists the necessary files to be in the server lib directory. They are all there except
commons-lang.jar
jcs.jar
odmg.jar
I also have not included these in the project. I have only included the files to keep the compiler from complaining at me. I will locate these jars and place them in the lib directory and also try including them in the project. I am not sure if these could be related to my problem.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158723#4158723
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158723
17 years, 10 months
[Management, JMX/JBoss] - Migration: 3.2.0 to 4.2.2 (org.jboss.jmx.adaptor.rmi.RMIAdap
by pdeshmuk
We are currently migrating from JBoss 3.2.0 to 4.2.2 and the registerMBean() method from the org.jboss.jmx.adaptor.rmi.RMIAdaptor interface seems to have been removed (getting compile error on the method).
This is our current method to register the JBoss scheduler:
public void registerSchedule() throws SchedulerException {
unregisterSchedule(false); // just in case
try {
server.registerMBean(this, scheduleName);
} catch (Exception e) {
throw new SchedulerException(e.getMessage(), e);
}
}
The registerMBean method has been removed from the RMIAdaptor interface and thus fails to compile:
server.registerMBean(this, scheduleName);
We were wondering if this should be replaced by the createMBean method (from the javax.management.MBeanServerConnection super-interface of RMIAdaptor) as follows:
server.createMBean(this.getClass().getName(), scheduleName);
Any thoughts will be greatly appreciated.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158714#4158714
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158714
17 years, 10 months
[Management, JMX/JBoss] - jconsole problem with JDK1.6
by drwschneider
I'm running JBoss 4.2.2.GA (just the standard distribution, no other applications deployed) with Sun JDK1.6.0_10.
The platform MBean server is enabled with
JAVA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
| JAVA_OPTS="$JAVA_OPTS -Djboss.platform.mbeanserver -Djavax.management.builder.initial=org.jboss.system.server.jmx.MBeanServerBuilderImpl"
in the run.conf file in the bin directory., as described in the Wiki.
JConsole does show the JBoss MBeans in the console's MBean Tab, but all other Tabs (Memory, Threads, ..etc) are greyed out and unavailable.
When I use the JBoss MBean server, removing the jboss.platform.mbeanserver option, those tabs are available, but of course the JBoss MBeans are not shown.
JRockit1.6 shows the same behaviour.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158704#4158704
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158704
17 years, 10 months
[Persistence, JBoss/CMP, Hibernate, Database] - EntityManager Injection, Null Pointer Exception. (Sorry...)
by repkin
I wanted the entitymanager have been injected by the container. But after a lot of trial, I decided to ask the question.
Here is the situation,
My ear file structure:
| surgeonfish.ear
| |----surgeonfish-ds.xml
| |----META-INF
| |----application.xml
| |----jboss-app.xml
| |----MANIFEST.MF
| |----surgeonfish.jar
| |----com.beans...
| |----META-INF
| |----persistence.xml
| |----MANIFEST.MF
| |----surgeonfish.war
| |----META-INF
| |----MANIFEST.MF
| |----WEB-INF
| |----classes
| |----lib
| |----web.xml
|
--------
surgeonfish-ds.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>time_reporting_data_source</jndi-name>
| <connection-url>jdbc:mysql://localhost:3306/timereporting</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>root</user-name>
| <password>test</password>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
----------------
application.xml
| <application>
| <display-name>Surgeonfish</display-name>
| <module>
| <web>
| <web-uri>surgeonfish.war</web-uri>
| <context-root>/surgeonfish</context-root>
| </web>
| </module>
| <module>
| <ejb>surgeonfish.jar</ejb>
| </module>
| </application>
|
---------------
jboss-app.xml:
| <jboss-app>
| <module>
| <service>surgeonfish-ds.xml</service>
| </module>
| <loader-repository>
| surgeonfish:archive=surgeonfish.ear
| </loader-repository>
| </jboss-app>
|
--------------
persistence.xml:
| <persistence>
| <persistence-unit name="time_report_persistence_context">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/time_reporting_data_source</jta-data-source>
| <jar-file>../surgeonfish.jar</jar-file>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
| <property name="hibernate.show_sql" value="true"/>
| <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
| <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
| </properties>
| </persistence-unit>
| </persistence>
|
----------------------
Here my test bean:
| package com.xyz...;
|
|
| import javax.ejb.Local;
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.EntityManagerFactory;
| import javax.persistence.Persistence;
| import javax.persistence.PersistenceContext;
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
|
| @Stateless
| @Local(value=PrStaffInterface.class)
| public class PrStaffHome {
|
| private static final Log log = LogFactory.getLog(PrStaffHome.class);
|
| @PersistenceContext(unitName="time_report_persistence_context")
| private EntityManager entityManager;
|
| public PrStaff findById(Integer id) {
| log.debug("getting PrStaff instance with id: " + id);
| try {
| /*
| EntityManagerFactory emf = Persistence.createEntityManagerFactory("time_report_persistence_context");
| EntityManager em = emf.createEntityManager();
| PrStaff instance1 = em.find(PrStaff.class, id);
| ---this lines working without any error...---
| */
|
| PrStaff instance = entityManager.find(PrStaff.class, id);->I am taking null pointer exception here...
| System.out.println("instance:"+instance);
| log.debug("get successful");
| return instance;
| } catch (RuntimeException re) {
| log.error("get failed", re);
| throw re;
| }
| }
| }
|
I cant find reason, why container is not injecting the entity manager. Of course I am missing something but I cant find. Thanks for your helps...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158701#4158701
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158701
17 years, 10 months
[EJB 3.0] - EntityManager Injection, Null Pointer Exception. (Sorry...)
by repkin
I wanted the entitymanager have been injected by the container. But after a lot of trial, I decided to ask the question.
Here is the situation,
JBoss Server:jboss-4.2.2.GA
My ear file structure:
| surgeonfish.ear
| |----surgeonfish-ds.xml
| |----META-INF
| |----application.xml
| |----jboss-app.xml
| |----MANIFEST.MF
| |----surgeonfish.jar
| |----com.beans...
| |----META-INF
| |----persistence.xml
| |----MANIFEST.MF
| |----surgeonfish.war
| |----META-INF
| |----MANIFEST.MF
| |----WEB-INF
| |----classes
| |----lib
| |----web.xml
|
----------------
HERE ARE MY CONFIG FILES:
----------------
surgeonfish-ds.xml:
| <?xml version="1.0" encoding="UTF-8"?>
| <datasources>
| <local-tx-datasource>
| <jndi-name>time_reporting_data_source</jndi-name>
| <connection-url>jdbc:mysql://localhost:3306/timereporting</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>root</user-name>
| <password>test</password>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
----------------
application.xml
| <application>
| <display-name>Surgeonfish</display-name>
| <module>
| <web>
| <web-uri>surgeonfish.war</web-uri>
| <context-root>/surgeonfish</context-root>
| </web>
| </module>
| <module>
| <ejb>surgeonfish.jar</ejb>
| </module>
| </application>
|
---------------
jboss-app.xml:
| <jboss-app>
| <module>
| <service>surgeonfish-ds.xml</service>
| </module>
| <loader-repository>
| surgeonfish:archive=surgeonfish.ear
| </loader-repository>
| </jboss-app>
|
--------------
| persistence.xml:
| <persistence>
| <persistence-unit name="time_report_persistence_context">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <jta-data-source>java:/time_reporting_data_source</jta-data-source>
| <jar-file>../surgeonfish.jar</jar-file>
| <properties>
| <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
| <property name="hibernate.show_sql" value="true"/>
| <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
| <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
| </properties>
| </persistence-unit>
| </persistence>
|
----------------------
Here my test bean:
| package com.xyz...;
|
|
| import javax.ejb.Local;
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.EntityManagerFactory;
| import javax.persistence.Persistence;
| import javax.persistence.PersistenceContext;
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
|
| @Stateless
| @Local(value=PrStaffInterface.class)
| public class PrStaffHome {
|
| private static final Log log = LogFactory.getLog(PrStaffHome.class);
|
| @PersistenceContext(unitName="time_report_persistence_context")
| private EntityManager entityManager;
|
| public PrStaff findById(Integer id) {
| log.debug("getting PrStaff instance with id: " + id);
| try {
| /*
| EntityManagerFactory emf = Persistence.createEntityManagerFactory("time_report_persistence_context");
| EntityManager em = emf.createEntityManager();
| PrStaff instance1 = em.find(PrStaff.class, id);
| ---this lines working without any error...---
| */
|
| PrStaff instance = entityManager.find(PrStaff.class, id);->I am taking null pointer exception here...
| System.out.println("instance:"+instance);
| log.debug("get successful");
| return instance;
| } catch (RuntimeException re) {
| log.error("get failed", re);
| throw re;
| }
| }
| }
|
I cant find reason, why container is not injecting the entity manager. Of course I am missing something but I cant find. Thanks for your helps...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4158700#4158700
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4158700
17 years, 10 months