Labels

.NET Job Questions About Java Absract class Abstract class Abstract Class and Interface Aggregation ajax aop apache ofbiz Apache ofbiz tutrial Association authentication autocad basics batch Binary Tree bootstrap loader in java build Builder design pattern C++ Job Questions caching CallableStatement in java certifications Chain of responsibility Design pattern charts check parentheses in a string Classes classloader in java classloading concept code quality collage level java program Composition concurrency Concurrency Tutorial Converting InputStream to String Core Java core java concept core java interview questions Core Java Interview Questions Core Java Questions core java tutorial CyclicBarrier in Java data structures database Database Job Questions datetime in c# DB Db2 SQL Replication deserialization in java Design Patterns designpatterns Downloads dtd Eclipse ejb example/sample code exception handling in core java file handling injava File I/O vs Memory-Mapped Filter first program in spring flex Garbage Collection Generics concept in java grails groovy and grails Guice Heap hibernate Hibernate Interview Questions how-to IBM DB2 IBM DB2 Tutorial ide immutable Interceptor Interface interview Interview Questions for Advanced JAVA investment bank j2ee java JAVA Code Examples Java 7 java changes java class loading JAVA Classes and Objects Java Classloader concept Java classloading concept java cloning concept java collection Java collection interview questions Java Collections java concurrency Java CountDownLatch java definiton Java design pattern Java EE 5 Java EE 6 Java Exceptions Java file Java Garbage Collection Java generics Java Glossary java hot concept java immutable concept Java Interface Java interview Question java interview question 2012 java interview question answer Java Interview Questions Java Interview Questions and Answers java interview topic java investment bank Java Job Questions java multithreading java multithreading concept java new features Java Packages java proxy object java questions Java Serialization Java serialization concept java serialization interview question java session concept java string Java Swings Questions java synchronization java threading Java Threads Questions java tutorial java util; java collections; java questions java volatile java volatile interview question Java Wrapper Classes java.java1.5 java.lang.ClassCastException JavaNotes javascript JAX-WS jdbc JDBC JDBC Database connection jdk 1.5 features JDK 1.5 new features Concurrent HashMap JMS interview question JMS tutorial job JSESSIONID concept JSESSIONID interview Question JSF jsp JSP Interview Question JSP taglib JSTL with JSP Junit Junit Concept Junit interview question.Best Practices to write JUnit test cases in Java JVM Linux - Unix tutorial Marker Interfaces MD5 encryption and decryption messaging MNC software java interview question musix NCR java interview question Networking Job Questions news Object Serialization Objects ojdbc14.jar OOP Oracle Oracle SQL Query for two timestamp difference orm own JavaScript function call in Apache ofbiz Packages Palm Apps patterns pdf persistence Portal Portlet Spring Integration Prime number test in java programs Rails Reboot remote computers REST Ruby Sample application schema SCJP security Senior java developer interviews servlet3 servlets session tracking singleton design pattern Spring Spring 2.5 Framework spring ebook Spring framework concept spring MVC spring pdf Spring Security Spring Security interview questions SQL SQL performance SQL Query to create xml file Sql Query tuning ssis and ssrs StAX and XML string concept string immutable string in java strings struts Struts2 Struts2 integration synchronization works in java Technical Interview testing tips Tomcat top Tutorial Volatile in deep Volatile working concept web Web Developer Job Questions web services weblogic Weblogic Application Server websphere what is JSESSIONID xml XML parsing in java XML with Java xslt


Sunday, 21 July 2013

most Asked j2ee questions


What servlet container and JDK is used in J2EE Public Service?
Apache Tomcat, release 5.5.23 running on Java SDK version 6.
What Servlet/JSP specification versions are supported?
The supported specification versions are: Servlet 2.4 and JSP 2.0.
My webapplication uses EJB, can I host it in the J2EE Public Service?
Apache Tomcat is not an EJB server. It is a Servlet container so EJBs are not supported directly by the J2EE Public Server. 
A solution to use EJBs in the J2EE Public Service is to use OpenEJB. It is a project developed by the Apache Software Foundation which allows to use EJBs with Tomcat server (Tomcat 5 or 6 ). For more information, please visit the project website OpenEJB.
Web Application Archive (war) contains all files of a web application. In fact, it is a zip archive of application files with a specific structure. Read more here about the structure of the war file and how to create it manually.
J2EE Public Service provides a production (not development) platform and the applications should be thoroughly tested before deploying them on the service. However, there is no test machine available. The solution is straightforward: it's very simple to set up a test enviroment on your PC. Follow the instructions:
  1. Make sure you have a JDK 6 installed on your PC; if you don't, then download it from here(click "download JDK 6" ) and install it.
  2. Make sure that JAVA_HOME environment variable points to your JDK 6 installation.
  3. Download the container from here: jps-tomcat-5.5.23-oracle-jdbc-10.2.0.3.zip.
  4. Unzip it to a folder of your choice, this folder will be referred to as $CATALINA_HOME.
  5. Use:
       $CATALINA_HOME\bin\catalina.bat start -security
    or (depending on your operating system):
       $CATALINA_HOME\bin\catalina.sh start -security
    to start tomcat
  6. Simply copy your web application archive (.war) file to $CATALINA_HOME/webapps directory to deploy your application
After that, your application will be accessible on your PC on port 8080. Make sure to include -security option when you start tomcat to check, if your application works with J2EE Public Service security manager.
Follow the instructions:
  1. Make sure you have a JDK 6 installed on your PC; if you don't, then download it from here(click "download JDK 6" ) and install it.
  2. Make sure that JAVA_HOME environment variable points to your JDK 6 installation.
  3. Download the container from here: apache-tomcat-6.0.18-oracle-jdbc-10.2.0.3.zip.
  4. Unzip it to a folder of your choice, this folder will be referred to as $CATALINA_HOME.
  5. Use:
       $CATALINA_HOME\bin\catalina.bat start -security
    or (depending on your operating system):
       $CATALINA_HOME\bin\catalina.sh start -security
    to start tomcat
  6. Simply copy your web application archive (.war) file to $CATALINA_HOME/webapps directory to deploy your application
After that, your application will be accessible on your PC on port 8080. Make sure to include -security option when you start tomcat to check, if your application works with J2EE Public Service security manager.
I need to create a temporary file from a servlet/jsp. Where can I write it?
Every Tomcat container has read/write access to its temp directory. To be sure that your solution is portable, don't use any hardcoded file paths. Instead, use the following:
   java.io.File tempFile = java.io.File.createTempFile("test",".tmp");   tempFile.deleteOnExit();
If you have any further doubts, consult the API.
My application uses custom libraries. Where should I upload the jar files?
Please all jar files you use in the WEB-INF/lib/ directory in the war file. Mind you, some libraries (see below) come with the container so you don't have to (and should not to) bundle them with your application.
Can I use NICE authentication? How should I authenticate/authorize my users?
NICE authentication is the default way to go. Please see the following technical recommendation on authorization/authentication using CERN Authentication.
What libraries are available by default?
The following libraries are available by default to every application.
  • Basic runtime classes provided by the Java Virtual Machine, version 6
  • Libraries which come with Apache Tomcat, release 5.5.23:
    • commons-el.jar - Jakarta commons el, implementing the expression language used by Jasper.
    • jasper-compiler.jar - The JSP 2.0 compiler.
    • jasper-compiler-jdt.jar - The Eclipse JDT Java compiler.
    • jasper-runtime.jar - The JSP 2.0 runtime.
    • jsp-api.jar - The JSP 2.0 API.
    • naming-factory.jar - The JNDI implementation used by Tomcat 5 to resolve references to enterprise resources (EJB, connection pools).
    • naming-factory-dbcp.jar - Jakarta commons DBCP, providing a JDBC connection pool to web applications. The classes have been moved out of their default org.apache.commons package.
    • naming-resources.jar - The specialized JNDI naming context implementation used to represent the static resources of a web application. This is not related to the support of the J2EE ENC, and cannot be removed.
    • servlet-api.jar - The Servlet 2.4 API. servlet-api.jar
  • Oracle drivers, version 10.2.0.3:
    • ojdbc14.jar
    • orai18n.jar
There are three most common problems when using connection pooling:
  1. You're not closing your Connection objects.
  2. You're not closing your ResultSet, Statement, PreparedStatement or CallableStatement objects.
  3. The connection in the pool gets broken.
The first two problems lead to resource leak. 

Number 1 will block your application, as you reach the maximum number of connections. Therefore, i'ts very important to close the Connection objects, because only then are they returned to the pool and can be reused by your application. 

Number 2 makes cursors stay on the database side, which will block the entire database, when the cursor limit is hit. 

There are two useful tools that let you investigate the problems on the database side:http://service-oracle.web.cern.ch/service-oracle/help/session-manager.php and ViewDB. Use them to get a hint of a forgotten Connection/Statement/Resultset and/or review your code to fix the problem.

You can also use the following DBCP parameters to make let DBCP recover these abandoned connections (see below for more on DBCP parameters): 
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"

Number 3 is more tricky, as there can be many reasons for the connection to be broken. The symptoms are the following: you sometimes get a database error, but when you click "refresh" the error is gone.

The solution here is to configure connection pool in such a way that it checks the connection before it's used. We're recommending use of Apache Jakarta Commons DBCP, as explainedhere. Normally, setting the following DBCP parameters fixes the problem: 
testOnBorrow="true"
validationQuery="select sysdate from dual"

If these settings are not optimal for you, please check DBCP parameter documentation to choose best settings for your scenario.
We provide you two solutions depending on your requirements:
1._ DFS library: On demand (J2EE Public Service Support), we provide you a library that uses WebDAV to connect the Distributed File System (DFS). The limitation of this solution is that the source code of your java webapplication will have to be modified in order to use use this library.
2._ AFS repository: An AFS repository will be assigned to your webapplication. This AFS repository is a directory where you can store your data files and configure your webapplication to access to it as part of the file system. For more information, consult Using AFS as permanent storage solution .

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...