//
archives

Cloud

This category contains 6 posts

Private Cloud Foundry Hello World

Cloud Found (https://www.cloudfoundry.org/) is a VMWare PAAS that has been released as open source and can be installed privately on your infrastructure. Once you have your cloud installed you can start to develop with Eclipse and publish your application in the new Private Cloud. Here are the steps to follow.

  • Add to your file host the dns name of your server.
    192.168.9.23 javatest01.cloudbox.net.intre.it
    192.168.9.23 drawbridge.cloudbox.net.intre.it
    192.168.9.23 api.cloudbox.net.intre.it
    192.168.9.23 cloudbox.net.intre.it
  • Download Eclipse STS - http://www.springsource.com/developer/sts
  • Install Cloud Foundry plugin
  • Connect to api.cloudbox.net.intre.it (change with your server name) using your account information (to add an user use mvc – https://github.com/cloudfoundry/vmc)

    Tasto destro->New->Server

    Next

    Add server  api.cloudbox.net.intre.it clicking on su Manage Cloud e clicking Add.
  • Create a new Eclipse Dynamic Web Project



    Right click on the Project -> Spring Tools -> Add Spring Project Nature
  • Add the project to Cloud Foundry double click on Cloud Server in Tab Server.




  • Add an html file for test in Web Content

  • Browse the application
If do you need details how to install Cloud Foundry on your private infrastructure please left a comment that I’ll publish a post about it :-)

Hibernate and JPA error: duplicate import, try using auto-import=”false”

Using Hibernate and JPA you cannot have two classes with the same name (on different packages) mapped. This raise an error at runtime:
Caused by: org.hibernate.DuplicateMappingException: duplicate import: MyClass refers to both com.intre.MyClass and com.dummy.MyClass (try using auto-import=”false”)

To solve this issue on the Entity annotation  of com.intre.MyClass and com.dummy.Class add the property name.

package com.intre;
@Entity(name = “com.intre.myclass”)
@Table(name = “MyClass”)
public class MyClass …

package com.dummy;
@Entity(name = “com.dummy.myclass”)
@Table(name = “MyClass”)
public class MyClass …

Eclipse BIRT and JavaScript in reports

With Firefox 5, Firefox 6, Chrome 13, Chrome 14 and Chrome 15 all JavaScript embedded in a Eclipse BIRT report don’t work anymore. Nothing is executed :-(

After some googling I find out that the problem is really new and reported in the BIRT issue tracker: https://bugs.eclipse.org/bugs/show_bug.cgi?id=351217.

After half a day of struggling in BIRT viewer code I found the problem!

The file webcontent/birt/ajax/ui/report/AbstractReportComponent.js contains the code

 //  Internet Explorer has a funky execScript method that makes this easy
 if ( window.execScript )
     window.execScript( scripts[i].innerHTML );

this is not executed by new browsers and therefore all javascript is ignored. I’ve changed this block of code with

//  Internet Explorer has a funky execScript method that makes this easy
if ( window.execScript ){
    window.execScript( scripts[i].innerHTML );
}else {
    with (window) {
        window.eval(scripts[i].innerHTML);
    }
 }

and now it works again!

CAS and Active Directory – LDAP Attributes

CASCAS is an Open Source  Single Sign On Server - http://www.jasig.org/cas. Iit can be integrated with both AD and LDAP. The task is easy if you know Spring and Tomcat - https://wiki.jasig.org/display/CASUM/LDAPhttps://wiki.jasig.org/display/CASUM/SAML+1.1.

The problem is to get the AD/LDAP attributes with CAS Client. Following the documents above you are able to login against CAS but not to visualize in your application the mapped attributes.

Just a note in authenticationManager – deployerConfigContext.xml - change the credentianToPrincipalResolvers

 <property name="credentialsToPrincipalResolvers">
                        <list>

                        <bean class="org.jasig.cas.authentication.principal.CredentialsToLDAPAttributePrincipalResolver">
                                <property name="credentialsToPrincipalResolver">
                                        <bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver"/>
                                </property>
                                <property name="filter" value="(sAMAccountName=%u)"/>
                                <property name="principalAttributeName" value="sAMAccountName"/>
                                <property name="searchBase" value="cn=Users,dc=pssupport"/>
                                <property name="contextSource" ref="contextSource"/>
                                <property name="attributeRepository">
                                        <ref bean="attributeRepository"/>
                                </property>
                        </bean>
                </list>
   </property>

This because CAS need to be configured in order to expose attributes. You have two ways to to that:

Using CAS services console (https://localhost:8433/cas/services). If this is not enable add the user to ROLE_ADMIN in deployerConfigContext.xml and configure CAS properties - https://wiki.jasig.org/display/CASUM/Configuring. Once you are in you can configure the attributes to visualize.

 

Setup the org.jasig.cas.services.InMemoryServiceRegistryDaoImpl to expose by default the attributes. To do so edit the deployerConfigContext.xml, locate the deployerConfigContext.xml and add to HTTP and HTTPS registeredServices the allowedAttributes property as in this example

<bean class="org.jasig.cas.services.RegisteredServiceImpl">
                        <property name="id" value="0" />
                        <property name="name" value="HTTP" />
                        <property name="description" value="Only Allows HTTP Urls" />
                        <property name="serviceId" value="http://**" />
                        <property name="allowedAttributes">
                  <list>
                        <value>cn</value>
                        <value>name</value>
                        <value>givenName</value>
                        <value>displayName</value>
                        <value>userPrincipalName</value>
                        <value>sAMAAccountName</value>
                        <value>telephone</value>
                        <value>mail</value>
                        <value>memberOf</value>
                  </list>
                </property>

restart CAS, login with your client and you should see now the attributes.


Looking for JavaScript IDE, try on the cloud!

In the last ten days two new development-as-a-service platforms are available on the Cloud. No more operating system to update and programs to install, just point to a web site and you can start programming and debugging JavaScript!

The idea is really interesting and appealing. I hope that in the future we can see also Visual Studio (C#) and Eclipse (Java, C++, PHP) in the Cloud.

If you want to try some of them go to:

and let me know your comments!

Have fun!

Python Web Server with Tornado

Tornado is an Open Source Web Server for Python really interesting. It powers the FriendFeed and it is listed in the Facebook Open Source Technology page for Infrastructure.

I tried quickly on my Ubuntu 10.10 Laptop and it is really simple to install and test.

Just open a terminal and type:

  • sudo apt-get install python-pycurl
  • sudo apt-get install pip
  • sudo pip install tornado
  • vi hello.py and write an hello world web application like this
  • import tornado.ioloop
    import tornado.web

    class MainHandler(tornado.web.RequestHandler):
    def get(self):
    self.write("Hello, world")

    application = tornado.web.Application([
    (r"/", MainHandler),
    ])

    if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.instance().start()

  • python hello.py
  • open the browser and go to http://localhost:8888

Thats it!

Twitter Updates

Follow

Get every new post delivered to your Inbox.

Join 67 other followers