Skip to main content

Deploy Problems

14 replies [Last post]
dsmith9094
Offline
Joined: 2007-07-30

Hi,

I'm having big problems trying to deploy a client/server application. Here's the software I'm using:

- java 1.6
- Netbeans 5.5.1
- Sun Application Server 9.x (bundled with Netbeans)
- DB2 V9.x

The client application has a GUI-client, no webpages.
The server side has the ejb-beans, session beans, persistence layer, etc.

In order to keep compile and deploy time at a minimum, the sourcecode has been separated in smaller (Netbeans) projects:

- app-client (Main class that shows a JFrame)
- 2 other client projects with GUI-Dialogs that get called thru class loader
- base (remote interfaces and business classes that do lookups to facades (session beans) thru remote interfaces and calls to facade functions)
- ejb (server side, here are all the session beans, ejb-beans, local interfaces, persistence layer and db-schema)
- utility projects on the server side for math-logic and business logic

Here's what works:
- All the projects have been created thru Netbeans
- These projects can be deployed to a local Sun Application Server using Netbeans
- The app-client can be started and/or debugged and all calls to the remote interfaces work
- The server-facades are called thru remote interfaces, using lookup and initialcontext

Here's what doesnt work:
- The projects can be deployed to a remote Sun AS server, but when started, the app-client cant find the server facades

I'm trying to use Netbeans for development and debugging on a local Sun AS Server,
and at the same time I want to deploy an .ear file to a remote Sun AS Server and run the app-client with java web start.
I've added a .jnlp file to the .ear file.

My problem:
I dont know which descriptor/deployment files i need, and which projects need them.
I'm getting name lookup errors when the app-client tries to access the facades.
From what I've seen its no wonder, because i havent told the app-client where to look for the server.

I've looked in different forums, and found plenty of articles. I've tried all solutions,
but they dont seem to work with my project configuration. I've tried all kinds of different "hello world" programs.
(The "sless" program works as is.) The hello programs work, but as soon as i try to expand them to more than two projects,
I get lookup errors. I've looked at the Sun Docs, read all about sun-ejb-jar (and cohorts).
Netbeans puts some of these .xml files into some of the projects. I've looked in these files, but I don't know if
they're needed or if some are still missing.

I'm at a total loss, and I don't know where to go from here. Is my project configuration so complicated?

My "base" project is THE PROJECT that all other projects have to link to.
The "base" project has the remote interface calls (hidden) in business classes. I want all client-apps to use these
business classes if they want to access server-data.

My question:
Considering my project configuration, which projects need which deployment files?
Which projects have to be application or ejb modules and which can be simple java projects?
Most important, is it possible to use this project configuration, or do I have to change something?

Danny.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
dsmith9094
Offline
Joined: 2007-07-30

Hi,

First of all, many thanks to Tim and vbk for the prompt answers.

We discussed the answers in our shop and they cleared up some issues
and opened others.

We decided to make a 3 project application to try the alternatives
mentioned in your answers. First off, I threw our .jnlp file as far
away as my baseball arm allowed. Second, all unnecessary code was
thrown out. I'll append the source code and NB projects to this post.

Here's how we made the projects:

- AEV-app-client (client, main class, calls a class method in "base")
- AEV-base (has the remote interface, and the class that calls the facade)
- AEV-ejb (server, has the facade that is being called)

In this constellation, the appclient does not run correctly in NetBeans,
per jawaws (from the admin console) or per appclient script.
I'll append the .ear file to this post. The "MenueFacade" is null,
no matter how the application is run.

The application was compiled with Netbeans. After compiling the .ear,
the application was verified and deployed thru the asadmin command-line.

First, the output from the verify tool:

======================================================================
D:\Sun\AppServer\bin>verifier.bat AEV.ear
WARNUNG: DPL5400:Exception occurred : error in opening zip file.
INFO: Verifying: [ AEV.ear ]
INFO: Verifying: [ AEV-ejb_jar ]
INFO: Verifying: [ AEV-app-client_jar ]
INFO: Verifying: [ AEV-base_jar ]
INFO:
# of Failures : 0
# of Warnings : 0
# of Errors : 0
INFO: No errors found in the archive.
======================================================================

It seems that the verification is ok. Now, to deploy the app.
Here's the server.log output from the deploy:

======================================================================
[#|2007-08-01T17:02:13.620+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.admin|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;D:\Temp\s1astempdomain1server-867388250\AEV.ear;|ADM1064:The upload file at [D:\Temp\s1astempdomain1server-867388250\AEV.ear] exists and will be overwritten.|#]

[#|2007-08-01T17:02:13.636+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.admin|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;D:\Temp\s1astempdomain1server-867388250\AEV.ear;|ADM1006:Uploading the file to:[D:\Temp\s1astempdomain1server-867388250\AEV.ear]|#]

[#|2007-08-01T17:02:14.432+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.core.classloading|_ThreadID=17;_ThreadName=Thread-35;|LDR5202:Exception in EJBClassLoader
java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.canonicalize0(Native Method)
at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:396)
at java.io.File.getCanonicalPath(File.java:559)
at com.sun.enterprise.loader.EJBClassLoader$1.run(EJBClassLoader.java:418)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.enterprise.loader.EJBClassLoader.findResource0(EJBClassLoader.java:391)
at com.sun.enterprise.loader.EJBClassLoader.findResource(EJBClassLoader.java:467)
at java.lang.ClassLoader.getResource(ClassLoader.java:977)
at java.lang.ClassLoader.getResource(ClassLoader.java:972)
at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1159)
at com.sun.enterprise.loader.EJBClassLoader.getResourceAsStream(EJBClassLoader.java:782)
at com.sun.xml.rpc.spi.JaxRpcObjectFactory.newInstance(JaxRpcObjectFactory.java:131)
at com.sun.enterprise.webservice.codegen.JaxRpcRICodegen.(JaxRpcRICodegen.java:120)
at com.sun.enterprise.webservice.codegen.JaxRpcCodegenFactory.getAdapter(JaxRpcCodegenFactory.java:50)
at com.sun.ejb.codegen.IASEJBC.doCompile(IASEJBC.java:839)
at com.sun.ejb.codegen.IASEJBC.ejbc(IASEJBC.java:580)
at com.sun.enterprise.deployment.backend.EJBCompiler.preDeployApp(EJBCompiler.java:339)
at com.sun.enterprise.deployment.backend.EJBCompiler.compile(EJBCompiler.java:222)
at com.sun.enterprise.deployment.backend.AppDeployer.runEJBC(AppDeployer.java:359)
at com.sun.enterprise.deployment.backend.AppDeployer.deploy(AppDeployer.java:214)
at com.sun.enterprise.deployment.backend.AppDeployer.doRequestFinish(AppDeployer.java:129)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)
|#]

[#|2007-08-01T17:02:14.666+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=17;_ThreadName=Thread-35;|deployed with moduleid = AEV|#]

[#|2007-08-01T17:02:14.900+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.container.ejb|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;|**RemoteBusinessJndiName: MenueFacade; remoteBusIntf: remote.MenueFacadeRemote|#]

[#|2007-08-01T17:02:14.931+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.core.classloading|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;AEV;|LDR5010: All ejb(s) of [AEV] loaded successfully!|#]

[#|2007-08-01T17:02:15.056+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;|Registering ad hoc servlet: WebPathPath: context root = "/AEV", path = "/AEV-base'|#]

[#|2007-08-01T17:02:15.087+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;|Registering ad hoc servlet: WebPathPath: context root = "/AEV", path = "/AEV-app-client'|#]

[#|2007-08-01T17:02:15.087+0200|INFO|sun-appserver-pe9.0|javax.enterprise.system.tools.deployment|_ThreadID=14;_ThreadName=httpWorkerThread-4848-0;|Java Web Start services started for application com.sun.enterprise.appclient.jws.ApplicationContentOrigin@13da08 registration name=AEV
com.sun.enterprise.appclient.jws.NestedAppclientContentOrigin@14f6d51 registration name=AEV, context root=/AEV/AEV-base, module name=
, parent=AEV
com.sun.enterprise.appclient.jws.NestedAppclientContentOrigin@191ebc5 registration name=AEV, context root=/AEV/AEV-app-client, module name=
, parent=AEV|#]
======================================================================

From what I see in the server.log, the deployment was ok. As a verification,
I checked what NetBeans and the web-admin-console shows. Everything ok.

Now, when I run the application, an exception is thrown because the
menueFacade is null.

Please help, I'm pretty frustrated that I cant get a small "hello
world" with 3 projects to work.

Danny.

tjquinn
Offline
Joined: 2005-03-30

Hi, Danny.

At least part of the problem is that the application.xml specifies the AEV-base library as an app client. That's what the element in application.xml means. The element does not mean that the JAR is a library.

Various packaging and class path decisions are driven by the module types, so my first suggestion is to fix that and then see what happens from there. Library JARs should reside at the /lib directory within the EAR or at whatever location in the EAR is specified by the
element in the application.xml descriptor. (The /lib value is the default if none is specified.)

- Tim

P.S. I did not get the IOException when I deployed your EAR on my system, so that looks like either a local issue or perhaps there's a bug exposed by your use of D: as opposed to C:.

added p.s.

Message was edited by: tjquinn

dsmith9094
Offline
Joined: 2007-07-30

Hi Tim,

I changed the AEV-base project to a normal java class library and packaged it into the .ear file under /lib. Also, I added the j2ee.jar in /lib.

No change. The menuFacade is still null.

I'm appending the changed files to this post.

Danny.

tjquinn
Offline
Joined: 2005-03-30

Hi, Danny.

With your latest attachment, deployment works fine and the app client seems to work fine as well. I get a dialog box listing the call stack with this as the top few frames:

DomainModel.Menue.getString(Menue.java:29)
aev.Main.main(Main.java:32)

I am using a very recent build of GlassFish V2. I noticed you are using Sun Java System Application Server 9.0.

Would you be able to try with a recent build of GF V2 to see if the problem persists in your environment with the newer build? Is using a newer build routinely an option for you?

- Tim

dsmith9094
Offline
Joined: 2007-07-30

Hi Tim,

Thanks again for your prompt response.

I'm glad to see that the app deploys on your system and runs with the same result as on my system. Now, we both have the same version of the app giving the same error on my Sun AS 9.0 and your GF V2.

The dialog box that you're getting is the stack trace that I print out when I catch the exception thrown when the menueFacade is null. The app should be showing a dialog box with "hello world" when everything works right.

The big question is: why is the facade null? Is this a classpath problem? Do I need any deployment descriptors?

A short description of the app:
In main, I create an instance of the class Menue. Then I call a method of the class Menue (getString) that returns a string (which should be "hello world") and show it in a dialog box.

The method Menue.getString() calls a method (thru a remote interface) of the facade MenueFacade (getString). This is where the error is. The variable menueFacade is an instance of the remote interface with the @EJB annotation.
This variable is null. I'm assuming that the EJB injection didn't work. Here is where I don't know what to do to get the injection to work.

Danny.

P.S.
Our project is still in the development phase, so we will be checking for newer stable releases of Sun AS. The reason we're not using GF versions is because we have to use the same version in development that will be used in production. In a later phase, the customer will install Sun AS in his system and we will have a harder time updating to newer releases. The customer will have a support contract for Sun AS.

tjquinn
Offline
Joined: 2005-03-30

Hi, Danny.

OK, I'm embarrassed to say that I should have thought of this before.

The problem is that in app clients the Java EE spec calls for injection to be supported only on the client's main class, and only on static elements. Because the @EJB annotation is on an element in a class other than the main class when run in the context of the client, the client-side injection handling does not deal with it.

I tried the following and it worked for me while preserving what I think is your general design approach.

1. I added this new constructor to Menue:

public Menue(MenueFacadeRemote facade) {
menueFacade = facade;
}

2. I added this declaration to the app client's Main class:

@EJB (name="MenueFacade")
private static MenueFacadeRemote menueFacade;

(It is the same as the declaration in Menue except this one is static, as required by the Java EE spec to support injection.)

3. I changed the line in the client main method to instantiate the Menue to be this:

Menue aMenue = new Menue(menueFacade);

This displayed the Hello World dialog box successfully.

This approach is a little messy, but it does resolve the problem.

Please let us know if this works for you as well.

- Tim

dsmith9094
Offline
Joined: 2007-07-30

Hi Tim,

This solution sounds great! I haven't tried it yet, but from what you suggest, it should work on my system.

I'll get on this right away on Monday morning and give you feedback.

My steps:
1. Try it 1:1. If all works, do the next steps.
2. Put a static variable for the remote interface in the Menue class.
3. From the main class, fill the static variable in the Menue class.

The reason I want to try using a static variable is because the Menue class is representative of the many different ejb beans that will be read/written from our DB2 database. We have 23 different beans at the moment, but by the time the project is finished, we'll have about 100 beans. Some beans will be instantiated in the 1000's. Another reason is that our main class goes into a loop, showing a Dialog. So i have to send these 23 (later on 100) interfaces to the classes before showing the dialog.

Thanks in advance. I'll let you know of my results.

Danny.

tjquinn
Offline
Joined: 2005-03-30

Hi, again, Danny.

I'm glad it sounds like this approach will work for you. I see your point about using a private static variable for the remote I/F. If I understand what you meant it sounds like it makes sense. (I had just hacked something to make sure it would work before I pointed you in that direction!)

I'll be eager to hear your results. (I will be out of the office most of next week so do not mistake silence for lack of interest.)

One small piece of (unsolicited) advice - and you may already plan this. If you will have a lot of initialization work to be done, consider doing it in a separate thread from your main client thread, perhaps displaying a "Working..." progress bar or something like that as the init code runs. Users tend to prefer this to having the U/I simply stall while the warm-up occurs; to them, nothing seems to be happening.

(I am not a U/I expert but as a user I have encountered plenty of software from teams that apparently did not have one on staff!)

- Tim

dsmith9094
Offline
Joined: 2007-07-30

Hi Tim,

I tried your latest solution, and it works! Many thanks.

I still have a problem, though. I can deploy the application through an .ear, and can start it with web start and it shows my "hello world".

What I can't do is debug the application through NetBeans. This is a very important objective for me and a no-win solution until this is resolved. I suppose this is not the right forum for NetBeans, so I'm setting this post to "answered". Maybe you or someone else knows of a good forum for NetBeans in conjunction with EJB 3.0 beans and Sun AS.

I'm uploading the final .ear and NetBeans project files. Maybe this 3-project solution can help someone else in the future. The projects don't use any special jars or ressources, so they'll run on any system. I deployed on WinXP, Win2003 Server and SuSE Linux Enterprise Server V10. It worked everywhere.

Danny.

P.S.
Thank you for all your prompt and professional responses. They helped me to understand EJB-Injection a bit more. By the way, that is where my problem with debugging is. I get this stack trace when i try to debug the app-client (debugging the single project, not the .ear):

06.08.2007 17:14:41 com.sun.enterprise.appclient.MainWithModuleSupport
WARNUNG: ACC003: Application threw an exception.
com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref MenueFacade@jndi: remote.MenueFacadeRemote@null@remote.MenueFacadeRemote@Session@null into class aev.Main
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:373)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:193)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:131)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:123)
at com.sun.enterprise.appclient.MainWithModuleSupport.(MainWithModuleSupport.java:325)
at com.sun.enterprise.appclient.Main.main(Main.java:180)
Caused by: javax.naming.NameNotFoundException: remote.MenueFacadeRemote#remote.MenueFacadeRemote not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:203)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:175)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:61)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
Exception in thread "main" java.lang.RuntimeException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref MenueFacade@jndi: remote.MenueFacadeRemote@null@remote.MenueFacadeRemote@Session@null into class aev.Main
at com.sun.enterprise.appclient.MainWithModuleSupport.(MainWithModuleSupport.java:364)
at com.sun.enterprise.appclient.Main.main(Main.java:180)
Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref MenueFacade@jndi: remote.MenueFacadeRemote@null@remote.MenueFacadeRemote@Session@null into class aev.Main
at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:373)
at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:193)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:131)
at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:123)
at com.sun.enterprise.appclient.MainWithModuleSupport.(MainWithModuleSupport.java:325)
... 1 more
Caused by: javax.naming.NameNotFoundException: remote.MenueFacadeRemote#remote.MenueFacadeRemote not found
at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:203)
at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:175)
at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:61)
at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:116)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
Java Result: 1

Hong Zhang

Hi, Danny
(Tim is on vacation this week).

W.r.t netbeans alias:
To send feedback, get support, and receive updates and information
about J2EE development support in NetBeans, subscribe to
*nbj2ee@netbeans.org*. You can subscribe to the mailing list by sending
a blank email to nbj2ee-subscribe@netbeans.org
. You can also send questions and
feedback to nbusers@netbeans.org .

Debugging glassfish with netbeans is similar as debugging with
other debugger:
1. For glassfish server side debugging, enable the "debug-enabled"
attribute in the GF_INSTALL/domains/domain1/config/domain.xml (you can
customize the port):
debug-enabled="true" debug-options="-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=9009"
rmic-options="-iiop -poa -alwaysgenerate -keepgenerated -g"
javac-options="-g"
system-classpath="${com.sun.aas.installRoot}/lib/appserv-launch.jar"
classpath-suffix="" env-classpath-ignored="true">

2. For glassfish appclient side debugging, the appclient script in
located in the GF_INSTALL/bin directory, add the following debug option
to the java command of the script (you can customize the port):
"-Xdebug
-Xrunjdwp:transport=dt_socket,address=5678,server=y,suspend=y"

And then have the debugger attach to the corresponding port.

Thanks,

- Hong

glassfish@javadesktop.org wrote:

>Hi Tim,
>
>I tried your latest solution, and it works! Many thanks.
>
>I still have a problem, though. I can deploy the application through an .ear, and can start it with web start and it shows my "hello world".
>
>What I can't do is debug the application through NetBeans. This is a very important objective for me and a no-win solution until this is resolved. I suppose this is not the right forum for NetBeans, so I'm setting this post to "answered". Maybe you or someone else knows of a good forum for NetBeans in conjunction with EJB 3.0 beans and Sun AS.
>
>I'm uploading the final .ear and NetBeans project files. Maybe this 3-project solution can help someone else in the future. The projects don't use any special jars or ressources, so they'll run on any system. I deployed on WinXP, Win2003 Server and SuSE Linux Enterprise Server V10. It worked everywhere.
>
>Danny.
>
>P.S.
>Thank you for all your prompt and professional responses. They helped me to understand EJB-Injection a bit more. By the way, that is where my problem with debugging is. I get this stack trace when i try to debug the app-client (debugging the single project, not the .ear):
>
>06.08.2007 17:14:41 com.sun.enterprise.appclient.MainWithModuleSupport
>WARNUNG: ACC003: Application threw an exception.
>com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref MenueFacade@jndi: remote.MenueFacadeRemote@null@remote.MenueFacadeRemote@Session@null into class aev.Main
> at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:373)
> at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:193)
> at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:131)
> at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:123)
> at com.sun.enterprise.appclient.MainWithModuleSupport.(MainWithModuleSupport.java:325)
> at com.sun.enterprise.appclient.Main.main(Main.java:180)
>Caused by: javax.naming.NameNotFoundException: remote.MenueFacadeRemote#remote.MenueFacadeRemote not found
> at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:203)
> at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:175)
> at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:61)
> at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:116)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
> at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
> at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
> at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
> at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
> at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
> at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
>Exception in thread "main" java.lang.RuntimeException: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref MenueFacade@jndi: remote.MenueFacadeRemote@null@remote.MenueFacadeRemote@Session@null into class aev.Main
> at com.sun.enterprise.appclient.MainWithModuleSupport.(MainWithModuleSupport.java:364)
> at com.sun.enterprise.appclient.Main.main(Main.java:180)
>Caused by: com.sun.enterprise.InjectionException: Exception attempting to inject Unresolved Ejb-Ref MenueFacade@jndi: remote.MenueFacadeRemote@null@remote.MenueFacadeRemote@Session@null into class aev.Main
> at com.sun.enterprise.util.InjectionManagerImpl._inject(InjectionManagerImpl.java:373)
> at com.sun.enterprise.util.InjectionManagerImpl.inject(InjectionManagerImpl.java:193)
> at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:131)
> at com.sun.enterprise.util.InjectionManagerImpl.injectClass(InjectionManagerImpl.java:123)
> at com.sun.enterprise.appclient.MainWithModuleSupport.(MainWithModuleSupport.java:325)
> ... 1 more
>Caused by: javax.naming.NameNotFoundException: remote.MenueFacadeRemote#remote.MenueFacadeRemote not found
> at com.sun.enterprise.naming.TransientContext.doLookup(TransientContext.java:203)
> at com.sun.enterprise.naming.TransientContext.lookup(TransientContext.java:175)
> at com.sun.enterprise.naming.SerialContextProviderImpl.lookup(SerialContextProviderImpl.java:61)
> at com.sun.enterprise.naming.RemoteSerialContextProviderImpl.lookup(RemoteSerialContextProviderImpl.java:116)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> at java.lang.reflect.Method.invoke(Method.java:597)
> at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
> at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
> at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
> at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
> at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
> at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
> at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
> at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
>Java Result: 1
>[Message sent by forum member 'dsmith9094' (dsmith9094)]
>
>http://forums.java.net/jive/thread.jspa?messageID=229620
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
>For additional commands, e-mail: users-help@glassfish.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

tjquinn
Offline
Joined: 2005-03-30

Hi, again, Danny.

I echo what Hong wrote about the NetBeans aliases.

What happens if you right-click on the EAR application project icon (not the app client single project) and choose Debug Project? Vince might have more light to shed on this, but I can believe that trying to run the client on its own might not establish the rest of the environment - including the EJB the client is trying to look up.

Just a thought.

- Tim

P.S. Using Debug Project will simulate launching the client using the appclient script, not using Java Web Start. In theory the two will behave the same. In practice we have seen cases in which he behavior differs but we consider those cases to be bugs which we address as quickly as we discover them. If Debug Project works and then you see different runtime behavior when you launch using Java Web Start, then be sure to let us know. There are ways to debug any Java Web Start application launch, including app clients. But let's not cross that bridge until we have to!

added P.S.

Message was edited by: tjquinn

dsmith9094
Offline
Joined: 2007-07-30

Hi Hong and Tim,

I've subscribed to the mailing list. Thanks for the address.

I've incorporated the injection solution in our project, which deploys fine now. Funny thing, I only injected the first 3 referenced facades (we have over 20 at the moment), but ALL facades can now be found. The rest are found with lookup().

All of our facade calls are hidden in pojo classes (in our "base" project). The variable for the facade is always static, and each class method that calls a facade method first calls a method that fills the static facade variable (with lookup()) if its null. This has worked since day one in NetBeans (including debugging), but wasn't deployable. When i added the injection into the main class, the debugging didnt work anymore. Hence, the P.S. in the last post.

In the meantime, I've added a second main class that uses injection and fills the static variables for the facades. This main class then calls the original main class (which doesnt use injection). In the app-client single project, the original main class is still being used to run and debug, everything works, but not deployable. In the EAR application, the second main class is used (the one with injection). This way, the application is debuggable with NetBeans and the EAR is deployable.

I know this is only a workaround, but it works. Our project timetable is mean and lean, and we have another milestone coming up (1st week of September). I just installed a Dell Quad-CPU Server with Win2003 Server in Terminal-Server mode, using NetBeans 5.5.1 bundled with Sun AS. All developers are using this server and each developer has his own domain. With this new server, the time for starting/stopping NetBeans is neglible, as is starting/stopping Sun AS. Multi-Domains on one computer with Sun AS / Glassfish work fine.

I would like to make a clean solution for debugging with NetBeans, but my boss doesn't agree. "The workaround works, get to work on more important things!" (quote from my boss).

Thanks for your efforts and time. I really appreciate it,

Danny.

vbkraemer
Offline
Joined: 2003-09-03

I will try to add a little clarity here, too...

1. using the Run item on your project, when it targets a remote server... This is a limitation with the NetBeans Enterprise Application projects that have an app client as the configured Client Module URI in their 'Run' project property and Application Client projects.

I think this is resolved in NB 6.0 builds.. [The Run item is disabled.]

2. Unfortunately, running an application client is much more difficult that we let on. NetBeans does a lot of magic that we don't expose to support the Run item. GlassFish does a lot of magic to enable Java Web Start of application clients that is kept fairly opaque. Tim has a number of blog entries that shed light on the support that are tweakable... The blog is here: http://blogs.sun.com/quinn/

He also published a fairly extensive article http://java.sun.com/developer/technicalArticles/J2EE/jws-glassfish/ about this, too.

I get the impression that you have done something like this...

ear
app-client
ejb-impl
ejb-interfaces

and the client and the ejb-impl have a dependency on the ejb-interfaces jar/project, right?

This seems like a reasonable decomposition. If you have something else, please outline it in a bit more detail.

Thanks and HTH,
vbk

tjquinn
Offline
Joined: 2005-03-30

Hi, Danny.

You posed several questions. Maybe I can help with at least some of them.

First, try to narrow down whether the problem is related to GlassFish itself or with the NetBeans-to-GlassFish interaction. If you build your application using however many NB projects you have, and then use the GlassFish command line or admin GUI to deploy the application, do things then work correctly?

As for using Java Web Start to launch the client... If you are using the support that is built into GlassFish for launching app clients using Java Web Start the JNLP you have added to the EAR will not be used. If you are using your JNLP to try to launch the app client, this may be part of the problem. A true Java EE app client must run in the app client container (ACC). The ACC prepares the environment correctly for the app client and runs automatically if you use the appclient script or launch using the built-in support for Java Web Start. It is not possible - well, at least not supported - for developer-provided JNLP to launch the ACC to run an app client.

It is certainly possible to write your own JNLP to launch a client program (although not a true Java EE application client) that could explicitly look up the server-side components and contact them. But it's much easier to use injection that's available in an actual app client which the ACC takes are of for you.

Does this help some?

- Tim