[Persistence, JBoss/CMP, Hibernate, Database] - Refering to a datasource wih its ENC name
by MarcusDidiusFalco
Hallo!
I have a datsource
<datasources>
| <local-tx-datasource>
| <jndi-name>FencingDS</jndi-name>
| <connection-url>jdbc:mysql://localhost:3306/fencing</connection-url>
| .....
| </local-tx-datasource>
| </datasources>
deployed. Using the JMX console it shows up in the JNDI java: Namespace under FencingDS.
So I want to get a connection from it in an EJB
ctx = new InitialContext();
| DataSource ds = (DataSource) ctx.lookuk("java:/comp/env/jdbc/FencingDS");
| Connection con = (Connection) ds.getConnection();
ejb-jar.xml:
<ejb-jar>
| <enterprise-beans>
| <session>
| <description>TestBean </description>
| <ejb-name>TestBean</ejb-name>
| <resource-ref>
| <description>Beschreibung der Resourcen</description>
| <res-ref-name>jdbc/FencingDS</res-ref-name>
| <res-type>javax.sql.DataSource</res-type>
| <res-auth>Container</res-auth>
| </resource-ref>
| </session>
| </enterprise-beans>
| </ejb-jar>
In jboss.xml I try to map the global JNDI name to the ENC name:
<jboss>
| <enterprise-beans>
| <session>
| <ejb-name>TestBean</ejb-name>
| <resource-ref>
| <res-ref-name>jdbc/FencingDS</res-ref-name>
| <resource-name>java:FencingDS</resource-name>
| </resource-ref>
| </session>
| </enterprise-beans>
| </jboss>
But when I try to deploy the jar I always get an Exception
java.lang.RuntimeException: mapped-name is required for jdbc/FencingDS of deployment TestBean
and the EJB is not bound.
I have so far not found a reference how to do this right.
I would greatly appreciate any help.
Thanks,
Hans
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098189#4098189
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098189
18Â years, 8Â months
[JBoss jBPM] - jbpm-bpel-1.1.Beta3 + oracle10g
by cocogg
hi,
I have no problem on run jbpm-bpel-1.1.Beta3's sample(hello) with default db, but I want use Oracle db, I change the hibernate.cfg.xml and jbpm-bpel-ds.xml, when I deploy the jpbm-bpel.sar ,I get a exception.I confused whether I made a mistake, or jbpm-bpel-1.1.Beta3 didn't support other db.I whould appreciate if some on can give me a answer.
----------------------------------------------------------------------------
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getTypeName(Dialect.java:241)
at org.hibernate.mapping.Column.getSqlType(Column.java:181)
at org.hibernate.mapping.Table.sqlCreateString(Table.java:383)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:879)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:311)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91)
at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:94)
at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:98)
at org.jbpm.persistence.db.DbPersistenceService.getJobSession(DbPersistenceService.java:281)
at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:526)
at org.jbpm.job.executor.JobExecutorThread.acquireJobs(JobExecutorThread.java:109)
at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:56)org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getTypeName(Dialect.java:241)
at org.hibernate.mapping.Column.getSqlType(Column.java:181)
at org.hibernate.mapping.Table.sqlCreateString(Table.java:383)
at org.hibernate.cfg.Configuration.generateSchemaUpdateScript(Configuration.java:879)
at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:140)
at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:311)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1213)
at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:91)
at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:94)
at org.jbpm.persistence.db.DbPersistenceService.getSession(DbPersistenceService.java:98)
at org.jbpm.persistence.db.DbPersistenceService.getJobSession(DbPersistenceService.java:281)
at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:526)
at org.jbpm.job.executor.JobExecutorThread.acquireJobs(JobExecutorThread.java:109)
at org.jbpm.job.executor.JobExecutorThread.run(JobExecutorThread.java:56)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098178#4098178
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098178
18Â years, 8Â months
[JNDI/Naming/Network] - ClassCastException on PortableRemoteObject.narrow(object, He
by lavkul
posted Sunday, October 21, 2007 11:47 PM
--------------------------------------------------------------------------------
I have created an EJB module and a web module.
When I try to run EJB from a servlet I get ClassCastException. I do not know why?
I am using myEclipse 6.0 and JBoss 4.2.1 GA application server.
I get ClassCastException When I try to narrow after lookup.
I have seen many sites but i could not resolve this problem.
Can some one help on this?
Please find below the code details.
jboss.xml
-----------------------------------------------
<enterprise-beans>
<ejb-name>Hello</ejb-name>
<jndi-name>ejb/Hello</jndi-name>
<ejb-name>TesterBean</ejb-name>
<jndi-name>test/Tester</jndi-name>
</enterprise-beans>
ejb-jar.xml
-----------------------------------------------
<enterprise-beans>
<ejb-name>Hello</ejb-name>
com.wiley.examples.HelloHome
com.wiley.examples.Hello
<ejb-class>com.wiley.examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<display-name>TesterBean</display-name>
<ejb-name>TesterBean</ejb-name>
com.wiley.examples.TesterHome
com.wiley.examples.Tester
<ejb-class>com.wiley.examples.TesterEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
jboss-web.xml
-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.4//EN"
"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd">
<jboss-web>
<ejb-ref>
<ejb-ref-name>ejb/HelloEjb</ejb-ref-name>
<jndi-name>ejb/Hello</jndi-name>
</ejb-ref>
</jboss-web>
web.xml
-----------------------------------------------------
<ejb-ref>
<ejb-ref-name>ejb/HelloEjb</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
com.wiley.examples.HelloHome
com.wiley.examples.Hello
<ejb-link>Hello</ejb-link>
</ejb-ref>
code from servlet
---------------------------------------------------
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
env.put(Context.URL_PKG_PREFIXES,"org.jboss.naming rg.jnp.interfaces");
env.put("org.omg.CORBA.ORBInitialHost","localhost");
env.put("org.omg.CORBA.ORBInitialPort","3700");
Context context = new InitialContext();
Object object = context.lookup("java:comp/env/ejb/HelloEjb");
System.out.println(object);
HelloHome helloHome = null;
if (object != null) {
// PortableRemoteObject.narrow(object, HelloHome.class);
helloHome = (HelloHome)PortableRemoteObject.narrow(object, HelloHome.class);
Hello hello = helloHome.create();
System.out.println(hello.hello());
}
I am able to compile entire code but When i excute EJB's I get ClassCastException on PortableRemoteObject.narrow(object, HelloHome.class);
Please help.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098174#4098174
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098174
18Â years, 8Â months