[JBoss Portal Users] - hibernate database connection
by Fuchs
hello,
iam using jboss portal 2.7.2 bundle.
i like to use my own mysql database with hibernate functionality which is called from some portlets.
But i get this error:
19:48:07,463 ERROR [*Home] Could not locate SessionFactory in JNDI
javax.naming.NameNotFoundException: SessionFactory not bound
i made a java utility project:
MyProject
-package.tables (*.Home.class/*.class/*.hbm.xml)
-META-INF (hibernate-service.xml)
-hibernate.cfg.xml
hibernate.cfg.xml:
<hibernate-configuration>
| <session-factory>
| <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
| <property name="hibernate.connection.datasource">java:jdbc/CustomerDB</property>
| <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
| <property name="current_session_context_class">thread</property>
| <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
|
| <mapping resource="package/tables/*Home.hbm.xml" />
| <mapping resource="package/tables/*.hbm.xml" />
|
| </session-factory>
| </hibernate-configuration>
hibernate-ds.xml
<datasources>
| <local-tx-datasource>
| <jndi-name>jdbc/CustomerDB</jndi-name>
| <connection-url>jdbc:mysql://mysqlserver/mydataschema</connection-url>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>****</user-name>
| <password>****</password>
| <min-pool-size>5</min-pool-size>
| <max-pool-size>20</max-pool-size>
| </local-tx-datasource>
| </datasources>
hibernate-service.xml
<server>
| <mbean code="org.jboss.portal.jems.hibernate.SessionFactoryBinder" name="jboss.har:service=Hibernate">
| <attribute name="DatasourceName">java:/CustomerDB</attribute>
| <attribute name="Dialect">org.hibernate.dialect.MySQLDialect</attribute>
| <attribute name="SessionFactoryName">java:/hibernate/SessionFactory</attribute>
| <attribute name="CacheProviderClass">org.hibernate.cache.NoCacheProvider</attribute>
| </mbean>
| </server>
The code which looks up for the jndi:
| private final SessionFactory sessionFactory = getSessionFactory();
|
| protected SessionFactory getSessionFactory() {
| try {
| return (SessionFactory) new InitialContext()
| .lookup("java:/hibernate/SessionFactory");
| } catch (Exception e) {
| log.error("Could not locate SessionFactory in JNDI", e);
| throw new IllegalStateException(
| "Could not locate SessionFactory in JNDI");
| }
| }
|
I read a lot of post, but never found a solution.
Can i get some help, please?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4264187#4264187
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4264187
16 years, 5 months
[Security] - Cannot use custom CallbackHandler with LoginContext
by mwx.dennis
I'm connecting to a JBoss 5.1.0.GA from a standalone client. I use a custom LoginModule. This is my client side security config:
admin-securitydomain {
| org.jboss.security.ClientLoginModule required;
| };
|
This is my client side login code:
| URL authenticationConfigURL = getClass().getResource(AUTH_PROP_CONFIG_FILENAME);
| System.setProperty(AUTH_PROP_KEY, authenticationConfigURL.toExternalForm());
| LoginCallbackHandler callbackHandler = new LoginCallbackHandler(username, password, Role.ADMINISTRATOR, Market.de);
| LoginContext loginContext = new LoginContext(SECURITY_DOMAIN, callbackHandler);
| loginContext.login();
|
I'd like to use my own CallbackHandler but it doesn't work as expected - the CallbackHandler that is passed into the LoginModule is of type javax.security.auth.login.LoginContext$SecureCallbackHandler.
As a consequence, when I try to login, I get a
javax.security.auth.callback.UnsupportedCallbackException: Unrecognized Callback
| at org.jboss.security.auth.callback.JBossCallbackHandler.handle(JBossCallbackHandler.java:126)
| at javax.security.auth.login.LoginContext$SecureCallbackHandler$1.run(LoginContext.java:955)
| ...
|
Any ideas how I can fix this?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4264173#4264173
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4264173
16 years, 5 months