Friday, December 18, 2015

MySQL - Can't init tc log

/usr/sbin/mysqld: File '' not found (Errcode: 2)
151217 20:21:27 [ERROR] Failed to open log (file '', errno 2)
151217 20:21:27 [ERROR] Could not open log file
151217 20:21:27 [ERROR] Can't init tc log

151217 20:21:27 [ERROR] Aborting

Solution:

mysql-bin.index had become corrupted
edit this file to include all indexes did the fix

server was able to restart after that

Tuesday, July 14, 2015

Apache with Oracle Build - partial

PREFIX=/root/apache/build
##cd /usr/src
#wget http://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gz
#tar xvf pcre-8.37.tar.gz
#cd pcre-8.37
#/usr/local/pcre
#./configure --disable-cpp --prefix=/root/apache/pcre
#make
#make install
#wget http://www.apache.org/dist/httpd/httpd-2.4.12.tar.gz
#tar xvf httpd-2.4.12.tar.gz
#cd /usr/src
#wget http://www.apache.org/dist/apr/apr-1.5.2.tar.gz
#wget http://www.apache.org/dist/apr/apr-util-1.5.4.tar.gz
#tar xvf apr-1.5.2.tar.gz
#tar xvf apr-util-1.5.4.tar.gz
#cd apr-1.5.2
#./configure --prefix=$PREFIX
#make
#make install
#cd ..
#cd apr-util-1.5.4
#./configure --with-apr=/usr/src/apr-1.5.2 --with-oracle=/opt/oracle/instantclient_11_2 --with-oracle-include=/opt/oracle/instantclient_11_2/sdk/include --prefix=$PREFIX
#make
#make install
#mv apr-1.5.2 httpd-2.4.12/srclib/apr
#mv apr-util-1.5.4 httpd-2.4.12/srclib/apr-util

cd httpd-2.4.12
##./configure --enable-so --enable-ssl --with-mpm=prefork --with-included-apr=  --with-included-apr-util
#./configure --enable-so --with-apr=/usr/src/apr-1.5.2 --with-pcre=/root/apache/pcre --prefix=$PREFIX
make
#make install




# Basic Auth Working
<Directory /var/www/html/agency1>
        AuthType Basic
        AuthName "http.conf agency1"
        # (Following line optional)
        AuthBasicProvider file
        AuthUserFile /etc/httpd/conf/security/passwords
        AuthGroupFile /etc/httpd/conf/security/groups
        # Require user fox
        Require group agency1
</Directory>
# Digest Auth now working key is AuthName must match realm
<Location /agency2>
        #AllowOverride AuthConfig
        AuthType Digest
        AuthName "agency2"
        AuthDigestDomain /agency2/
        #AuthDigestProvider file
        AuthUserFile /etc/httpd/conf/security/digest
        Require user user2
</Location>




<IfModule mod_dbd.c>
# mod_dbd configuration
DBDriver oracle

DBDParams "user=user pass=password dbname=XE server=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=XE)))"
DBDPersist off
 # You should test with Persist off then change to on if it works.
DBDMin  4
DBDKeep 8
DBDMax  20
DBDExptime 300
</IfModule>
<Directory /var/www/html/private>
  # core authentication and mod_auth_basic configuration
  # for mod_authn_dbd
  AuthType Basic
  AuthName "My Server"
  AuthBasicProvider dbd
  # core authorization configuration
  Require valid-user
  # mod_authn_dbd SQL query to authenticate a user
  AuthDBDUserPWQuery \
    "SELECT password FROM authn WHERE userid = %s"
</Directory>

Saturday, March 21, 2015

JPA Facet Eclipse Oracle


Good link for easy doc

http://www.javabeat.net/eclipselink-jpa-installation-configuration/

<repositories>
<repository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>codelds</id>
<url>https://code.lds.org/nexus/content/groups/main-repo</url>
</repository>
</repositories>


<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>

Friday, January 23, 2015

openshift tomcat7 realm

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

<web-app>

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Entire Application</web-resource-name>
            <url-pattern>/protected/*</url-pattern>
        <!-- If you list http methods, only those methods are protected -->
<http-method>DELETE</http-method>
         <http-method>GET</http-method>
         <http-method>POST</http-method>
<http-method>PUT</http-method>
      </web-resource-collection>
      <auth-constraint>
         <!-- Anyone with one of the listed roles may access this area -->
<role-name>ROLENAME</role-name>
         <role-name>Administrator</role-name>
         <role-name>Power User</role-name>
         <role-name>User</role-name>
         <role-name>View Only</role-name>
      </auth-constraint>
    </security-constraint>

    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>My Password-Protected Web Application</realm-name>
        <login-config>
            <form-login-page>/loginForm.jsp</form-login-page>
            <form-error-page>/loginError.jsp</form-error-page>
        </login-config>
    </login-config>


<error-page>
  <exception-type>javax.servlet.ServletException</exception-type>
  <location>/error.htm</location>
</error-page>
<error-page>
  <error-code>500</error-code>
  <location>/test.jsp</location>
</error-page>


</web-app>



<Realm className="org.apache.catalina.realm.JDBCRealm"
        connectionURL="jdbc:mysql://localhost/stealth6_stealthtrader?user=stealth6&amp;password=gbury26"
        driverName="com.mysql.jdbc.Driver"
        roleNameCol="role_name"
        userCredCol="user_pass"
        userNameCol="user_name"
        userRoleTable="user_roles"
        userTable="users"/>


Thursday, January 15, 2015

Simple Eclipse Maven Hibernate Setup

create a JPA project using

pom.xml

<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>[4.2.6,4.2.9]</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.1-GA</version>
</dependency>
</dependencies>


src/hibernatecfg.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
                                         "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
 <session-factory>
  <!--  Database connection settings  -->
  <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
  <property name="connection.url">jdbc:oracle:thin:@localhost:1521:xe</property>
  <property name="connection.username">csfox</property>
  <property name="connection.password">password</property>
  <property name="dialect">org.hibernate.dialect.OracleDialect</property>
  <!--  Echo all executed SQL to stdout  -->
  <property name="show_sql">true</property>
  <!--  Drop and re-create the database schema on startup  -->
  <property name="hbm2ddl.auto">create-drop</property>
  <mapping class="hibernate.Message"/>
 </session-factory>
</hibernate-configuration>

sample java table

@Entity
public class MyTable {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    Long id;
    @Column(nullable = false)
    String value;

run java 
        Configuration configuration = new Configuration();
        configuration.configure();
        ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder();
        serviceRegistryBuilder.applySettings(configuration.getProperties());
        ServiceRegistry serviceRegistry = serviceRegistryBuilder.buildServiceRegistry();
        SessionFactory factory = configuration.buildSessionFactory(serviceRegistry);
Session session = factory.openSession();
        Transaction tx = session.beginTransaction();
        session.persist(object);
        tx.commit();
 List<MyTable > list = (List<MyTable>) session.createQuery(
            "from MyTable").list();
        session.close();


Tuesday, January 13, 2015

Simple Quick Struts2 Eclipse Project Setup

quick notes for simple eclipse struts2 project


new project ->other ->maven ->maven-archetype-webapp

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

add facet runtime server

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-core</artifactId>
<version>2.3.20</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-convention-plugin</artifactId>
<version>2.3.20</version>

</dependency>

<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-tiles3-plugin</artifactId>
<version>2.3.15.1</version>
</dependency>


web.xml

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>
<filter>
<filter-name>StrutsPrepareAndExecuteFilter</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>StrutsPrepareAndExecuteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

struts.xml

<struts>
<constant name="struts.devMode" value="true" />
<package name="default" extends="struts-default" namespace="/">
<action name="index">
<result>/index.jsp</result>
</action>
</package>
</struts>

forward

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:property value="name" />