Recent Posts
Archives

Posts Tagged ‘JPA’

PostHeaderIcon (long tweet) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB’ at line 1

Stacktrace

[java]org.hibernate.tool.hbm2ddl.SchemaExport – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘type=InnoDB’ at line 1[/java]

Quick fix

In JPA configuration, replace:
datasource.dialect = org.hibernate.dialect.MySQLInnoDBDialect
with:
datasource.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
Actually, Java driver for MySQL 5.5+ is not backward compatible with the SQL dialect MySQLInnoDBDialect.

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 [DevoxxBE2013] MongoDB for JPA Developers

Justin Lee, a seasoned Java developer and senior software engineer at Squarespace, guides Java EE developers through the transition to MongoDB, a leading NoSQL database. With nearly two decades of experience, including contributions to GlassFish’s WebSocket implementation and the JSR 356 expert group, Justin illuminates MongoDB’s paradigm shift from relational JPA to document-based storage. His session introduces MongoDB’s structure, explores data mapping with the Java driver and Morphia, and demonstrates adapting a JPA application to MongoDB’s flexible model.

MongoDB’s schemaless design challenges traditional JPA conventions, offering dynamic data interactions. Justin addresses performance, security, and integration, debunking myths about data loss and injection risks, making MongoDB accessible for Java developers seeking scalable, modern solutions.

Understanding MongoDB’s Document Model

Justin introduces MongoDB’s core concept: documents stored as JSON-like BSON objects, replacing JPA’s rigid tables. He demonstrates collections, where documents vary in structure, offering flexibility over fixed schemas.

This approach, Justin explains, suits dynamic applications, allowing developers to evolve data models without migrations.

Mapping JPA to MongoDB with Morphia

Using Morphia, Justin adapts a JPA application, mapping entities to documents. He shows annotating Java classes to define collections, preserving object-oriented principles. A live example converts a JPA entity to a MongoDB document, maintaining relationships via references.

Morphia, Justin notes, simplifies integration, bridging JPA’s structured queries with MongoDB’s fluidity.

Data Interaction and Performance Tuning

Justin explores MongoDB’s query engine, demonstrating CRUD operations via the Java driver. He highlights performance trade-offs: write concerns adjust speed versus durability. A demo shows fast writes with minimal safety, scaling to secure, slower operations.

No reported data loss bugs, Justin assures, bolster confidence in MongoDB’s reliability for enterprise use.

Security Considerations and Best Practices

Addressing security, Justin evaluates injection risks. MongoDB’s query engine resists SQL-like attacks, but he cautions against $where clauses executing JavaScript, which could expose vulnerabilities if misused.

Best practices include sanitizing inputs and leveraging Morphia’s type-safe queries, ensuring robust, secure applications.

Links:

PostHeaderIcon [DevoxxBE2012] Apache TomEE: Java EE 6 Web Profile on Tomcat

David Blevins, a veteran in open-source Java EE and founder of projects like OpenEJB and TomEE, showcased Apache TomEE. With over a decade in specifications like EJB and CDI, David positioned TomEE as a bridge for Tomcat users seeking Java EE capabilities.

He polled the audience, revealing widespread Tomcat use alongside other servers, highlighting the migration pain TomEE addresses. David described TomEE as Tomcat enhanced with Java EE, unzipping Tomcat, adding Apache projects like OpenJPA and CXF, then certifying the bundle.

Emphasizing small size, certification, and Tomcat fidelity, David outlined distributions: Web Profile (minimal specs), JAX-RS (adding REST), and Plus (including JMS, JAX-WS).

Understanding the Web Profile

David clarified the Java EE 6 Web Profile, a subset of 12 specs from the full 24, excluding outdated ones like CORBA and CMP. This acknowledges Java EE’s growth, focusing on essentials for modern apps.

He noted exclusions like JAX-RS (added in EE 7) and inclusions like JavaMail in TomEE’s Web Profile for practicality. David projected EE 7’s profile reductions, potentially enabling full-profile TomEE certification.

Demonstrating TomEE in Action

In a live demo, David set up TomEE in Eclipse using Tomcat adapters, creating a servlet with EJB injection and JPA. He deployed seamlessly, showcasing CDI, transactions, and web services, all within Tomcat’s familiar environment.

David highlighted TomEE’s lightweight footprint—under 30MB—booting quickly with low memory. He integrated tools like Arquillian for testing, demonstrating in-container and embedded modes.

Advanced Features and Configuration

David explored clustering with Hazelcast, enabling session replication without code changes. He discussed production readiness, citing users like OpenShift and Jelastic.

Configuration innovations include flat XML-properties hybrids, human-readable times (e.g., “2 minutes”), and dynamic resource creation. David showed overriding via command-line or properties, extending for custom objects injectable via @Resource.

Error handling stands out: TomEE collects all deployment issues before failing, providing detailed, multi-level feedback to accelerate fixes.

Community and Future Directions

Celebrating TomEE’s first year, David shared growth metrics—surging commits and mailing lists—inviting contributions. He mentioned production adopters praising its simplicity and performance.

David announced a logo contest, encouraging participation. In Q&A, he affirmed production use, low memory needs, and solid components like OpenJPA.

Overall, David’s talk positioned TomEE as an empowering evolution for Tomcat loyalists, blending familiarity with Java EE power.

Links:

PostHeaderIcon WebLogic 10.x new features

Recent history

BEA WebLogic 9.0, 9.1 and 9.2 were released from 2007: the main features were: a new console, WLST (WebLogic ScriptingTool), deployment plans, WebLogic Diagnostic Framework (WLDF), new security providers (RDBMS, SAML 1.1, etc.), JMS performance improvements, support of Java EE 4, JDK 5, Spring, OpenJPA, Kodo, etc.

Since this date, some events happened:

  • Oracle bought Sun (2009)
  • Oracle released WebLogic 10.3 (2008)
  • Oracle bought BEA (2008)

WebLogic Server 10 General Features

  • Developer productivity ehancements
    • JDK 6, Java EE 5
    • Support of EJB3 and JPA
    • BEA enhancements
  • Web Services: more annotations, less XML
    • JAX-RPC Web Services Enhancements
    • JAX-WS 2.0 Web Services Implementation
  • Misc:
    • Better administration console
    • Auto-Record of Admin Console actions as WLST scripts
    • Automatic JTA Transaction Recovery Service (TRS) migration
    • SNMP 3.0
    • Production Application Redeployment enhancements
    • Clustering – Unicast messaging (in addition to Multicast)

Programmer Perspective

  • New persistence engine: TopLink
  • OEPE (Oracle Entreprise Pack for Eclipse): sequence of tools and plugins for Eclipse: remote deployment, debugging,  editors for weblogic.xml and weblogic-application.xml, wizards, facets, Weblogic ClientGen, WSDLC and JAXB wizards
  • Optimizations for Spring integration and certication
  • Web 2.0:
    • Ajax / Dojo client support
    • Http publish / submit engine for collaborative applications:
      • Bayeux protocol
      • data exchange within applications over persistent connections
      • scalability for Dojo clients
  • Ad-hoc tools for:
    • Oracle Database
    • Spring
    • JAX-WS webservices

Lightweight WebLogic Server

WebLogic 10 offers a light weight server:

  • Install only “core” WebLogic server
  • Optionally, startup other services (JDBC, EJB, JMS, etc.)
  • FastSwap: modify classes without requiring redeployment.

Architect Perspective

Architects have to consider WebLogic as a complete suite, and not only WebLogic Server:

  • Oracle RAC integration: Connectivity to RAC with load balancing, failover, transactions
  • Enterprise Messaging with JMS: High performance and reliable JMS messaging engine “built-in”
  • ActiveCache with Coherence*Web and EJB/JPA: Coherence Data Grid caching included and integrated
  • Operations Automation: Tools for automating management of applications and servers
  • Operations Insight: Tools for diagnosing problems in development and production
  • Other features
    • Development tools: Choice of tools for developer productivity
    • Web Services: Enterprise Web Services for SOA
    • TopLink: Persist application data to stores with performance and productivity. It works in a way similar to Hibernate L2 cache.
    • Spring: Enable flexible choice of dev frameworks with same WebLogic QOS

Production and Support Perspective

WebLogic 10 provides a tool: JRockit Mission Control

  • monitors more than 150 parameters:
  • CPU
    • memory
    • leaks
    • latency spikes
    • threads
    • object references
    • JDBC connections
    • JMS
    • pools
    • clusters
    • configuration files
    • etc.
  • allows to compare WebLogic domains
  • Runtime Analyzer: runtime capture for offline analysis, Garbage Collector analysis, etc.

Coherence – ActiveCache

Coherence is the Data Grid offered by Oracle. It allows to store Java objects in memory, and share them between all instances. From a certain viewpoint, Coherence looks like the GigaSpaces.

Roadmap for Future WebLogic Releases

  • Support of Java EE 6 (ratified by the community in last December)
  • OSGi deployment
  • More native integration for WebLogic Server – Coherence – Oracle Database
  • JRockit Flight Recorder for constant record
  • Virtualization
  • More integration with Maven, Hudson and Cruise Control
  • Shared Library: use the same JAR for many applications, rather than packing the same JAR in different EARs.
  • On long term:
    • IDE
      • NetBeans to be oriented onto J2ME development
      • JDevelopper to remain Oracle strategic IDE
      • Contributions to Eclipse to go on
    • JRockit and Sun HotSpot JVMs to be merged.