Flow execution in Ejb project in java - java

Hi am working on very very old projects which contain 10 to 15 dependencies am very curious to know any tool or some utility to track flow execution of java class,method,lines,return type,get query executed while operation ..etc
for example:
if am calling soap request from SoapUI its goes into #WebService() and flow goes on..
How do I trace methods calls in Java? i have seen this link not sure how to incorporate and execute in existing project am doing manual job right now by debug with eclipse.kindly help on if way to write code or tool which i can see executions

JPDA. any decent IDE will connect to your container via JDPA protocol and allow you to debug from inside the container. you have to configure the container using some configuration switches (which get passed onto the JVM at startup time). check the documentation for you app server for how it prefers to be configured for JPDA.

Related

How can i setup end to end code debugging for JBPM application

Project uses bpmn files for handling main part of the flows.Currently i have set up code debugging for java part which this way is useless for bpmn files because hundreds of lines embedded to script tasks iniside bpmns.If i set up debug for bpmns it would be useless for java part.Question is to find some way to setup debugging for both.Thanks
This might depend on the jBPM version but jBPM Eclipse Plugin 6.0 comes with debugging capabilities as explained in 18.2 Debugging, however:
Note that we currently don't allow you to put breakpoints on the nodes within a process directly. You can however put breakpoints inside any Java code you might have (i.e. your application code that is invoking the engine or invoked by the engine, listeners, etc.) or inside rules (that could be evaluated in the context of a process). At these breakpoints, you can then inspect the internal state of all your process instances.
If installing Eclipse plugin is not possible you would have to debug through the Java code of jBPM engine. It's doable, but not pleasant experience.

How add externals .jar to Ibm Integration Bus 10. java compute

I try to create a PDF from an XML using apache fop, i can do it in Netbeans or Eclipse IDE's, but the Java Compute inside the IIB when i try to execute from SOAP UI launch me this java error
java.lang.NoClassDefFoundError: org/apache/fop/apps/FopFactory
java error
but, i already add the necesaires libraries:
libraries added without errors
Here reference is made
libraries referenced
I hope you can help me, thank you all.
It depends on how you want to work, but you simply have to put this jar on the shared-classes.
This folder exist at the execution group (integration server) level, or at the broker (integration node) level. If you plan to reuse it later, I would suggest you to put it at the broker level, otherwise at the execution group level.
Path sample (unix in this case)
/var/mqsi/shared-classes (For all your broker on this VM, NOT recommanded)
/var/mqsi/config/"yourBrokerName"/shared-classes (broker level)
/var/mqsi/config/"yourBrokerName"/"yourExecutionGroupName"/shared-classes (execution group level)
If you put it at the execution group level, the execution group needs to be restarted. If you put it at the broker level, you should restart the whole broker.
Feel free to contact me if you have other questions, but with the shared-classes keyword, you should be able to find everything you are looking for.

Run Java Agent XPage

I try to run an Java Agent in XPage. The Agent runs in the beforePageLoad Event to manipulate the current document.
<xp:this.beforePageLoad><![CDATA[#{javascript:
var agent:NotesAgent =database.getAgent("RedirectGroups")
agent.runWithDocumentContext(currentDocument.getDocument())
}]]></xp:this.beforePageLoad>
For testing the agent prints a simple message to the console.
If I run the XPage in Browser I get an error 500 message. I'm using Notes 9.01 on an Domino 9 Server
Will I have to run the agent in an other event of the XPage?
Well, the first thing you have to realize is that a Java agent runs in a totally different context than the XPage. They are running in two separate JVMs. It is therefore also important to understand that you will NOT have access to any of the classes/resources available to your XPage from your agent.
To run Java code that manipulates your document you would use e.g. managed beans and instead of just having the opening/saving phases of a "traditional" Domino web application you will have the 6 phases in the JSF lifecycle to interact with your data source. This is a better pattern for modifying your data in an XPages application.
When you get an error 500 it means that some logic in the server side has failed (e.g. in a managed bean or some SSJS). The best way to see this is by using the XPages LogReader from openntf.org that will show you the contents of the local files from the server with the error messages (and stack trace).
You can find valuable info about how to use Java in XPages via a number of NotesIn9 video sequences.
The agent has to have
Security option "Run as Web user" set
as Target "None"
As the agent might run with this options it's not good practice to call a Java agent in an XPage. Better call/use the Java code direct in your XPage.

How to build a command line interface in java for an existing web based application

I have created a web based application using JSP and Servlets and the application uses an SQL Server DB as its backend.
The architecture is like this:
I have all my business logic in a jar file
I have created my views using JSPs and am using servlets to interact with my business logic jar
The jar connects to the database to persist and hydrate information, which is relayed to the JSP by my servlets.
My web application runs on a remote Tomcat server.
Now, I have been given a new requirement. I have to create a command line interface, where I should be able to specify a list of commands and hit enter (or alternatively, create a set of commands and save it in a .bat file or something, and run it), so that my application performs the necessary actions. Basically, I have to create a command line interface, which can be used along with the GUI i already have (JSPs).
I am totally new to this. Can anyone throw light on where and how I can start?
Any little help is greatly appreciated.
EDIT
This is what my web application does. User can see a list of test scripts (written in Selenium WebDriver). He can choose script(s), choose a host on where to run them from, and click "Run", and the test executes on the said machines.
Now, I want a command line interface, which will eliminate the need for the GUI. Let's say, I simply want the user to be able to type a command like "execute My_Script_1", and the script should be executed.
The test scripts, the selenium drivers, everything reside on the App server.
My command line interface should be able to work on Windows command prompt.
Thank you.
Are you using Spring?
Can you specify, what exactly your CLI should do?
You may do, what Thomas said.
You also may use template engines like Velocity.. To form your output.
Use some kind of JavaCurses-like library to make your output... Look well.
Specifying commands...
Hm.. think about your business logic what exactly you are showing to user.
Remember webapp ui is webapp ui. Console ui is different. And user expects different behaviour
So commands like
show goods category="for kids"
Will be great.
Also don't forget about different help commands
yourJarName.jar --help / -h and etc
If your are want to write application with interactive mode... think about help command there.
You say you have your business logic in a JAR.
Why not starting another project with this JAR as a dependency and build it as an executable jar ?
Then simply use System.in and System.out to interact with the user.
EDIT :
So your application is hosted. Do you have an API like REST or SOAP or any other ?
Then you can build a client reading a string that the user has written, parsing it and calling the right service in your API.
I see two options:
Create a client-side CLI that generates the same data your server
receives. In other words, you don't modify your server code, and you create a
client-side CLI module (with jQuery for example) that parses the command lines and sends
exactly the same thing your actual GUI sends.
Set up a text area in your web app (decorated as a CLI) that reacts
on each Enter key pressed, and sends the line(s) to your server. On
your server, you can create a utility class (say CLIParser.java for
instance), and use Args4j to parse the received command,
validate it and run it.
Have you looked at Primefaces terminal? http://www.primefaces.org/showcase/ui/misc/terminal.xhtml
You data structure looks simple enough. Also you mentioned you designed your application the way the business logic is separated from the front end.
In this case you may consider exposing your business logic as a REST based WebService. It should not be that hard since you have layered structure in your application.
Looks like a few methods:
list scripts - returns a list of available scripts list hosts
returns a list of available hosts run script(scriptName, hostAddress)
runs script scriptName on a host with on address hostAddress possibly returns the results if your application supports this
All three look like a good candidates for GET methods.
You may consider Jersey or Resteasy or another framework.
You can find plenty tutorials for both of them. Take a look for example here.
From your command line application you can make calls to your web service in different ways. Just because I used to work with Jersey JAX-RS implementation most of the time, I found use of Jersey client(the latest stable version) the most convenient. Here you can find a short tutorial how you can do it from your command line application with Jersey client. JBoss also has a client API as a part of their framework(also fully certified JAX-RS implementation). You may even decide not to use any client API and do all the work manually utilizing HttpURLConnection, but I would not recommend. There is no big difference in using client API or do all the work manually with HttpURLConnection for the simple service, but you never know when your application becomes not that simple because of new requirements your client could not think of at the beginning.
Hope that helps

Executing a class in remote jvm

I have a small test class that I want to run on a particular jvm that's already up and running (basically it's an web application running on Tomcat) . The reason I want to do this is I want to execute a small test class (with the main method and all) within that jvm so that I get the same environment (loaded and initialized classes) for my test class.
Is it possible to indicate that ,say through a jvm parameter, that it should not initialize a new vm to execute my class but instead go and execute on the remote vm and show me the result here, on my console. So the local jvm acts as a kind of thin proxy ?
I am not aware in case there are some tools that should make this possible .Also heard somewhere that java 6 jvm comes with an option like this , is that true ?
Please help me.
Thanks,
After reading this question and the answers, I decided to roll my own little utility: remoteJunit
It is lightweight and dynamically loads classes from the client to the server JVM. It uses HTTP for communication.
You might want to take a look at btrace. It allows you to run code in an already started JVM provided you don't change the state of the variables inside that JVM. With this kind of tracing, you might be able solve your problem in a different way. Not by running extra code in form of a new class but by adding safe code to and existing class running inside a JVM.
For instance, you might System.out.println the name of the file when there is a call to File.exists.
You might find JMX useful. Register an MBean in the server process. Invoke it with visualvm (or jconsole). (tutorial) Never tried it myself, mind.
RMI would also do the magic.
http://java.sun.com/javase/6/docs/technotes/guides/rmi/index.html
Make your web application start an RMI registry and register your service
beans there.
Then in other JVM you can run a program that queries the RMI registry
started by your web application for the services you want to verify
and you are done.
I assume "small test class" is basically some debugging code you want to run to monitor your real application, which is deployed remotely on a Tomcat. If this is the case, you should connect your Eclipse debugger remotely to the Tomcat instance, so you can set a breakpoint at interesting locations and then use the Display view of Eclipse to run any arbitrary code you might need to perform advanced debugging code. As java supports Hot Code Replacement using the debug mechanism, you can also change existing code on the remote side with new code at runtime.

Categories

Resources