EzDevInfo.com

glassfish interview questions

Top glassfish frequently asked interview questions

Address already in use: JVM_Bind

I'm using Glassfish 3.0.1, JVM 1.6.0_21 on Windows XP Pro;

I don't know exactly what has changed in my environment but I get this stacktrace as soon as I try to deploy an enterprise application (ejb module + app client module).

There is nothing running on port 3820, except Glassfish... I checked with netstat with the server stopped and the server started.

What could be the cause of this? Some internal process conflict?

Any tips on how I can debug this further?

WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
SEVERE: iiop.createsocket_exception
WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
SEVERE: java.net.BindException: Address already in use: JVM_Bind
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
        at java.net.ServerSocket.bind(ServerSocket.java:319)
        at java.net.ServerSocket.<init>(ServerSocket.java:185)
        at javax.net.ssl.SSLServerSocket.<init>(SSLServerSocket.java:106)
        at com.sun.net.ssl.internal.ssl.SSLServerSocketImpl.<init>(SSLServerSocketImpl.java:106)
        at com.sun.net.ssl.internal.ssl.SSLServerSocketFactoryImpl.createServerSocket(SSLServerSocketFactoryImpl.java:72)
        at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createSSLServerSocket(IIOPSSLSocketFactory.java:402)
        at org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory.createServerSocket(IIOPSSLSocketFactory.java:281)
        at com.sun.corba.ee.impl.transport.SocketOrChannelAcceptorImpl.initialize(SocketOrChannelAcceptorImpl.java:91)
        at com.sun.corba.ee.impl.transport.CorbaTransportManagerImpl.getAcceptors(CorbaTransportManagerImpl.java:247)
        at com.sun.corba.ee.impl.transport.CorbaTransportManagerImpl.addToIORTemplate(CorbaTransportManagerImpl.java:264)
        at com.sun.corba.ee.spi.oa.ObjectAdapterBase.initializeTemplate(ObjectAdapterBase.java:131)
        at com.sun.corba.ee.impl.oa.poa.POAImpl.initialize(POAImpl.java:474)
        at com.sun.corba.ee.impl.oa.poa.POAImpl.makeRootPOA(POAImpl.java:323)
        at com.sun.corba.ee.impl.oa.poa.POAFactory$1.evaluate(POAFactory.java:279)
        at com.sun.corba.ee.impl.orbutil.closure.Future.evaluate(Future.java:57)
        at com.sun.corba.ee.impl.resolver.LocalResolverImpl.resolve(LocalResolverImpl.java:51)
        at com.sun.corba.ee.impl.resolver.CompositeResolverImpl.resolve(CompositeResolverImpl.java:55)
        at com.sun.corba.ee.impl.orb.ORBImpl.resolve_initial_references(ORBImpl.java:1289)
        at com.sun.corba.ee.impl.naming.cosnaming.TransientNameService.initialize(TransientNameService.java:122)
        at com.sun.corba.ee.impl.naming.cosnaming.TransientNameService.<init>(TransientNameService.java:90)
        at org.glassfish.enterprise.iiop.impl.PEORBConfigurator.configure(PEORBConfigurator.java:154)
        at com.sun.corba.ee.impl.orb.ORBConfiguratorImpl.runUserConfigurators(ORBConfiguratorImpl.java:191)
        at com.sun.corba.ee.impl.orb.ORBConfiguratorImpl.configure(ORBConfiguratorImpl.java:176)
        at com.sun.corba.ee.impl.orb.ORBImpl.postInit(ORBImpl.java:579)
        at com.sun.corba.ee.impl.orb.ORBImpl.set_parameters(ORBImpl.java:680)
        at com.sun.corba.ee.impl.orb.ORBImpl.setParameters(ORBImpl.java:666)
        at com.sun.corba.ee.spi.osgi.ORBFactory.initialize(ORBFactory.java:91)
        at org.glassfish.enterprise.iiop.impl.GlassFishORBManager.initORB(GlassFishORBManager.java:612)
        at org.glassfish.enterprise.iiop.impl.GlassFishORBManager.getORB(GlassFishORBManager.java:289)
        at org.glassfish.enterprise.iiop.impl.GlassFishORBFactoryImpl.createORB(GlassFishORBFactoryImpl.java:83)
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getORB(GlassFishORBHelper.java:122)
        at org.glassfish.enterprise.iiop.api.GlassFishORBHelper.getProtocolManager(GlassFishORBHelper.java:189)
        at com.sun.ejb.containers.BaseContainer.initializeProtocolManager(BaseContainer.java:810)
        at com.sun.ejb.containers.BaseContainer.<init>(BaseContainer.java:558)
        at com.sun.ejb.containers.AbstractSingletonContainer.<init>(AbstractSingletonContainer.java:136)
        at com.sun.ejb.containers.CMCSingletonContainer.<init>(CMCSingletonContainer.java:73)
        at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:109)
        at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:207)
        at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:197)
        at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:63)
        at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:175)
        at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:216)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:338)
        at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:183)
        at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:272)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
        at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
        at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:365)
        at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:204)
        at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:166)
        at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:100)
        at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:245)
        at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:791)
        at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:693)
        at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:954)
        at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:170)
        at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:135)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:102)
        at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:88)
        at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:76)
        at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:53)
        at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:57)
        at com.sun.grizzly.ContextTask.run(ContextTask.java:69)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:330)
        at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:309)
        at java.lang.Thread.run(Thread.java:619)

WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
WARNING: Can not find resource bundle for this logger.  class name that failed: org.glassfish.enterprise.iiop.impl.IIOPSSLSocketFactory
SEVERE: "IOP00410216: (COMM_FAILURE) Unable to create IIOP listener on the specified host/port: all interfaces/3820"

EDIT Here it's exactly what I tried:

C:\Documents and Settings\b.tanase>netstat -p tcp -ano | findstr :3820

asadmin> start-domain domain1
Waiting for DAS to start ...
Started domain: domain1
Domain location: D:\java\glassfish-3.0.1\glassfish\domains\domain1
Log file: D:\java\glassfish-3.0.1\glassfish\domains\domain1\logs\server.log
Admin port for the domain: 4848
Command start-domain executed successfully.

C:\Documents and Settings\b.tanase>netstat -p tcp -ano | findstr :3820

asadmin> deploy d:/java/projects/netbeans-projects/CountingSystem/dist/CountingS
ystem.ear
com.sun.enterprise.admin.cli.CommandException: remote failure: Exception while l
oading the app : java.lang.RuntimeException: EJB Container initialization error
Exception while invoking class org.glassfish.ejb.startup.EjbDeployer load method
 : java.lang.RuntimeException: EJB Container initialization error


Command deploy failed.

C:\Documents and Settings\b.tanase>netstat -p tcp -ano | findstr :3820
  TCP    0.0.0.0:3820           0.0.0.0:0              LISTENING       2428

As you can see there's nothing listening on port 3820 until the deployment failes (before EJB Container initialization error I get in the server log the stacktrace posted at the beggining of the post)


Source: (StackOverflow)

Getting JSTL to run within Tomcat and Eclipse

I've been trying to get this to run, but I can't. I'm using Eclipse Galileo, Tomcat 5.5.23 and have several JSTLs around. My latest try was to use the GlassFish jar file "jstl-impl-1.2.jar". I placed it in Tomcat's shared lib, added it as external jar into my Eclipse project and exported it.

Could anybody tell me, which jars to load in which folder and how to tell it to load in Eclipse?


Source: (StackOverflow)

Advertisements

How to install the GlassFish 3 server adapter with Eclipse Helios 3.6

Question as stated in the title: how to install the GlassFish Server Adapter on Eclipse Helios 3.6?


Source: (StackOverflow)

what is java.io.EOFException, Message: Can not read response from server. Expected to read 4 bytes, read 0 bytes

This question has been asked a couple of times in SO and many times in other sites. But I didn't get any satisfiable answer.

My problem:
I have a java web application which uses simple JDBC to connect to mysql database through Glassfish application server.

I have used connection pooling in glassfish server with the following configurations:
Initial Pool Size: 25
Maximum Pool Size: 100
Pool Resize Quantity: 2
Idle Timeout: 300 seconds
Max Wait Time: 60,000 milliseconds

The application has been deployed for last 3 months and it was running flawlessly too.
But from last 2 days the following error is coming at the time of login.

Partial StackTrace

com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: No operations allowed after connection closed.Connection was implicitly closed due to underlying exception/error:  

** BEGIN NESTED EXCEPTION **  

com.mysql.jdbc.CommunicationsException  
MESSAGE: Communications link failure due to underlying exception:  

** BEGIN NESTED EXCEPTION **  

java.io.EOFException  
MESSAGE: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.  

STACKTRACE:  

java.io.EOFException: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.  
at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1997)  
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2411)  
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2916)  
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)  
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)  
at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)  
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)  
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1448)  
............  
............  
my application traces....  

What caused this error suddenly ? I have lost a lot of time for this.

EDIT : The problem even persists after restarting the server. As per DBA two of the important mysql server configurations are:
wait_timeout : 1800 seconds
connect_timeout : 10 seconds
NOTE : Other applications deployed in the same server connecting to the same database and using different pools are running smoothly.

EDIT-2 : After reading a lot of things and expecting some positive outcome I made these changes to my connection pool.

Max Wait Time : 0 (previously it was 60 seconds)
Connection Validation : Required
Validation Method : table
Table Name : Demo
Validate Atmost Once : 40 seconds
Creation Retry Attempts : 1
Retry Intervals : 5 seconds
Max Connection Usage : 5

And this worked as the application is running for 3 days consistently. But I got a very strange and interesting result of out this. While monitoring the connection pool, I found these figures:

NumConnAcquired : 44919 Count
NumConnReleased : 44919 Count
NumConnCreated : 9748 Count
NumConnDestroyed : 9793 Count
NumConnFailedValidation : 70 Count
NumConnFree : 161 Count
NumConnUsed : -136 Count

How can the NumConnFree become 161 as I have Maximum Pool Size = 100 ?
How can the NumConnUsed become -136, a negative number ?
How can the NumConnDestroyed > NumConnCreated ?


Source: (StackOverflow)

How do I specify the jdk for a glassfish domain?

I've got Glassfish 2.1.1 installed. I have a 1.5 and a 1.6 JDK installed. Even though my JAVA_HOME variable is set to the 1.5 version (and both "java -version" and "javac -version" display 1.5), whenever I start my glassfish domain it always states at the top of the log that its using version 1.6. How can I override this?

Starting Domain domain2, please wait.
04-May-2012 08:38:47 com.sun.enterprise.admin.servermgmt.launch.ASLauncher buildCommand
INFO:
C:/Dev/jdk/1.6/1.6.0_19\bin\java

Source: (StackOverflow)

What is the difference between Tomcat, JBoss and Glassfish?

I am starting to look into Enterprise Java and the book I am following mentions that it will use JBoss. Netbeans ships with Glassfish. I have used Tomcat in the past.

What are the differences between these three programs?


Source: (StackOverflow)

Would you, at present date, use JBoss or Glassfish (or another) as Java EE server for a new project? [closed]

If you started a new Java EE project today which is to be finished in about a year, which application server would you choose and why?

Part of your answer should include your arguments for your decision. And also how much experience you have with the Java EE server you choose and with the other available servers on the market. These are interesting as we all get a sense of the investigation and thought that was put into your answer.


Source: (StackOverflow)

PermGen space error - Glassfish Server

I am running java web application using Hibernate and glassfish Server. I am getting

java.lang.OutOfMemoryError: PermGen space exception when after I deploying it several times.

I tried -XX:MaxPermSize=128M in my Environment variables, but it doesn't work.


Source: (StackOverflow)

How can a JACC provider use the Principal-to-role mapping facilities of the server it's deployed on?

I am writing a JACC provider.

Along the way, this means implementing a PolicyConfiguration.

The PolicyConfiguration is responsible for accepting configuration information from the application server, such as which permissions accrue to which roles. This is so that a Policy later on can make authorization decisions when handed information about the current user and what he's trying to do.

However, it is not part of the PolicyConfiguration's (atrocious) contract to maintain a mapping between roles and their permissions, and Principals that are assigned to those roles.

Typically--always, really--an application server houses this mapping. For example, on Glassfish, you affect this mapping by supplying things like sun-web.xml and sun-ejb-jar.xml and so on with your Java EE modules. (These vendor-specific files are responsible for saying, e.g., superusers is a group that is to be assigned the application role of admins.)

I would like to reuse the functionality these files supply, and I would like to do so for as wide an array of application servers as possible.

Here is--totally arbitrarily--IBM's take on the matter, which appears to confirm my suspicion that what I want to do is essentially impossible. (More ammunition for my case that this particular Java EE contract is not worth the paper it's printed on.)

My question: how do I get at this principal-to-role-mapping information in--for starters--Glassfish and JBoss from within a PolicyConfiguration? If there's a standard way to do it that I'm unaware of, I'm all ears.


Source: (StackOverflow)

Log4J properties file - where to put it

I wrote a web service project using netbeans 6.7.1 with glassfish v2.1, put log4j.properties to the root dir of project and use

static Logger logger = Logger.getLogger(MyClass.class);

in Constructor: PropertyConfigurator.configure("log4j.properties");

and in functions:

logger.info("...");
logger.error("...");
...

but, it is error info(actually, I have tried to put it almost every dir that I could realize):

log4j:ERROR Could not read configuration file [log4j.properties].
java.io.FileNotFoundException: log4j.properties (The system cannot find the file specified)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:106)
        at java.io.FileInputStream.<init>(FileInputStream.java:66)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:297)
        at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:315)
        at com.corp.ors.demo.OrsDemo.main(OrisDemo.java:228)
log4j:ERROR Ignoring configuration file [log4j.properties].
log4j:WARN No appenders could be found for logger (com.corp.ors.demo.OrsDemo).
log4j:WARN Please initialize the log4j system properly.

the example project could be get from http://www.91files.com/?N3F0QGQPWMDGPBRN0QA8


Source: (StackOverflow)

Why use Apache Web Server in front of Glassfish or Tomcat?

Is it good idea to use Apache Webserver in front of GF or Tomcat? Does it improve the performance/security?

Or there is not any reason to use Apache Web Server with GF?


Source: (StackOverflow)

glassfish v3 vs tomcat 7 [closed]

Which one do you recommend for web and why?


Source: (StackOverflow)

Difference com.sun.jersey and org.glassfish.jersey

What is the difference between com.sun.jersey and org.glassfish.jersey?

Currently I have my REST service working on com.sun.jersey and I want to write tests, but I can't find a good tutorial for this (nothing seems to work). However, I can find good documentation about the org.glassfish.jersey tests.


Source: (StackOverflow)

Jetty, Tomcat, Nginx, Geronimo, Glassfish: I'm confused

As someone new to the Java EE ecosystem, I'm confused with these products which share a tremendous amount of keywords. And half of them come from Apache software foundation.

Can someone address me with a brief distinctive explanation for each of them?


Source: (StackOverflow)

Location of GlassFish Server Logs

I have NetBeans IDE installed on a Windows 7 64-bit machine. Obviously, NetBeans comes with the GlassFish server.

I am currently having problems with a project and would like to check the server logs. Where are these stored please?


Source: (StackOverflow)