[Advanced Documentation] - Re: How to Configure Jboss4.2.2 using Https
by naturei27
Hi Peter,
I was going thru the URL:-http://wiki.jboss.org/wiki/Wiki.jsp?page=SSLSetup
and in that content they have mentioned how to setup the Jboss ..In the URL Mentioned there is a topic called "1-SSL enabled on the server-the common case" in that we are creating the server.cer and client.truststore .Please explain the use of that.In that topic there is a subtopic called as "Run the client" java -Djavax.net.ssl.trustStore=client.truststore -Djavax.net.ssl.trustStorePassword=123456 acme/ReadHttpsURL2 https://localhost:8443
I'm having the following problem in this step.....
D:\mykeystore\serverkeys>java -Djavax.net.ssl.trustStore=client.truststore -Djav
ax.net.ssl.trustStorePassword=123456 acme/ReadHttpsURL2 https://localhost:443
Exception in thread "main" java.lang.NoClassDefFoundError: acme/ReadHttpsURL2
Caused by: java.lang.ClassNotFoundException: acme.ReadHttpsURL2
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Please tell me, where can I get this class...Please do reply me .
Thanks in advance....
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165503#4165503
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165503
17 years, 9 months
[Persistence, JBoss/CMP, Hibernate, Database] - JNDI bound SessionFactory !!!
by siddharth_2279
Hi All,
1) Could anyone please tell me the steps to create a JNDI bound Session Factory. I am struggling with it for days. Please Help !!!
2) Is there a difference between JNDI bound SessionFactory and normal JNDI connection using Hibernate.
I am using the following softwares :
JBoss AS 4.2.2 GA
MySQL (database)
Hibernate 3.2
The program which I have tried is the following :
SaveExample.java
---------------------
| private static Context jndiContext;
|
| public static void main(String[] args) {
| // TODO Auto-generated method stub
|
|
| Session session = null;
|
| try{
| System.out.println("Before Session Factory Configuration. !!!");
|
| SessionFactory sf = new Configuration().configure().buildSessionFactory();
|
|
| jndiContext = new InitialContext();
|
| sf = (SessionFactory)jndiContext.lookup("java:MySqlDS");
|
|
| session = sf.openSession();
|
| System.out.println("After Session Factory Configuration. !!!");
|
|
|
| }catch(Exception e){
| e.printStackTrace();
| }finally{
| session.flush();
| session.close();
| }
|
| }
|
|
hibernate.cfg.xml
--------------------
| <hibernate-configuration>
|
| <session-factory>
|
| <property name="hibernate.connection.datasource">MySqlDS</property>
| <property name="hibernate.session_factory_name">java:Mydatabase</property>
| <property name="hibernate.jndi.url"></property>
| <property name="hibernate.jndi.class"></property>
| <property name="hibernate.connection.username"></property>
| <property name="hibernate.connection.password"></property>
|
| <property name="show_sql">true</property>
| <property name="format_sql">true</property>
|
| <!-- Show and print nice SQL on stdout. -->
| <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
| <property name="hibernate.hbm2ddl.auto">update</property>
|
| <!-- List of XML Mapping files -->
| <mapping resource="contact.hbm.xml"/>
| <!-- <mapping resource="address.hbm.xml"/> -->
|
| </session-factory>
|
| </hibernate-configuration>
|
|
I have put the lib file mysql-connector-java-5.1.5-bin.jar in the server\default\lib folder of JBoss and I have put the mysql-ds.xml file in server\default\deploy directory of JBoss.
mysql-ds.xml
---------------
|
| <datasources>
| <local-tx-datasource>
| <jndi-name>MySqlDS</jndi-name>
| <connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
| <!-- Added by me for configuting a data source for remote usage -->
| <use-java-context>false</use-java-context>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>root</user-name>
| <password>root</password>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
| <!-- should only be used on drivers after 3.22.1 with "ping" support
| <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
| -->
| <!-- sql to call when connection is created
| <new-connection-sql>some arbitrary sql</new-connection-sql>
| -->
| <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
| <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
| -->
|
| <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
|
|
Exception
-----------
|
| Before Session Factory Configuration. !!!
| log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
| log4j:WARN Please initialize the log4j system properly.
| org.hibernate.HibernateException: Could not find datasource
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
| at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
| at com.example.jndi.JNDIExample.main(JNDIExample.java:27)
| Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: [Root exception is java.lang.ClassNotFoundException: ]
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
| at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
| at javax.naming.InitialContext.init(InitialContext.java:223)
| at javax.naming.InitialContext.<init>(InitialContext.java:197)
| at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
| ... 7 more
| Caused by: java.lang.ClassNotFoundException:
| at java.lang.Class.forName0(Native Method)
| at java.lang.Class.forName(Class.java:242)
| at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
| ... 12 more
| Exception in thread "main" java.lang.NullPointerException
| at com.example.jndi.JNDIExample.main(JNDIExample.java:44)
|
|
The problem is that the program (SaveExample.java) in Eclipse is running as a standalone Java Application and Jboss server is running in another console window. So how could I make them connect to each other so that they the application program can recognize the datasource and not given Could not find datasource exception.
Do I need to write anything extra in hibernate.cfg.xml for the JNDI bound SessionFactory except
java:Mydatabase
If yes then what .
Please help as I am struggling with it for many days now. Thank in advance .
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165499#4165499
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165499
17 years, 9 months
[JNDI/Naming/Network] - Could not find datasource !!!
by siddharth_2279
Hi All.
I am stuck in a peculiar problem and struggling with it. I have a created a standalone program in Java that accesses a database through a DataSource which I have configured in JBoss AS. I am trying to access the database using JNDI.
I have a program by the name of SaveExample
| private static Context jndiContext;
|
| public static void main(String[] args) {
| // TODO Auto-generated method stub
|
|
| Session session = null;
|
| try{
| System.out.println("Before Session Factory Configuration. !!!");
|
| SessionFactory sf = new Configuration().configure().buildSessionFactory();
|
|
| jndiContext = new InitialContext();
|
| sf = (SessionFactory)jndiContext.lookup("java:MySqlDS");
|
|
| session = sf.openSession();
|
| System.out.println("After Session Factory Configuration. !!!");
|
|
|
| }catch(Exception e){
| e.printStackTrace();
| }finally{
| session.flush();
| session.close();
| }
|
| }
|
|
hibernate.cfg.xml
--------------------
| <hibernate-configuration>
|
| <session-factory>
|
| <property name="hibernate.connection.datasource">MySqlDS</property>
| <property name="hibernate.session_factory_name">java:Mydatabase</property>
| <property name="hibernate.jndi.url"></property>
| <property name="hibernate.jndi.class"></property>
| <property name="hibernate.connection.username"></property>
| <property name="hibernate.connection.password"></property>
|
| <property name="show_sql">true</property>
| <property name="format_sql">true</property>
|
| <!-- Show and print nice SQL on stdout. -->
| <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
| <property name="hibernate.hbm2ddl.auto">update</property>
|
| <!-- List of XML Mapping files -->
| <mapping resource="contact.hbm.xml"/>
| <!-- <mapping resource="address.hbm.xml"/> -->
|
| </session-factory>
|
| </hibernate-configuration>
|
|
I have put the lib file mysql-connector-java-5.1.5-bin.jar in the server\default\lib folder of JBoss and I have put the mysql-ds.xml file in server\default\deploy directory of JBoss.
mysql-ds.xml
---------------
|
| <datasources>
| <local-tx-datasource>
| <jndi-name>MySqlDS</jndi-name>
| <connection-url>jdbc:mysql://localhost:3306/jbossdb</connection-url>
| <!-- Added by me for configuting a data source for remote usage -->
| <use-java-context>false</use-java-context>
| <driver-class>com.mysql.jdbc.Driver</driver-class>
| <user-name>root</user-name>
| <password>root</password>
| <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
| <!-- should only be used on drivers after 3.22.1 with "ping" support
| <valid-connection-checker-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker</valid-connection-checker-class-name>
| -->
| <!-- sql to call when connection is created
| <new-connection-sql>some arbitrary sql</new-connection-sql>
| -->
| <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers
| <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
| -->
|
| <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml -->
| <metadata>
| <type-mapping>mySQL</type-mapping>
| </metadata>
| </local-tx-datasource>
| </datasources>
|
|
|
Exception
-----------
|
| Before Session Factory Configuration. !!!
| log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
| log4j:WARN Please initialize the log4j system properly.
| org.hibernate.HibernateException: Could not find datasource
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:56)
| at org.hibernate.cfg.SettingsFactory.createConnectionProvider(SettingsFactory.java:414)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
| at com.example.jndi.JNDIExample.main(JNDIExample.java:27)
| Caused by: javax.naming.NoInitialContextException: Cannot instantiate class: [Root exception is java.lang.ClassNotFoundException: ]
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
| at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
| at javax.naming.InitialContext.init(InitialContext.java:223)
| at javax.naming.InitialContext.<init>(InitialContext.java:197)
| at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
| ... 7 more
| Caused by: java.lang.ClassNotFoundException:
| at java.lang.Class.forName0(Native Method)
| at java.lang.Class.forName(Class.java:242)
| at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:42)
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
| ... 12 more
| Exception in thread "main" java.lang.NullPointerException
| at com.example.jndi.JNDIExample.main(JNDIExample.java:44)
|
|
My problem is that the program (SaveExample.java) in Eclipse is running as a Java Application and Jboss server is running in another console window. So how could I make them connect to each other so that they the application program can recognize the datasource and not given Could not find datasource exception.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165498#4165498
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165498
17 years, 9 months
Automatically rejected mail
by Mail Delivery Subsystem
Your message was automatically rejected by Dovecot Mail Delivery Agent.
The following reason was given:
Quota exceeded
17 years, 9 months