Rohit Garg

Ranch Hand
+ Follow
since Feb 05, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rohit Garg

As far as my knowledge of graphics goes, you need to look at something called framebuffer. 60 fps is not something that you would just plainly go and loop-update the screen.

Never tried framebuffer myself in swing, but i think it can be the solution to your problem.
11 years ago
I had a problem to solve in the interview which said that

Digits should be rounded off to a precision level of 0.05

.

Now i tried out the math formula to do that using Double as the object, but unfortunately, math bug crept in and the resulting value became something like 12.150000000002. Now i have no option but to use the Decimal format.. ..

Just wanted to ask is there another way out??

Regards,
Rohit
12 years ago
No issues man... Do post back when you arr done..

Thanks so much for your help!



No issues man. We are all here to GET and PUT help!!
12 years ago

As I understand it, JNDI is like a shop assistant, showing the customers (the server and the web app) the way to the fruit aisle (the database), going past different food on the way (different resources). Is that about right?



Nice way of putting things together ...

JNDI is totally and entirely linked to the configurational side of the server. You won't be needing additional code to make beans on the webserver get shared across different applications. It behaves just like a TreeMap which has string vs an object. If you lookup for a string, you will get the object.

Now when they say data source, what do they mean? What is its purpose? Also, I don't understand the text in green. Can someone err... thickify it for me?



A Datasource is like a wrapper to the connection. As you might know that there a lot of vendors working on creating datasources, at times they miss out on things in their drivers that can change the way your application interacts with your database. For example you might want to configure that a ConnectionFactory only passes 5 connections and not more than that at any point in time. It would become your headache to code that thing. Now what the containers have provided to you is the same thing but in an externalized manner (kind of property/xml file driven). They only say that you have the freedom to create database connections inside your application, but i have provided you an API via which you will be able to manage them outside of your application.

As far as the text in green is concerned, it just says that you need to make entries to your datasource to another file (usually server.xml) and just add a reference to it in your descriptor (usually web.xml). Then what it would do is that put an instance of the datasource object given by container to the TreeMap provided by JNDI and the string to access would be java:comp/env/<datasource_name> (something like java:comp/env/jdbc/myDatabaseName).

Hope that helps!!
12 years ago
Tried it out myself and appeared to work just fine.

I would say that you should check for any classes within some other jar files in your classpath with same name and package. It happens a lot that a preferred classloader in the chain has loaded the some other class (with same package and name) and it just returns that one instead of the one you are thinking about.
12 years ago
Hi,

Just out of curiosity, wanted to know if there is any mechanism by which stuck threads can be killed without requiring a server restart so that the memory space occupied by them can be freed and the out of memory error, which will eventually kill the server, can be avoided.

Thanks,
Rohit
13 years ago
Hi all,

Whenever an enterprise application is deployed on my local weblogic server 9.2, an exception appears but the deployment completes successfully. The trace is :

java.lang.ClassNotFoundException: com.bea.p13n.entitlements.common.management.internal.PolicyRefMigration
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:286)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:158)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:242)
at com.bea.p13n.entitlements.management.internal.RDBMSPolicyRefManager.initializePersistence(RDBMSPolicyRefManager.java:537)
at com.bea.p13n.entitlements.management.internal.RDBMSPolicyRefManager.getResourceElement(RDBMSPolicyRefManager.java:260)
at com.bea.p13n.entitlements.management.internal.RDBMSSecurityPolicyManager.getSecurityPolicy(RDBMSSecurityPolicyManager.java:226)
at com.bea.p13n.entitlements.management.SecurityPolicyManager.getSecurityPolicy(SecurityPolicyManager.java:119)
at com.bea.content.manager.internal.ContentUpgradeListener.hasUpgradeBeenDone(ContentUpgradeListener.java:105)
at com.bea.content.manager.internal.ContentUpgradeListener.postStart(ContentUpgradeListener.java:58)
at weblogic.application.internal.flow.BaseLifecycleFlow$PostStartAction.run(BaseLifecycleFlow.java:209)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.application.internal.flow.BaseLifecycleFlow$BaseAction.invoke(BaseLifecycleFlow.java:95)
at weblogic.application.internal.flow.BaseLifecycleFlow.postStart(BaseLifecycleFlow.java:62)
at weblogic.application.internal.flow.TailLifecycleFlow.activate(TailLifecycleFlow.java:33)
at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:635)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:212)
at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:154)
at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)
at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:181)
at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:358)
at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:52)
at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:186)
at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)
at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)
at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)
at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)
at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:181)


Can you guys please put some light on the same..

Thanks in Advance!!
13 years ago
Hi Rahul,

Just wanted to one thing which is not clear from the example :

-The method changeJVMEncoding(Subject subject).

As i can see that the method is creating a anonymous inner class and declaring the method run, it is protecting the System.setProperty() method by using the JAAS framework.
Just wanted to ask that is there a way by which i can protect the System.setProperty() method itself instead of putting it in an authenticated wrapper?
Does JAAS provide something of this sort?
14 years ago
Hi,

One more theory (obviously mine ) says that java compiler cannot check what is stored inside a variable. Thus the compiler doesn't know the meaning of true or false. It even doesn't know the meaning of 1's and 2's that we assign to integers in our code.

Moreover, if it were able to know, then there would'nt have been a need to develop a java runtime (what we call the 'java.exe').

Thus, if there is any logical branching going on inside a code, it will entirely depend on the code that the unreachable code error is thrown or not.

for example : (code written by myself)



This code will surely give unreachable code error.
Its because two times, you have called the run method yourself and once it will be called by the thread you have created

Regards.
Hi,

The object which obj variable references has no link with the one that c1 used to refer to after the execution of the line :

obj = new C();

Thus, the answer would surely be 1 which is the object reffered to by c2.

Regards.
but we can't compare a non wrapper with a primitive
In java 1.5, yes we can compare an object and a primitive