tag:blogger.com,1999:blog-36521258959971640702024-03-06T03:10:00.417-06:00Sud's BlogJava, Eclipse, GlassFish, TopLink, AspectJ, Bashsudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-3652125895997164070.post-63692523582562635852009-07-24T15:09:00.002-05:002009-07-24T15:17:20.090-05:00Eclipse WTP missing in Pulse CatalogIf you use pulse to manage your local eclipse installation (if not, you should check it out) the Galileo profiles are slightly different from Ganymede. Previously you could add WTP to your profile. But now, WTP is no longer listed in the catalog and there is no way to add it to a profile. Instead, you must start with the Java EE profile (which BTW also brings in Mylyn and Data Tools). I learnt sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com100tag:blogger.com,1999:blog-3652125895997164070.post-74962966357882468202009-01-27T19:31:00.003-06:002009-01-27T19:43:41.237-06:00Bash command completionIf you cannot live without command completion in the linux shell, check this out...you can even get completion working for command arguments!! I was pretty thrilled to learn about this.See the debian documentation for details. In Ubuntu Hardy, the /etc/bash_completion that provides this functionality is missing. You can download this missing file from here. I extracted it from the source. sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com20tag:blogger.com,1999:blog-3652125895997164070.post-21449232747833600242008-10-28T15:07:00.004-05:002008-10-28T15:16:12.508-05:00One reason a Rails application breaks with no error messageI'm new to Ruby and Rails and spent about 3 hours trying to figure out why objects of my Purchase model which references my Transaction model weren't being presisted. Rails would say that the object was saved in the database but there were no records being created. Also Rails wouldn't throw any error message either.After pulling hair for 3 hours I nailed it down to my Transaction model. sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com2tag:blogger.com,1999:blog-3652125895997164070.post-8315310945532589492007-11-07T13:06:00.000-06:002007-11-07T13:15:39.844-06:00Log4j and MySQLWhen configuring log4j with an appender to log to a MySQL database there are some nuances you might need to be aware of.First, here is what the relevant settings in the log4j.properties file should look like:# Set root logger level to DEBUG and its only appender to DB.log4j.rootLogger=DEBUG, DB# The database loggerlog4j.appender.DB=org.apache.log4j.jdbc.JDBCAppenderlog4j.appender.DB.URL=jdbc:sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com638tag:blogger.com,1999:blog-3652125895997164070.post-80988267381933072132007-10-30T18:50:00.001-05:002008-03-23T15:21:16.547-05:00Hello World! REST web service using Jersey and GlassfishRecently I had the need to expose some EJB application functionality to a client PHP application. I wanted to avoid the heavy weight SOAP protocol and REST seemed like a good choice. Wanting to stay within the JAVA language for a more seamless developer experience I came across the JSR 311 spec and the implementation Jersey.If you are a JAVA programmer and are wanting to use REST in your sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com177tag:blogger.com,1999:blog-3652125895997164070.post-20419066583896077082007-10-26T09:04:00.000-05:002007-10-26T09:14:48.710-05:00Programmatic Login to Authenticate Against a EJB in GlassfishWhat?This is the method used to authenticate a standalone java client (including Eclipse RCP plugins) to the Glassfish EJB container.Referenceshttp://java.sun.com/developer/EJTechTips/2006/tt0225.html#2How?See here on how to configure Glassfish's server.policy file: https://glassfish.dev.java.net/javaee5/docs/DG/beabg.html#beacmMake sure the following jars from Glassfish are in the classpath:sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com144tag:blogger.com,1999:blog-3652125895997164070.post-51959259345029155162007-07-08T12:31:00.000-05:002007-07-08T12:34:38.699-05:00Set the Application Server > Logging > Log Levels > Deployment > Debugging to FINE to quickly troubleshoot deployment issues in Glassfishsudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com2tag:blogger.com,1999:blog-3652125895997164070.post-15349443395928470482007-03-04T16:07:00.000-06:002007-03-04T16:36:17.304-06:00Standalone EJB 3.0 client for remote EJB serverIn order for a client to connect to your remote GlassFish server you need to add a second IIOP listener with the hostname listening at a different port (ex: 3701). You can do this via the GlassFish admin console.Create a Java project in Eclipse that will be a standalone EJB 3.0 client application.When deploying the previously created EJB jar on glassfish using the admin console check the option sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com204tag:blogger.com,1999:blog-3652125895997164070.post-59501766079587528882007-03-04T15:59:00.000-06:002007-03-04T16:35:45.528-06:00EJB 3.0 + Glassfish + JPA + EclipseFollow instructions here to create the EJB project in eclipse.http://www.webagesolutions.com/knowledgebase/javakb/jkb005/index.htmlCreate the jdbc connection pool and the corresponding resource via the GlassFish admin console.Now create a persistence.xml fiel in the src/META-INF folder in your project to point to the JDBC resource.<persistence> <persistence-unit name=\"myPU\"&sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com12tag:blogger.com,1999:blog-3652125895997164070.post-69000091545744155572006-11-16T16:44:00.000-06:002006-11-16T16:56:48.434-06:00GlassFish + JNDI + LDAP + JAVASTEP 1: Create JNDI LDAP ResourceIn the GlassFish admin console create a JNDI Custom Resource with the following parameters:1. Give it a JNDI name such as myLDAP2. Resource Type: javax.naming.directory.Directory3. Factory Class: com.sun.jndi.ldap.LdapCtxFactoryAdd the following as additional parameters:1. Name: java.naming.security.principal Value: the reader dn2. Name:sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com41tag:blogger.com,1999:blog-3652125895997164070.post-90088299067458626882006-11-14T22:02:00.000-06:002006-11-14T22:13:59.504-06:00Scripting FTP in BASHThe following code snippet can be embedded in a bash script to ftp a file or script other ftp functions. It also includes error checking if the ftp of the file fails.function ftpfile { # failure or success flag # FLAG=0 # assume success # Start the actual ftp of the file RETUR=$(ftp -n <>${LOGFILE} open $SERVER user $USERNAME $PASSWORD ascii put file.txtsudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com42tag:blogger.com,1999:blog-3652125895997164070.post-48110565768192682632006-11-04T13:25:00.000-06:002006-11-04T13:27:51.821-06:00JDBC via JNDI// define sql queryString sql = "select firstname from users";// initialize database connection objectsConnection conn = null;Statement stmt = null;ResultSet rs = null;// get JNDI JDBC connectionInitialContext ctxt = new InitialContext();DataSource ds = (DataSource) ctxt.lookup("jdbc/TrackIt");conn = ds.getConnection(); // run sql objectsstmt = conn.createStatement();rs = sudhttp://www.blogger.com/profile/13628606966401327565noreply@blogger.com2