Sunday, July 22, 2012

Add Clean script to MsBuild

Add the following Target to the Project.csproj file :

    <Target Name = "Clean">
<RemoveDir Directories="$(builtdir)" />
</Target>


We will have to declare what is builtdir (which will be pointing to something like bin) and for this we will have to add 


<builtdir>BuiltApp</builtdir>


and to create a new directory during build process


<MakeDir Directories = "$(builtdir)" Condition = "!Exists('$(builtdir)')" />



Now to clean use the following



msbuild <file name>.proj /target:Clean



and to build use



msbuild <file name>.proj /target:Build

Saturday, July 21, 2012

.NET 4.0 build server reference assemblies warnings MSB3644

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(847,9): warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [D:\ProjectName\Project.csproj]


If you get errors like above especially on Hudson build server it means you are missing Framework v 4.0 reference assemblies normally located in the folder C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0

Find a full version of the reference assemblies directory and copy them from the development machine to the directory \Program Files\Reference Assemblies\Microsoft\Framework\v4.0 and use override command to build the project:-
msbuild -p:FrameworkPathOverride="C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" Project.sln

Friday, July 20, 2012

JunkCard.com review

Be careful when buying card from secondary sites like JunkCard. I had a bad experience and then I researched a bit more into this.

These websites sell electronic gift cards which are not actually gift cards but ecodes. It seems the website is run by some folks in the west coast. Similarly facebook updates will be posted during west coast hours.

If you go through the reviews online most of the reviews will be 5/5 and very similar in the nature. Notice the punctuation and capitalization which is similar to the capitalization used by their customer care. Most of the reviews will be written by accounts that were open during the same time period and only have 1 review

 

image

image

image

TOPOST: Customer care emails

Tuesday, July 17, 2012

Oracle SID error


If you get Oracle TNS listener like error below its probably due to incorrect configuration of the connect string in your application:-


INFO : org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3ddfd90f: defining beans [dataSource,org.springframework.jdbc.datasource.init.DataSourceInitializer#0]; root of factory hierarchy
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.jdbc.datasource.init.DataSourceInitializer#0': Invocation of init method failed; nested exception is org.springframework.dao.DataAccessResourceFailureException: Failed to execute database script; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
)

    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:377)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:278)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4701)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5204)
    at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5199)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: org.springframework.dao.DataAccessResourceFailureException: Failed to execute database script; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
)
    at org.springframework.jdbc.datasource.init.DataSourceInitializer.execute(DataSourceInitializer.java:115)
    at org.springframework.jdbc.datasource.init.DataSourceInitializer.afterPropertiesSet(DataSourceInitializer.java:86)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1479)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
    ... 20 more
Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
)
    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1549)
    at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1388)
    at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
    at org.springframework.jdbc.datasource.init.DataSourceInitializer.execute(DataSourceInitializer.java:104)
    ... 23 more
Caused by: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
 
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:419)
    at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
    at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
    at org.apache.commons.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:38)
    at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:582)
    at org.apache.commons.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:1556)
    at org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory(BasicDataSource.java:1545)
    ... 26 more
Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
 
    at oracle.net.ns.NSProtocol.connect(NSProtocol.java:386)
    at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1054)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:308)
    ... 34 more
Jan 26, 2012 7:48:41 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
Jan 26, 2012 7:48:42 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/appname] startup failed due to previous errors
Jan 26, 2012 7:48:42 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/appname] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Solution
Make sure that you look into tnsnames.ora file and listener.ora file:-
My tnsnames.ora looks like
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xe)
)
)

listener.ora looks this
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
Compare these settings to your jdbc url configuration in your web application and it will most likely give you a clue if the string is wrong:-
jdbc:oracle:thin:@aHost:1521:theSID

Sunday, July 01, 2012