Thursday, January 10, 2013

Recovering Windows key

Have you ever wondered how much pain is it when u loose you product key. Windows 8 have 90 days free support where they can remotely access your computer and try to fix it.

Well I was trying to install .net 3.5 for running  downward compatible programs but oh my got it was just in a loop.  I cant get key because I downloaded from my Academic institute and they just wont give me access.

Well not deviating from my topic how to find product key here is how it worked for me

Belarc Advisor: http://www.belarc.com/free_download.html
(It does a good job of providing a wealth of information.)
Also: http://www.magicaljellybean.com/keyfinder.shtml
and: http://www.nirsoft.net/utils/product_cd_key_viewer.html
and RockXP: http://www.majorgeeks.com/download4138.html which has additional features

are the four utilities listed on (source: http://answers.microsoft.com/en-us/windows/forum/windows_8-windows_install/where-do-i-find-the-windows-8-product-key-when-it/d4c5c0c1-825d-47f2-9bed-d9625c7e68ff)

Belarc Advisor didnt worked for me. :(

But  http://www.magicaljellybean.com/keyfinder.shtml actually worked.

Now I am gonna try my OS registry files and see but ya best of luck. :)

Monday, January 7, 2013

Changing WAR or adding time stamp to your war name for maven supported project

Changing names for a maven project can be done in one to the two ways.

Easy fix:

The war name is same as artifact ID

    <groupId>com</groupId>
    <artifactId>ABC</artifactId>
    <version>0.0.1-SNAPSHOT    </version>
    <packaging>war</packaging>


will generate ABC.WAR in target specified folder


Other way:

So in this senario I also want to attach dynamically generated timestamp to my war

We will need to install plugin to generate time stamp as we want
 
           <build>
                <finalName>
                        ${project.artifactId}-${project.version}-${timestamp}
                </finalName>
                <plugins>
                    <plugin>
                        <groupId>
                            com.keyboardsamurais.maven
                        </groupId>
                        <artifactId>
                            maven-timestamp-plugin
                        </artifactId>
                        <version>
                            1.0
                        </version>
                        <configuration>
                            <propertyName>
                                timestamp
                            </propertyName>
                            <timestampPattern>
                                    dd.MM.yyyy HH.mm
                            </timestampPattern>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>
                                        create
                                    </goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

Should output: ABC-0.0.1-SNAPSHOT-07.01.2013 11.54.war

Wednesday, October 3, 2012

Adding database to Jboss-as-7

So I was trying to add database configuration on my Jboss 7 server. So there are two modes for operation.
  • Standalone mode
  • Domain mode
More documentation can be found here
So download Jboss server from here and navigate to JBOSS_HOME/bin
In order to connect:
JBOSS_HOME/bin$ ./standalone.sh

In order to disconnect: jboss
JBOSS_HOME/bin$ ./jboss-cli.sh --connect --command=:shutdown 
JBOSS_HOME/bin$ bin/jboss-cli.sh --connect command=:shutdown
JBOSS_HOME/bin$ bin/jboss-cli.sh --connect :shutdown

Copy your war file in JBOSS_HOME/standalone/deployments
app_name.war.isdeploying 
app_name.war.deployed
app_name.war.failed

There you go on terminal you will be able to see the logs for your current project
 Depending on your project configuration:
 INFO  [org.jboss.web] (MSC service thread 1-16) JBAS018210: Registering web context: /app_name

Web browser : http://localhost:8080/app_name
By default index.jsf,index.html will load default is configured in web.xml file

In order to connect to database

Step1: Copy jar connector in deployments folder

Step2: Make changes in Jboss_Home/standalone/configuration/standalone.xml
          <datasources>
                <datasource jndi-name="java:jboss/datasources/ExampleDS" pool-name="ExampleDS" enabled="true" use-java-context="true">
                    <connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
                    <driver>h2</driver>
                    <security>
                        <user-name>sa</user-name>
                        <password>sa</password>
                    </security>
                </datasource>
                <datasource jndi-name="java:/name in persistant unit" pool-name="SqlServerDS_Pool" enabled="true" use-java-context="true">
                    <connection-url>jdbc:sqlserver://;databasename=</connection-url>
                    <driver>The Connector Jar you copied in deployments folder/driver>
                    <security>
                        <user-name>USER</user-name>
                        <password>*****</password>
                    </security>
                </datasource>
                <drivers>
                    <driver name="h2" module="com.h2database.h2">
                        <xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
                    </driver>
                </drivers>
            </datasources>

Step 3 : Now you can reference data source from your app with JNDI lookup
Example: persistence.xml
  
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
   xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
        http://java.sun.com/xml/ns/persistence
        http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

    <persistence-unit name="primary">
      <jta-data-source>java:/name_in_standalone.xml</jta-data-source>
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.look_up for your server"/>
         <property name="hibernate.hbm2ddl.auto" value="create-drop" />
      
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.format_sql" value="true"/>
         <property name="hibernate.default_schema" value="dbo"/>
       </properties>
   </persistence-unit>
</persistence>

 In case for errors like


Caused by: java.lang.NoClassDefFoundError: Lorg/slf4j/spi/LocationAwareLogger;

Caused by: java.lang.ClassNotFoundException: org.slf4j.spi.LocationAwareLogger from [Module "org.jboss.logging:main" from local module loader @50988 (roots: /Users/tshah/Downloads/jboss-as-7.1.1.Final/modules)]

Do make changes in JBOSS_HOME\modules\org\jboss\logging\main\module.xml
Older version: 
<module xmlns="urn:jboss:module:1.1" name="org.jboss.logging">
     <resources>
 
       <resource-root path="jboss-logging-3.1.0.GA.jar"/>
     
   <!-- Insert resources here -->
    </resources>
    <dependencies>
    
    <module name="org.jboss.logmanager"/>
  
  </dependencies>

</module>
 
Newer Version:
 
<module xmlns="urn:jboss:module:1.1" name="org.jboss.logging">
    <resources>
     
   <resource-root path="jboss-logging-3.1.0.GA.jar"/>
      
      <!-- Insert resources here -->
    </resources>
      <dependencies>
       
      <module name="org.jboss.logmanager"/>
   
      <module name="org.slf4j" />
     
      <module name="org.apache.log4j" />
    
   </dependencies>

</module>