Juan Handal

Greenhorn
+ Follow
since Jan 25, 2005
Merit badge: grant badges
For More
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 Juan Handal

Robin ,awesome book

i wonder why they didnt include Chrome in honeycomb? where its already included in Google Tv that is based on Android.


Mobile Firefox is more html5 compatible. I checked on that page. Seems like Windows Phone is worse than Android. Low Html5 compatibility has to be a problem for app developers.

12 years ago
Thanks Robin ,superb info !


12 years ago


Congratulations in your new book !!!

Is there a web site of fully/partially supported HTML(5) tags and attributes for various versions of Android ?

Which Browser will the best in your opinion?

Thanks.






12 years ago

Hi Robin,

The support for HTML5(Chrome is OK) in Android Phones and Tablets depends only in the browser,what about the hardware?

Cheers!



12 years ago
Pradeep


Try this example ,just for your question.

Also try EJB 3 Developer Guide by Michael Sikora PACKT press 2008.


http://www.netbeans.org/kb/61/javaee/entappclient.html
Hi

I read this article:


https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#AppClientDef


I think the answer is close but I don't hava a clear picture.


EVERE: exception caught
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at ejb.CC.lookupX(CC.java:34)
at ejb.CC.main(CC.java:27)
Exception in thread "main" java.lang.RuntimeException: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at ejb.CC.lookupX(CC.java:38)
at ejb.CC.main(CC.java:27)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at ejb.CC.lookupX(CC.java:34)
... 1 more
Java Result: 1
BUILD SUCCESSFUL (total time: 11 seconds)

Thanks Jaikiran and Venkatesh

I'm with GlassFish(APPServer 9)That comes bundled whit

Netbeans 5.5.1.

I tried @Stateless(name="XXX")
and the lookup("XXX") the same error.

As you say the jndi.properties have something to do whit the error.

I'm running Btest.java(Where lookup() is ) as a console application,

but inside the IDE and in the same ejb directory of the Stateless Bean.

This a stand-alone client a POJO BTest.java trying a lookup() in
the Session Bean BBean.java the error is :
javax.naming.NoInitialContextException.
I need to fix the JNDI lookup()


A project
|
|
A-ejb
|
|
Source Packages
|
|
ejb
|
BBean.java
BRemote.java
BTest.java
Right click ejb New------>File/Folder----------->Java Classes-------->Java Main Class

Creates a new Java class with a main method permitting it to be run as a console
application.

The Remote interface(I tried also with Local interface ,same result) :

package ejb;

import javax.ejb.Remote;
public interface BRemote{ }






The Session Bean :

package ejb;
import javax.ejb.Stateless;
@Stateless(name="X")
public class BBean implements ejb.Remote{
public BBean(){ }
}



Is a useless Bean ,but my point is to try the Context with BTest.java







OK this Btest is a POJO so i can not use Direct Injection,I will try l to get the Context.

package ejb;
import java.util.loggin.Level;
import java.util.loggin.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class BTest{
public BTest(){ }
public static void main(String [] args){

BTest cc=new BTest();
BRemote dd=(BRemote)cc.lookupX();
}
private BRemote lookupX(){
try{
Context c=new InitialContext();
return (ejb.BRemote)c.lookup("java:comp/env/ejb/"X");
}catch(NamingException ne){

Logger.getLogger(getClass().getName().log(Level.SEVERE,"exception caught",ne);
throw new RuntimeException(ne);
}


}end of class





Then I deployed A project OK no problem
I go to Run File (Shift +F6) :Run BTest.java

I got:
ejb.cc lookupX

Severe: exception caught

javax.naming.NoInitialException


This lookupX() was generated by the IDE
right click in the BTest{} class-------Enterprise Resources--->Call Enterprise Bean

How can I get it right with Netbeans?

The tutorial is great and works,but in this simple code not.

Thanks.




Hi Dario I'm using netbeans 5.5.1 & java 6.

This is the error log:

init:
deps-jar:
compile-single:
run-main:
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.InitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.InitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.<init>(InitialContext.java:197)
at ejb.TestAdios.main(TestAdios.java:26)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.InitContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
... 4 more
Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)

I've got tis information:

If you want to use a no-arg InitialContexr()

you need to put a "jndi.properties" file in your app client.

In my server GlassFish that file is empty.

(jndi.properties is inside $glassfish.home/lib/appserv-rt.jar)

I'm trying to set the jndi properties inside appserv-rt.jar so them

will be picked up.........


Application Server > Resources > JNDI > Custom Resources > Beta

Edit Custom Resource
Edit an existing JNDI custom resource.

Indicates required field
JNDI Name:Alpha

A unique identifier; contain only alphanumeric, underscore, dash, or dot characters
Resource Type:

Enter a fully qualified type; Resource Type definition follows the format xxx.xxx
Factory Class:

Factory class for resource; implements javax.naming.spi.ObjectFactory
Description:
Status: Enabled



Additional Properties (0)
Name Value
No properties found. Click "Add Property" above to add a property.


Finally

This is an EJB proyect(not WEB component)

src/Source Packages/ejb

In ejb packeges there is the SessionBean ,the remote interface(I tried

the local interface also) and the POJO wlth the main(String [] args){

trying ic.lookup(("Alpha")

The problem is that maybe netbeans is already setup for the InitialContext and not allow POJOs to lookup()?

Thanks


Hi
Please I need help with NetBeans ,running GlassFish & EJB3.


The Remote Interface:


package ejb;
import javax.ejb.Remote;

/**
* This is the business interface for AdiosNY enterprise bean.
*/
@Remote
public interface AdiosNYRemote {
public String Mensaje();


}






The Stateless Bean:


AdiosNYBean.java
*
* Created on May 26, 2007, 4:20 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ejb;
import javax.ejb.Stateless;
/**
*
* @author HANDAL
*/
@Stateless(mappedName="Alpha")
public class AdiosNYBean implements ejb.AdiosNYRemote {
public String Mensaje(){
System.out.println("Viva el Peru");
return "Peru tierra de Heroes";

}

/** Creates a new instance of AdiosNYBean */
public AdiosNYBean() {
}

}





The POJO trying to get the Context:



/*
* TestAdios.java
*
* Created on May 26, 2007, 4:27 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ejb;
import java.util.Properties;
import javax.naming.InitialContext;
/**
*
* @author HANDAL
*/
public class TestAdios {


/** Creates a new instance of TestAdios */
public TestAdios() {
}
public static void main(String [] args)throws Exception{
Properties props=new Properties();

props.setProperty("java.naming.factory.initial","com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs","com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state","com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
InitialContext ic=new InitialContext(props);
AdiosNYRemote ad=(AdiosNYRemote)ic.lookup("Alpha");


}

}






init:
deps-jar:
compile-single:
run-main:
Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.init(InitialContext.java:223)
at javax.naming.InitialContext.(InitialContext.java:197)
at ejb.TestAdios.main(TestAdios.java:31)
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.java:46)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:654)
... 4 more
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


Hi Dave

You are right.I'm trying to get the right one setProperty:

Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"com.sun.enterprise.naming.SerialInitContextFactory");
props.setProperty("java.naming.factory.url.pkgs",
"com.sun.enterprise.naming");
props.setProperty("java.naming.factory.state",
"com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");

// optional. Defaults to localhost. Only needed if web server is running
// on a different host than the appserver
props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");

// optional. Defaults to 3700. Only needed if target orb port is not 3700.
props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");

InitialContext ic = new InitialContext(props);

Where can I get the appservrt.jar's jndi to look the right property?

I'm using netbeans 5.5 & GlassFish

Thanks a lot.



Hi

I'm using GlassFish &NetBeans 5.5,no problems at all but

when it comes to a SessionBean(that is the name of the Session Bean) with only one method public String Hello(){return "HelloWorld";}

I tried the standalone client java class accessing public String Hello(){} ,but I can not get the Context.

class Test{

public static void main(String [] args)throws NamingException{
Context ctx=new InitialContext();
SessionBeanLocal hello=SessionBeanLocal)ctx.lookup("ejb/SessionBean");
System.out.println(hello.Hello() );
}
}


I got NoContextException ,both the SessionBean ,SessionBeanLocal& class Test are in the same

ejb directory.The problem is the lookup("What is the right JNDI name in here ???")

I'd appreciate any help.

JHandal


I'll take the EJB 3 exam,I.m in Brooklyn .

Trying to start a study group.
Rashid

I suggest to send this post to nbj2ee.com

is all about netbeans 5.5

or netbeans.org