Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

compiling ejb  RSS feed

 
Rajesh Chandra
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed j2sdkee1.3.1 in c:\ and i managed to run the server.I downloaded the tutorialbundle(from sun) which i want to run.i Created a new application from the deploy tool,ConverterApp.
Now I want to compile the remote interface (Converter.java), home interface (ConverterHome.java), and the enterprise bean class (Converter-Bean.java).
In a terminal window, i went to the j2eetutorial/examples directory and typed the following command: ant converter and I get the error ant is not recognized as internal or external command.Im using ant 1.6.5.Can I compile with this tool?If so How?
regs Rajesh
 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajesh,
Do you have the ant bin directory in your path?
 
Rajesh Chandra
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have in my environment variable ANT_HOME set to c:\ant1.6\bin. Is there any more that I have to do?
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajesh,

If you try to compile the example on Windows, then locate to MyComputer icon on the desktop. Right click on it and chose the Properties option. From the System Properties window click the Advance tab. Next click the Environment Variables button and locate the Path variable within the System Variables. Double click and make sure it contains the next text:

Next you have to open a new command window and retype your ant command.
Regards.
 
Rajesh Chandra
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey Valentine,
I have in my PATH variable (using windows xp)

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem%ANT_HOME%\bin;
I also tried with this one
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%ANT_HOME%\bin;
It doesnt work anyway.
regs Rajesh
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then you better run the full path:

See if if works. If it doesn't then you need to check the content of the content of the c:\ant1.6\bin and make sure that everything looks fine. You might probably need to reinstall ant.
Regards.
 
Rajesh Chandra
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much valentin now the path problem is over but it says the build.xml doesnt exist and build failed.Im new to j2ee .Can you show me through how to compile an ejb? I have weblogic but it looks scary with vast documentation.
regs Rajesh
 
Valentin Tanase
Ranch Hand
Posts: 704
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rajesh,

First let�s start with this:

now the path problem is over but it says the build.xml doesnt exist and build failed.

This is an ant issue. When you run ant, it tries to locate the building file within the current working directory. By default the name of this file is build.xml. You can specify another file if you whish, providing the �f flag:

Hence you better look for the build.xml file within your examples.

Can you show me through how to compile an ejb? I have weblogic but it looks scary with vast documentation.

There are several ways to compile ejbs and this mostly depends upon the building process that each organization has. One very common way is to compile your ejbs from within your IDE. This works very well for development environment though. However most companies use ant and many EJB vendors provide special ant tag that can be used for the same purpose. WebLogic has a special tool for compiling ejbs, named appc (previous to WL7.0 it was ejbc). You can invoke the appc from the command line like this:

java �classpath $BEA_HOME/server/lib/weblogic.jar;.;<other paths>; weblogic.appc �

The best way however to compile weblogic ejbs is to use ant. Weblogic provides a collection of ant tasks to help you (this is copied from BEA site):

  • wlddcreate�Generates basic deployment descriptor files for J2EE components in the source directory. See Generating Deployment Descriptors Using wlddcreate.
  • wlcompile�This Ant task compiles the contents of the source directory into subdirectories of the build directory. wlcompile compiles Java classes and also processes annotated .ejb files into deployment descriptors, as described in Compiling Applications Using wlcompile.
  • wlappc�This Ant task invokes the appc compiler, which generates JSPs and container-specific EJB classes for deployment. See appc Compiler.
  • wldeploy�This Ant task deploys any format of J2EE applications (exploded or archived) to WebLogic Server. To deploy directly from the split development directory environment, you specify the build directory of your application. See Deployment Tools Reference in Deploying WebLogic Server Applications.
  • wlpackage�This Ant task uses the contents of both the source and build directories to generate an EAR file or exploded EAR directory that you can give to others for deployment.

  • (see http://e-docs.bea.com/wls/docs81/programming/environment.html )

    You can read the online documentation if you�d like to know more about it.
    The next smart thing you can do is to run few examples yourself. The easiest way to achieve this is to go to $BEA_HOME/samples/server/examples/src/examples/ejb20/basic/statelessSession and open the build.xml file from there. Look at it and you�ll get a better understanding of what you should do. You probably need to look at the ant documentation in order to understand it, but is definitely worth trying. Once you understood this you can copy this file and suit it to your needs.
    Let me know if you need anymore help.
    Regards.
     
    Rajesh Chandra
    Ranch Hand
    Posts: 55
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Well Valentin as you said we can place the output of build in another build file as given
    ant �f c:\dev\prj\another_build.xml <target_name>

    I want to compile the ejb placed in C:\j2eetutorial\examples\src\ejb\converter and my build.xml is in C:\j2eetutorial\examples
    Should I create a new folder to place the build file? In my tutorials context how to go about.
    Further the tutorial says it is configured to work with ant 1.3 but Im using ant 1.6.5 >Is it because of the version Im not able to compile my ejb?
    regs
    Rajesh
     
    Valentin Tanase
    Ranch Hand
    Posts: 704
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Rajesh,

    My guess is that you should try to compile your EJBs from within the C:\j2eetutorial\examples folder (where your build.xml is located). If that doesn�t work, you probably need to look at the build.xml and you mostly need to change it little bit. You specially need to pay attention to variable definitions and other building paths. For example all compiling paths include special libraries, like the j2ee library (weblogic.jar in your case) and you must make sure that they point to the right place on your hard drive. The source path should point to the folder where the source files are, etc.

    Further the tutorial says it is configured to work with ant 1.3 but Im using ant 1.6.5 >Is it because of the version Im not able to compile my ejb?

    Do you get any compile errors? Then you better post them as well. So far my understanding is that you are not able to run ant.
    Finally there is one more thing I�d like to tell you though. Compiling your EJBs is not much of a deal. Ultimately you can compile them like any ordinary java class using a command line like this:

    This should be enough. Contrary to most of the beliefs you don�t need to generate RMI stubs or anything like this. The container uses dynamic proxies and stubs will be generated at runtime (you�d need to generate the RMI-IIOP stubs if you�re implementing CORBA clients, but this is another story). The appc tool on the other hand is a much better tool, because it does a lot of extra things (like compiling jsp for example) and can validate your deployment descriptors as well. Another weakness of java compiling (vs ant) is that you have no automatic way to pack your beans and this could be really tricky if you�ll choose to do it manually. Ultimately if your examples were designed to deploy your ejbs on other containers (like JBoss or Sun�s) they will mostly not going to work on WebLogic. All this vendor neutral stuff that J2EE is so proud of it�s only propaganda and nothing more. It would be better for you to get a working example from bea (see the build.xml I recommended you previously) and start from there. It might save you a lot of time and frustration though.
    Regards.
     
    Rajesh Chandra
    Ranch Hand
    Posts: 55
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thank you so much Valentine,finally I managed to compile the ejb and dploy it.I changed all the classpath and it worked out.
    regs Rajesh
     
    Valentin Tanase
    Ranch Hand
    Posts: 704
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You're very welcome Rajesh
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!