Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Server Error Caused by:
- package connectors;
- import org.hibernate.Session;
- import org.hibernate.SessionFactory;
- import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
- import org.hibernate.cfg.Configuration;
- import org.hibernate.service.ServiceRegistry;
- public class Connector {
- private static SessionFactory sessionFactory;
- private static SessionFactory buildSessionFactory() {
- try {
- // Create the SessionFactory from hibernate.cfg.xml
- Configuration configuration = new Configuration();
- configuration.configure("hibernate.cfg.xml");
- System.out.println("Hibernate Configuration loaded");
- //apply configuration property settings to StandardServiceRegistryBuilder
- StandardServiceRegistryBuilder ssrb = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties());
- System.out.println("Hibernate serviceRegistry created");
- SessionFactory sessionFactory = configuration.buildSessionFactory(ssrb.build());
- return sessionFactory;
- }
- catch (Throwable ex) {
- // Make sure you log the exception, as it might be swallowed
- System.err.println("Initial SessionFactory creation failed." + ex);
- throw new ExceptionInInitializerError(ex);
- }
- }
- public static SessionFactory getSessionFactory() {
- if(sessionFactory == null) sessionFactory = buildSessionFactory();
- return sessionFactory;
- }
- public static Session getSession(){
- return getSessionFactory().openSession();
- }
- }
- <artifactId>resqueue-mainproj</artifactId> <dependencies>
- <!-- our projects -->
- <dependency>
- <groupId>serverside</groupId>
- <artifactId>resqueue-dal</artifactId>
- <version>1.0</version>
- </dependency>
- <dependency>
- <groupId>serverside</groupId>
- <artifactId>resqueue-srdlib</artifactId>
- <version>1.0</version>
- </dependency>
- <!-- Jetty -->
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-servlet</artifactId>
- <version>7.6.0.v20120127</version>
- </dependency>
- <dependency>
- <groupId>org.eclipse.jetty</groupId>
- <artifactId>jetty-webapp</artifactId>
- <version>7.6.0.v20120127</version>
- </dependency>
- <!-- Nimbus -->
- <dependency>
- <groupId>com.nimbusds</groupId>
- <artifactId>nimbus-jose-jwt</artifactId>
- <version>2.9</version>
- </dependency>
- <!-- Jersey -->
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-server</artifactId>
- <version>1.8</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-json</artifactId>
- <version>1.8</version>
- </dependency>
- <!-- jUnit -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.10</version>
- <scope>test</scope>
- </dependency>
- <!--org.apache.http -->
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.3.2</version>
- </dependency>
- <!-- JSON LIB -> added for testing only -->
- <dependency>
- <groupId>com.google.code.gson</groupId>
- <artifactId>gson</artifactId>
- <version>2.2.4</version>
- </dependency>
- <!-- Hibernate -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.30</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-core</artifactId>
- <version>4.3.6.Final</version>
- </dependency>
- <!-- for JPA, use hibernate-entitymanager instead of hibernate-core -->
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>hibernate-entitymanager</artifactId>
- <version>4.3.6.Final</version>
- </dependency>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement