Recent Posts
Archives

Posts Tagged ‘JavaEE’

PostHeaderIcon [DevoxxBE2013] OpenShift Primer: Get Your Applications into the Cloud

Eric D. Schabell, JBoss technology evangelist at Red Hat, demystifies OpenShift, a PaaS revolutionizing cloud deployment for Java EE, PHP, Ruby, and beyond. Author of the OpenShift Primer e-book, Eric—drawing from his integration and BPM expertise—guides attendees through rapid app migration, showcasing portability without code rewrites. His action-packed session deploys a Java project in minutes, contrasting OpenShift’s ease with cumbersome VMs.

OpenShift’s open-source ethos, Eric argues, delivers developer freedom: Git-based workflows, auto-scaling gears, and cartridge-based runtimes. From free tiers to enterprise scalability, it transforms cloud adoption, with European data centers addressing latency and privacy concerns.

Demystifying PaaS and OpenShift Fundamentals

Eric contrasts IaaS’s VM drudgery with PaaS’s streamlined abstraction. OpenShift, atop Red Hat Enterprise Linux, provisions environments via cartridges—pre-configured stacks for languages like Java.

He demos creating an app: rhc app create, Git push, and instant deployment, emphasizing no vendor lock-in.

Rapid Deployment and Portability

Portability reigns: Eric deploys a legacy Java EE app unchanged, leveraging JBoss EAP cartridges. PHP/Ruby examples follow, highlighting multi-language support.

This agnosticism, Eric notes, preserves investments, scaling from localhost to cloud seamlessly.

Scaling, Monitoring, and Security

Auto-scaling gears adjust to loads, Eric illustrates, with hot-deploy for zero-downtime updates. Monitoring via console tracks metrics; security integrates LDAP and SSL.

For Europe, Irish data centers mitigate latency, with GDPR-compliant options addressing data sovereignty.

Why OpenShift? Open-Source Advantages

Eric’s pitch: unmatched ease, no code changes, and open-source values. Free tiers on AWS East Coast suit demos, with paid plans offering local regions like Ireland.

He invites booth chats, contrasting OpenShift’s speed with competitors’ rigidity.

Links:

PostHeaderIcon [DevoxxBE2012] Real World Java EE

Adam Bien, a renowned Java consultant, author, and Java Champion with decades of experience in enterprise applications, delivered an impromptu yet insightful session on practical Java EE usage. Adam, known for books like “Real World Java EE Patterns,” shared real-world insights from his freelance projects, emphasizing simplicity and effectiveness over hype.

He started by recounting his journey since 1995, favoring Java EE for its robustness in production. Adam advocated thin WAR deployments, bundling everything into a single archive for easy management, contrasting with complex EAR structures.

Discussing boundaries, Adam promoted domain-driven design, where entities form the core, with services as facades. He cautioned against unnecessary abstractions, like excessive DAOs, favoring direct JPA usage.

Adam highlighted CDI’s power for dependency injection, reducing boilerplate. He demonstrated boundary-control-entity patterns, where boundaries handle transactions, controls manage logic, and entities persist data.

Deployment Strategies and Simplicity

Adam stressed deploying as WARs to containers like GlassFish, avoiding heavy setups. He shared experiences with microservices avant la lettre, using REST for inter-service communication.

He critiqued over-engineering, like misusing ESBs for simple integrations, preferring lightweight approaches.

Testing and Quality Assurance

Adam advocated comprehensive testing: unit with JUnit, integration with Arquillian, and UI with Selenium/Graphene. He demonstrated embedding containers for realistic tests.

He emphasized boundary testing, simulating real scenarios without mocks where possible.

Performance and Scalability

Discussing optimization, Adam noted Java EE’s built-in clustering, but advised measuring first. He shared cases where simple configurations sufficed, avoiding premature scaling.

Community and Best Practices

Adam encouraged open-source contributions, sharing his GitHub projects. He addressed common pitfalls, like session misuse, advocating stateless designs.

In Q&A, he discussed tools like Jenkins for CI and IDEs like IntelliJ.

Adam’s talk reinforced Java EE’s viability for real-world applications through pragmatic, lean practices.

Links:

PostHeaderIcon [DevoxxFR2013] JCP & Adopt a JSR Workshop

Lecturer

Patrick Curran chairs the Java Community Process (JCP), overseeing membership, processes, and Executive Committee. With over 20 years in software, including 15 at Sun, he led Java Conformance Engineering and chaired related councils. Active in W3C and OASIS.

Arun Gupta directs Developer Advocacy at Red Hat, focusing on JBoss Middleware. A Java EE founding member at Sun, he drove global adoption; at Oracle, he launched Java EE 7.

Mike Seghers, an IT consultant since 2001, specializes in Java enterprise web apps using frameworks like Spring, JSF. Experienced in RIA and iOS, he engages developer communities.

Abstract

Patrick Curran, Arun Gupta, and Mike Seghers’s workshop guides joining the Java Community Process (JCP) and participating in Adopt-a-JSR. They explain membership, transparency, and tools for JUG involvement like hackathons. Focusing on Java EE 8, the session analyzes collaboration benefits, demonstrating practical contributions for standard evolution.

Understanding JCP: Membership and Participation Pathways

Curran outlines JCP membership: free for individuals via jcp.org, requiring agreements; paid for corporations/non-profits ($2,000-$5,000). Java User Groups join as associates, nominating representatives.

Adopt-a-JSR encourages JUGs to engage JSRs: review specs, test implementations, provide feedback. This democratizes development, ensuring community input.

Gupta details Java EE 8 focus: HTML5, cloud, modularity. Adopt-a-JSR aids via mailing lists, issue trackers, wikis.

Practical Engagement: Tools and Initiatives for Collaboration

Tools include mailing lists for discussions, JIRA for bugs, GitHub for code. JUGs organize hack days, building samples.

Seghers demos Belgian JUG’s app: uses JSF, EJB, JPA for urban travelers game. Source on GitHub, integrates WebSockets.

This hands-on approach educates, uncovers issues early.

Case Studies: Global Adopt-a-JSR Impact

Examples: London JUG’s multiple JSR contributions; SouJava’s CDI focus; Morocco JUG’s hackathons. Chennai JUG built apps; Egypt JUG presented at conferences.

These illustrate visibility, skill-building, influence on standards.

Broader Implications: Enhancing Transparency and Community

JCP 2.8 mandates open Expert Groups, encouraging participation. Adopt-a-JSR amplifies this, benefiting platforms via diverse input.

Curran urges minimal commitments: feedback, testing. Gupta highlights launch opportunities.

Workshop fosters collaborative ecosystem, strengthening Java’s future.

Links:

PostHeaderIcon [DevoxxBE2012] Why & How: JSON Validation with JSON Schema and Jackson

Stephane Rondal, co-founder of Arexo Consulting and a Java EE expert, introduced JSON Schema validation using Jackson. Stephane, with decades in software architecture, explained JSON’s ubiquity in web 2.0, mobile, and RESTful services, yet noted lacking structural validation compared to XML.

He advocated JSON Schema for defining constraints like types, formats, and cardinalities, ensuring data integrity. Benefits include self-documenting APIs, early error detection, and improved interoperability.

Drawbacks: added complexity, performance overhead, and evolving standards (draft 3 then, now higher).

Stephane demonstrated schema creation for documents with headers and items, specifying required fields and enums.

Using Jackson’s JsonSchema module, he validated instances, catching issues like type mismatches.

Implementing Validation in Practice

Stephane integrated validation post-parsing, using ObjectMapper and JsonNode for tree traversal. Tests showed valid/invalid responses, with errors reported clearly.

He recommended the Jackson-based validator for its maintenance and spec adherence.

Links:

PostHeaderIcon [DevoxxFR2013] Arquillian for Simple and Effective Web Tests

Lecturer

Alexis Hassler is a Java developer with over fifteen years of experience. He operates as an independent professional, engaging in coding, training, and supporting enterprises to enhance their Java development and deployment practices. As co-leader of the Lyon Java User Group, he contributes to community events like the Mix-IT conference in Lyon.

Abstract

Alexis Hassler’s session explores Arquillian’s capabilities for testing web applications, extending beyond Java EE components to comprehensive integration testing. Demonstrating extensions like Drone, Graphene, and Warp, he illustrates client-side and server-side testing methodologies. The discussion analyzes setup, execution, and benefits, emphasizing real-world testing that verifies both client interactions and server states for robust applications.

Core Concepts of Arquillian: Integration Testing Reversed

Hassler introduces Arquillian as a tool for integration testing Java EE components, defining a component as an entity like an EJB with injected dependencies, transactional, and security contexts. Unlike embedding containers in tests, Arquillian packages the component with tests and deploys to a container, inverting the process for realistic environments.

A basic test class uses JUnit with an Arquillian runner. The @Deployment annotation creates a testable archive (e.g., WAR) containing classes and resources. Methods like @Test execute within the container, accessing injected resources seamlessly.

This approach ensures tests run in production-like settings, catching issues early. Hassler contrasts with traditional unit tests, highlighting Arquillian’s focus on integrated behaviors.

Extending to Web Testing: Drone and Graphene for Client-Side Interactions

For web applications, Hassler leverages Drone and Graphene extensions, combining Arquillian’s deployment with Selenium’s browser automation. Drone instantiates WebDriver instances; Graphene enhances with guards for AJAX handling.

In setup, specify a managed container like JBoss AS in arquillian.xml. Tests deploy the app, then use @Drone-annotated browsers to interact: navigate via @ArquillianResource URLs, fill forms, assert outcomes.

Graphene’s guards wait for requests, ensuring reliable tests amid asynchronous behaviors. This client-mode testing (@RunAsClient) simulates user interactions, verifying HTTP responses without server-side access.

Code example:

@Drone
WebDriver browser;

@ArquillianResource
URL deploymentUrl;

@Test
@RunAsClient
public void testLogin() {
    browser.get(deploymentUrl + "login.jsf");
    // Interact and assert
}

This deploys, browses, and validates, bridging unit and functional testing.

Advanced Verification with Warp: Bridging Client and Server States

To inspect server-side states during client tests, Hassler introduces Warp. It wraps requests with payloads, executing inspections on the server before/after phases.

Define inspections extending WarpInspection, annotating with @WarpTest. Use @BeforeServlet/@AfterServlet for timing. Deploy via @WarpDeployment.

Example: Verify session attributes post-login. Client triggers action; Warp asserts server-side.

public class SessionInspection extends WarpInspection {
    @AfterServlet
    public void checkSession() {
        // Assert session values
    }
}

Warp enables “real tests” by combining client simulations with server validations, detecting mismatches invisible to pure client tests.

Hassler notes Warp’s alpha status, advising community forums for issues.

Implications for Development Practices: Flexibility and Community Support

Arquillian’s modularity allows mixing modes: @RunAsClient for web, in-container for components. This flexibility suits diverse apps, from simple servlets to complex JSF.

Challenges include initial setup—choosing extensions, versions, resolving conflicts. Documentation is evolving; forums on JBoss.org are responsive, often from developers.

Hassler encourages adoption for effective testing, reducing deployment surprises. Community involvement accelerates learning, fostering better practices.

In essence, Arquillian with extensions empowers thorough, efficient web testing, aligning development with production realities.

Links:

PostHeaderIcon [DevoxxBE2012] Weld-OSGi in Action

Mathieu Ancelin and Matthieu Clochard, software engineers at SERLI specializing in Java EE and modular systems, showcased the synergy between CDI, OSGi, and Weld in their Weld-OSGi framework during DevoxxBE2012. Mathieu, a member of the CDI 1.1 expert group and contributor to projects like GlassFish, collaborated with Matthieu, who focuses on OSGi integrations, to demonstrate how Weld-OSGi simplifies dynamic application assembly without added complexity.

They started with CDI basics, where dependency injection manages component lifecycles via annotations like @Inject. OSGi’s modularity, with bundles as deployment units and a dynamic service registry, complements this by allowing runtime changes. Weld-OSGi bridges them, enabling CDI beans to interact seamlessly with OSGi services.

A demo illustrated bootstrapping Weld-OSGi in an OSGi environment, registering bundles, and using extensions for event handling. They emphasized transparent service interactions, where CDI observes OSGi events for dynamic updates.

Mathieu and Matthieu highlighted Weld-OSGi’s role in making OSGi accessible, countering perceptions of its difficulty by leveraging CDI’s programming model.

Fundamentals of CDI and OSGi Integration

Mathieu explained CDI’s bean management, scopes, and qualifiers for precise injections. Matthieu detailed OSGi’s bundle lifecycle and service registry, where services publish and consume dynamically.

Weld-OSGi embeds CDI containers in OSGi, using extensions to observe bundle events and register services as beans. This allows injecting OSGi services into CDI components effortlessly.

Dynamic Features and Practical Demonstrations

They demonstrated service dynamism: publishing a service updates dependent beans automatically. Unpublishing triggers alternatives or errors, ensuring robustness.

Demos included hybrid applications where Java EE components interact with OSGi bundles via the registry, deploying parts dynamically without restarts.

Future Prospects and Community Engagement

Mathieu discussed ongoing work for hybrid servers like GlassFish, embedding Weld-OSGi for cleaner integrations. They referenced RFC 146, inspired by Weld-OSGi, for native CDI-OSGi support.

Encouraging trials, they pointed to GitHub repositories with examples and documentation, fostering feedback to evolve the framework.

Mathieu and Matthieu’s presentation illustrated Weld-OSGi’s potential to create fully dynamic modular applications, blending CDI’s elegance with OSGi’s power.

Links:

PostHeaderIcon [DevoxxBE2012] The Advantage of Using REST APIs in Portal Platforms to Extend the Reach of the Portal

Rinaldo Bonazzo, a seasoned IT professional with extensive experience in project management and technology evangelism for Entando, highlighted the strategic benefits of integrating REST APIs into portal platforms during his presentation. Rinaldo, who has led initiatives in sectors like animal health and European community projects, emphasized how Entando, an open-source Java-based portal, leverages REST to facilitate seamless data exchange across diverse systems and devices.

He began by outlining Entando’s capabilities as a comprehensive web content management system and framework, enabling developers to build vertical applications efficiently. Rinaldo explained the decision to adopt JSR-311 (now part of Java EE 6) for RESTful services, which allows Entando to connect with external clients effortlessly. This approach minimizes development effort, as REST standardizes interactions using lightweight protocols like JSON or XML, making integration with web clients, smartphones, and tablets straightforward.

In a practical demonstration, Rinaldo showcased creating a service to publish open data across multiple devices. He illustrated how REST APIs provide a base URI for accessing resources, such as content, images, or entities, without the overhead of more complex protocols. This not only accelerates development but also ensures that portals can reach beyond traditional boundaries, fostering broader adoption within organizations.

Rinaldo stressed the importance of REST in modern architectures, where portals must interact with sensors, mobile apps, third-party services like BI tools or CRM systems, and even legacy applications. By collecting data from various sources—such as IoT devices in smart cities or user inputs from mobile forms—Entando exposes this information uniformly, supporting web browsers, extranets, and accessibility features for users with disabilities.

He shared real-world examples from Entando’s deployments, including portals for the Italian Civil Defense Department and the Ministry of Justice. These implementations prioritize accessibility, ensuring compliance with standards that allow visually impaired users to access content. Rinaldo pointed to the municipality of Cerea’s open data initiative, where REST APIs enable developers to retrieve resources like georeferenced data or submit requests via mobile apps, demonstrating practical extensions of portal functionality.

Furthermore, Rinaldo discussed security aspects, noting Entando’s use of OAuth for authorization, which secures API access with tokens. This ensures safe data exchange while maintaining openness.

Overall, Rinaldo’s insights underscored how REST APIs transform portals from isolated systems into interconnected hubs, enhancing reach and utility. By adhering to established standards, developers can innovate rapidly, integrating portals with emerging technologies and meeting diverse user needs effectively.

Extending Portal Functionality Through Integration

Rinaldo elaborated on the architectural advantages, where REST enables portals to act as central data aggregators. For instance, in smart city applications, APIs collect sensor data for traffic management, which portals then process and disseminate. Similarly, mobile integrations allow direct content insertion, as seen in Maxability’s iPhone app for Entando, where users submit georeferenced photos that portals geolocate and manage.

He highlighted government successes in Italy, where Entando’s portals support critical operations while ensuring inclusivity. Features like API documentation pages, as in Cerea’s developer portal, provide clear guidance on endpoints, methods, and parameters, lowering barriers for external developers.

Rinaldo concluded by inviting engagement with Entando’s community, reinforcing that REST not only extends reach but also promotes collaborative ecosystems. His presentation illustrated a shift towards open, extensible platforms that adapt to evolving digital landscapes.

Links:

PostHeaderIcon [DevoxxBE2012] Building Modular Applications with Enterprise OSGi

At DevoxxBE2012, Tim Ward and Holly Cummins, both seasoned experts in OSGi and enterprise technologies, delivered a comprehensive exploration into leveraging Enterprise OSGi for constructing modular applications. Tim, affiliated with Paremus and a key contributor to Apache Aries, alongside Holly from IBM, who focuses on WebSphere and performance tooling, guided attendees through the intricacies of transforming traditional Java EE setups into dynamic, OSGi-based systems. Their session bridged familiar concepts like WAR files and dependency injection with OSGi’s modularity, addressing common pain points in class path management.

They initiated the discussion by outlining Enterprise OSGi’s origins and relevance. Emerging in 2010, this specification enhances OSGi’s core, which has powered embedded systems and IDEs like Eclipse for over a decade, to better suit server-side enterprise needs. Tim and Holly emphasized how it integrates seamlessly with application servers, enabling features such as web applications, database interactions, and transaction management within an OSGi framework.

A key theme was the modularity crisis in large Java EE projects. They illustrated how sprawling WAR files, often exceeding server sizes like Tomcat’s 7MB core, accumulate unnecessary libraries, leading to class path hell. By contrasting tangled dependency graphs with OSGi’s structured approach, they demonstrated how explicit module definitions simplify maintenance and foster cleaner architectures.

Embracing OSGi Modularity Basics

Delving deeper, Tim and Holly explained OSGi’s bundle model, where each bundle—a JAR with added metadata—declares imports and exports via manifests. This enforces visibility rules, preventing accidental dependencies and promoting intentional design. They highlighted how bundles resolve dynamically, allowing runtime adaptability without redeployments.

The duo addressed common misconceptions, asserting that OSGi simplifies both complex and straightforward tasks. For instance, they showcased how dependency injection via Blueprint or Spring works effortlessly in OSGi, maintaining developer familiarity while adding modularity benefits.

They also touched on third-party library integration, noting challenges with non-OSGi JARs but solutions through tools that convert them into bundles. This ensures compatibility, reducing the bloat from redundant inclusions like JavaMail APIs.

Transitioning from WAR to WAB

A pivotal segment focused on evolving WAR files into Web Application Bundles (WABs). Tim and Holly demonstrated this migration, starting with a standard WAR and incorporating OSGi manifests to define it as a bundle. This shift enables deployment in OSGi containers like Apache Karaf or WebSphere Liberty, preserving servlet functionality while gaining modularity.

They illustrated error handling advantages: OSGi fails fast on missing dependencies, unlike runtime surprises in traditional setups. Through live examples, they showed bundles starting only when requirements are met, enhancing reliability.

Furthermore, they explored dynamism, where services can be added or removed at runtime, updating applications without downtime. This transparency in remoting and service interactions aligns with Java EE goals but executes more fluidly in OSGi.

Handling Dependencies and Repositories

Tim and Holly then examined dependency management, advocating explicit declarations to avoid hidden assumptions. They introduced bundle repositories, akin to Maven but tailored for OSGi, which automatically provision required bundles. This centralizes library control, aiding compliance in regulated environments.

In demonstrations, they deployed applications across servers like Liberty and Karaf, resolving dependencies on-the-fly. For instance, adding Joda Time via a repository revived a stalled bundle, showcasing practical modularity.

They stressed architectural enforcement: OSGi’s rules prevent poor practices, but good design remains essential. Tools like Eclipse plugins aid in visualizing and managing these structures.

Demonstrating Dynamism and Best Practices

The session culminated in hands-on demos, where a simple web app evolved into a dynamic OSGi system. Starting with a basic servlet, they integrated services for runtime changes, like toggling UI elements without restarts.

Tim and Holly concluded by reinforcing OSGi’s power in enforcing scalable, maintainable systems. They recommended resources, including their book “Enterprise OSGi in Action,” for further learning. Their presentation underscored how Enterprise OSGi not only resolves class path issues but elevates enterprise development to new levels of flexibility and efficiency.

Links:

PostHeaderIcon [DevoxxFR2012] JavaServer Faces: Identifying Antipatterns and Embracing Best Practices for Robust Applications

Lecturer

Kito Mann leads as Principal Consultant at Virtua, Inc., focusing on enterprise architecture, training, and mentoring in JavaServer Faces (JSF), HTML5, portlets, Liferay, and Java EE. Editor-in-chief of JSFCentral.com, he co-hosts the Enterprise Java Newscast and hosts the JSF Podcast series. Author of “JavaServer Faces in Action” (Manning), Kito participates in JCP expert groups for CDI, JSF, and Portlets. An international speaker at events like JavaOne and JBoss World, he holds a BA in Computer Science from Johns Hopkins University.

Abstract

This article probes Kito Mann’s exploration of common pitfalls in JavaServer Faces (JSF) development, juxtaposed with recommended strategies for optimal performance and maintainability. It scrutinizes real-world antipatterns, from hardcoded IDs and database accesses in getters to broader issues like inconsistent standards and improper API usage. Embedded in JSF’s component-based framework, the analysis reviews techniques for dependency injection, state management, and view optimization. Via code illustrations and case studies, it evaluates consequences for scalability, team onboarding, and application longevity, advocating principled approaches to harness JSF’s strengths effectively.

Common Pitfalls in Component and Bean Management

JSF’s strength lies in its reusable components and managed beans, yet misuse breeds inefficiencies. Kito identifies hardcoding IDs in backing beans as a cardinal error—components autogenerate IDs, risking conflicts. Instead, employ bindings or relative references.

Database operations in getters exacerbate performance: invoked multiple times per request, they overload servers. Solution: Fetch data in lifecycle methods like init() or use lazy loading:

@PostConstruct
public void init() {
    users = userService.getUsers();
}

Lack of standards fragments codebases; enforce conventions for naming, structure. Wrong APIs, like FacesContext in non-UI layers, violate separation—inject via CDI.

Optimizing State and View Handling

State management plagues JSF: View-scoped beans persist unnecessarily if not destroyed properly. Kito advises @ViewScoped with careful serialization.

Large views bloat state; mitigate with for partial renders or for modularization. c:if toggles subtrees but beware quirks—prefer rendered attributes unless tree pruning is essential.

Dependency lookups in getters repeat calls; leverage CDI injection:

@Inject
private UserProvider userProvider;

This ensures singletons are fetched once, enhancing efficiency.

Enhancing Performance Through Best Practices

Ajax integrations demand caution: Overuse swells requests. Optimize with execute/render attributes.

Navigation rules clutter; use implicit navigation or bookmarkable views with GET parameters.

Testing antipatterns include neglecting UI tests—employ JSFUnit or Selenium for comprehensive coverage.

Implications: These practices yield responsive, scalable apps. By avoiding antipatterns, teams reduce debugging, easing onboarding. In enterprise contexts, they align JSF with modern demands like mobile responsiveness.

Kito’s insights empower developers to refine JSF usage, maximizing framework benefits.

Links: