Skip to main content

Java Web Start Client with -javaagent option

12 replies [Last post]
anaq
Offline
Joined: 2006-04-04

Dear all,

is there any way, how to specify the javaagent for web started swing client? I use toplink-essentials-agent, because I need manytoone lazy relations. I know, that JNLP file doesn't support this option in java-vm-args. I have an enterprise application with ejb module and swing client developed in netbeans 6.7.1, running on Glassfish 2.1.1, JDK6, JavaEE 5, Win XP and Ubuntu. When I run the client from Netbeans (there is -javaagent option in VM args), everything works, but outside Netbeans throws the client by saving an entity such an exception like it hasn't javaagent defined.

Can anybody help me?

Thank you

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
anaq
Offline
Joined: 2006-04-04

I think this is a new problem for a new thread... The original one was resolved. Please reply into the new thread.

Thank you

anaq
Offline
Joined: 2006-04-04

So I have found a solution - kick off toplink and use eclipselink :) I've moved my app to eclipselink and the many to one lazy entites don't throw the exception any more...

But there is another problem. Now it works good on localhost (running client from netbeans or browser usin JWS). But runnig the client remotly from another computer has some problems. Entities with manytoone lazy are returned to server empty - all attributes are null. When I set the manytoone relation to eager, the returning object is correct...

When I set the static weaving, reading an entity with manytoone lazy fails on this ex:

Exception [EclipseLink-70] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.DescriptorException
Exception Description: A NullPointerException was thrown while extracting a value through the method [_persistence_getentity_vh] in the object [org.database.OtherEntity].
Internal Exception: java.lang.NullPointerException
Mapping: org.eclipse.persistence.mappings.OneToOneMapping[entity]
Descriptor: RelationalDescriptor(org.database.OtherEntity --> [DatabaseTable(otherentity)])
...

Michael

tjquinn
Offline
Joined: 2005-03-30

Good to hear that EclipseLink is working for you!

Your latest question sounds more like a persistence question than an ACC one. I'm going to get some of the persistence engineers involved in this thread; they'll know much more than I do about this.

- Tim

mm110999
Offline
Joined: 2005-03-29

Hi Michael,

Couple of things

1. The exception stack posted above (Posted: Feb 12, 2010 1:38 AM) seems to be coming from the server side and not from the appclient side. Did you have your persistsence.xml set up for static weaving? If yes, you will need to statically weave your Entity classes before packaging them into .ear

2.
> Entities with manytoone lazy are returned to server empty - all attributes are null.
Are you trying to get the entities from appclient to server? Do you really get all* attributes of the entities (not only the relationship attribute) as null?

If you are indicating static weaving please make sure to weave your entities before packaging them.

anaq
Offline
Joined: 2006-04-04

Hi,
thank you for reply.

To the first point - you're right, I haven't weaved the classes, only setted it in persistence.xml. At this time I have some troubles with setting the static weaving correctly for my project. Hopeful I will be able to use dynamic weaving :)

To the second point - I'm sending the entities to server by save. When I've tried to save a modified entity with manytoone lazy relation, a new one with all attributes null has been created. So I've debugged the server side - the entity returned from client has had all attributes null (for example name, number,...), not only the relationship attribute.

This is happening only when I run the client from URL with IP address (also from the "server" computer when not using URL with localhost). When I run the client from URL with locahost, saving an entity works correctly. Is there any configuration in Glassfish, which can affect this? I tried to set the orb-listener-1 to the IP address, but this didn't help.

Michael

Message was edited by: anaq

anaq
Offline
Joined: 2006-04-04

One more thing...

I have the
in the persitance.xml in my ejb project. I tried to set it to static, but then I got oracle.toplink.essentials.exceptions.IntegrityException when starting the application client.

Michael

tjquinn
Offline
Joined: 2005-03-30

I assume you are not using the built-in automatic support in GlassFish for launching Java EE app clients using Java Web Start. (Such an app client should get this support automatically.)

If so this is really a Java Web Start question as opposed to a GlassFish question.

Having said that...

My understanding is that, starting with some release of Java SE 6 (I don't recall exactly which one but it was a while ago), you could specify a javaagent in the java-vm-args setting in the JNLP. But because that is a potential security issue Java Web Start would not honor that setting unless

1. You included an exact copy of the launching JNLP in the main application's JAR file, and
2. The main application's JAR file was signed.
3. The JNLP specified all permissions in the security setting.

I have not seen this in official documentation anywhere and I have never tried it myself, but in private correspondence with a Java Web Start engineering this is what I was told.

Maybe that will help?

- Tim

anaq
Offline
Joined: 2006-04-04

Thank you for reply.

Actually I use the build-in support for launching Java EE app clients. I deploy only .ear file with client module and then launch the client from URL, JNLP is generated automatically by Glassfish. If there is such a support, I'm doing something wrong... Any idea what should be wrong? Where should I set the javaagent?

Michael

tjquinn
Offline
Joined: 2005-03-30

Hi, Michael.

Hmm. The built-in support should do the work for you; you should not need to specify -javaagent. If I understand correctly, that's needed only if you are launching a Java SE application that uses TopLink Essentials.

So, the bottom line is that you should not need to set the javaagent yourself in this case and the TLE weaving should just work. But what you're saying is that it's not.

Can you try this: Deploy the EAR using

asadmin deploy --retreive localdir (yourapp).ear

Then launch the client using

appclient -client localdir/(yourapp)Client.jar

(and add to the end of that command any arguments that your client expects).

If that works then we need to look at the GlassFish/Java Web Start environment. If that does not work then we need to understand why.

- Tim

anaq
Offline
Joined: 2006-04-04

I've deployed the ear with the command you wrote. Then I've runned the client with

appclient -client local_path/EnterpriseApplicationClient.jar -name client_name -javaagent:D:\toplink-essentials-agent.jar.

This doesn't help me. I've got the same toplink exception. I think such an command uses Netbeans for launching the app client, so I don't understand, why it works in Netbeans and not from the command line.

There are 3 client jars - Client.jar and ClientClient.jar in client_project/dist and EnterpriseApplicationClient.jar in enterprise_app_project/dist. The only one, which can I run, is the last one from enterprise_app_project/dist dir. Client.jar and ClientClient.jar failed, because it cannot find the classed from ejb project, setting classpath doesn't help.I hope, this is correct...

One more thing - I found out, that the client runs correctly only if I run it from Netbeans directly from client_project. The client runned from EnterpriseApp project has the same problem with toplink... Both projects have VM options javaagent defined.

Michael

tjquinn
Offline
Joined: 2005-03-30

A few things...

1. The -javaagent option will be ignored. The appclient script treats everything after the -client (clientJar) option as an argument to pass to the client itself, not to be interpreted by the java command.

2. You should not need to specify the agent in any way when using the GlassFish appclient command. If I understand correctly, the TopLink Essentials agent is useful for Java SE clients. You are launching a Java EE client, and the app client container's class loader knows how to work with TLE to accomplish the same thing as the -javaagent setting does for Java SE clients.

After you deployed the EAR with the asadmin command and retrieved the required JAR file, launching the client using the appclient command I suggested should have worked. Can you post the output from your attempt to run? You mentioned a TopLink Essentials exception but didn't post it.

Thanks.

- Tim

anaq
Offline
Joined: 2006-04-04

Yes I know, I have looked into appclient specification and I have tried more combinations, but with no effect... I can run the client but it throws the same toplink ex (it's appended).

As I wrote, the client can be runned from the whole enterprise project or only client project. Running from the enterprise project means, I launch subcomponent of the enterprise app. URL: localhost:8080/EnterpriseApp/Client. This thorws the toplink ex , but everthing other works good.

When I run it from client project, the client is deployed as an application client module (before doing this there was no app client module, only enterprise app) URL: localhost:8080/Client. Running the client directly with this URL from browser thorws exception as if it cannot find the ejb jar (cassnotfound ex on my sesion bean) - the same one, which was thrown by my attempt to launch the Client.jar or ClientClient.jar. I don't know how netbeans runs this client without this exception...

I think the toplink exception has somethink with the javaagent, because I get the same exception, when I remove the -javaagent option from client project.

Hopeful are this infos helpful.

The exception from toplink by save (call em.merge(entity) in sessionbean) is:

EJB5018: An exception was thrown during an ejb invocation on [SessionBean]
javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:3903)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3803)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3605)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1388)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1325)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:210)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
at $Proxy99.save(Unknown Source)
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:154)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:1088)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
Caused by: Exception [TOPLINK-99] (Oracle TopLink Essentials - 2.1 (Build b31g-fcs (10/19/2009))): oracle.toplink.essentials.exceptions.DescriptorException
Exception Description: The method [_toplink_getentity_vh] on the object [org.database.OtherEntity] triggered an exception.
Internal Exception: java.lang.reflect.InvocationTargetException
Target Invocation Exception: java.lang.NullPointerException
Mapping: oracle.toplink.essentials.mappings.OneToOneMapping[entity]
Descriptor: RelationalDescriptor(org.database.OtherEntity --> [DatabaseTable(OtherEntity)])
at oracle.toplink.essentials.exceptions.DescriptorException.targetInvocationWhileGettingValueThruMethodAccessor(DescriptorException.java:1598)
at oracle.toplink.essentials.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:98)
at oracle.toplink.essentials.mappings.DatabaseMapping.getAttributeValueFromObject(DatabaseMapping.java:372)
at oracle.toplink.essentials.mappings.ForeignReferenceMapping.getAttributeValueFromObject(ForeignReferenceMapping.java:322)
at oracle.toplink.essentials.mappings.ForeignReferenceMapping.isAttributeValueInstantiated(ForeignReferenceMapping.java:518)
at oracle.toplink.essentials.mappings.ObjectReferenceMapping.mergeIntoObject(ObjectReferenceMapping.java:358)
at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.mergeIntoObject(ObjectBuilder.java:2152)
at oracle.toplink.essentials.internal.sessions.MergeManager.mergeChangesOfCloneIntoWorkingCopy(MergeManager.java:442)
at oracle.toplink.essentials.internal.sessions.MergeManager.mergeChanges(MergeManager.java:264)
at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.mergeCloneWithReferences(UnitOfWorkImpl.java:2734)
at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.mergeCloneWithReferences(RepeatableWriteUnitOfWork.java:311)
at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.mergeInternal(EntityManagerImpl.java:251)
at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerImpl.merge(EntityManagerImpl.java:128)
at com.sun.enterprise.util.EntityManagerWrapper.merge(EntityManagerWrapper.java:476)
at org.sesessionbean.SessionBean.save(SessionBean.java:561)
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.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1011)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:175)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2929)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:4020)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:203)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor254.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at oracle.toplink.essentials.internal.security.PrivilegedAccessHelper.invokeMethod(PrivilegedAccessHelper.java:322)
at oracle.toplink.essentials.internal.descriptors.MethodAttributeAccessor.getAttributeValueFromObject(MethodAttributeAccessor.java:91)
... 39 more
Caused by: java.lang.NullPointerException
at org.database.OtherEntity._toplink_getentity_vh(OtherEntity.java)
... 44 more