• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Simple & Basic EJB application -- Help is needed

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys, I am following an EJB tutorial. Unfortunately, it does not run (how surprising, right?). Trying to run it on jboss-4.0.5.GA. The deployment seems to be Ok, but running the servlet client fails.

Could you please take a look at it and tell me what you think is wrong? I simply cannot see any problem with the code & descriptors, however, as I have mentioned, the servlet does not run.

Thank you in advance.

Here is the application:

In the root of my development dir, I have 4 directories: build, deploymentdescriptors, src, web.

In the \ dir there are 2 files:

jboss-build.properties :



build.xml :




In the \src\test\session there are 4 files:

MyTestSession.java :




MyTestSessionHome.java :




MyTestSessionBean.java :




SessionTestServlet.java :



In the \web dir there is one file:

index.jsp :




In the \deploymentdescriptors\web dir there are 2 files:

web.xml :



jboss-web.xml :



In the \deploymentdescriptors\jar dir there are 2 files:

ejb-jar.xml :




jboss.xml :



In the \deploymentdescriptors\ear dir there is 1 file:

application.xml :



Here is the error message I am getting when I try to access the servlet (http://localhost:8080/example3/servlet/test):

 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody home?
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like a classloader issue. Have a look at InvalidPackagingError. How's your application packaged? Do you have those bean interfaces in more than one archive?
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.

1. I don't think I have any reasonable background to understand what is wrong from the link you gave.

2. As far as I know, classes do not appear twice in the archive files. The war archive contains the servlet. The jar archive contains the bean, remote interface, and home interface.

I attached the Ant build file... you can see how the archive files are being built. I really have put here all the data which is included in my application. I don't see any detail in the application which doesn't appear above.

I am just clueless regarding what is wrong???

[ March 19, 2007: Message edited by: Joseph Sweet ]
[ March 19, 2007: Message edited by: Joseph Sweet ]
 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Joseph,

I'm at home and have good news for you

I tried your test scenario in my Eclipse step by step exactly as you described.

It runs perfectly on my machine .



What Java version do you use? If it's Java 5 go and try it with Java 1.4

I used



Here the steps you should do:
  • 1.) open a DOS shell
  • 2.) go to you JBoss jboss-4.0.5.GA\bin
  • 3.) enter run -c default (there should be no exceptions)
  • 4.) build your project
  • 5.) drag and drop your ear folder from your build directory to your JBoss' jboss-4.0.5.GA\server\default\deploy directory
  • 6.) Try it again: http://localhost:8080/example3/servlet/test

  • Let us know how it work out for you

    Regards,
    Darya
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi,

    I am quite stuck here....

    Here is the Java version:

    java version "1.5.0_09"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
    Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)

    Why should it be 1.4? What is wrong with 1.5?

    Anyway, I have already done exactly what you had done as for compiling the project with the ant build file, and deploying it in the Jboss jboss-4.0.5.GA\server\default\deploy directory.

    Problem is that when i go to the link http://localhost:8080/example3/servlet/test, I get the error message I have mentioned above.

    Is there an issue with java 1.5 ???
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Joseph Sweet:
    Why should it be 1.4? What is wrong with 1.5?
    Is there an issue with java 1.5 ???



    Don't ask me that question . Try Java 1.4 to be equal with me.

    Did you try it with Java 1.4 when you say that you still get the exception?

    Let us know.

    Regards,
    Darya
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Well, I am still on JDK 1.5.

    I am just wondering, is it necessary to undergo all this process of installing JDK 1.4, changing paths, etc.............. it's like people telling you to reformat your computer once you get a bug in your program.

    Since 1.5 is supposed to be stable (actually, they have 1.6 already).

    It's such a simple EJB application what I am working on. How come it cannot work with 1.5 ???

    I bet most of the people in this forum have at least 1.5.

    Do you understand what the problem is, from the error message I cited above??
    [ March 19, 2007: Message edited by: Joseph Sweet ]
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Could be it's a classpath problem?
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Joseph Sweet:
    Well, I am still on JDK 1.5.

    I am just wondering, is it necessary to undergo all this process of installing JDK 1.4, changing paths, etc.............. it's like people telling you to reformat your computer once you get a bug in your program.



    Come on, now you are exaggerating a little bit . What's about it to install a Java 1.4 version on your computer.

    You can now become crazy over why it not run under Java 5 and why yes under Java 1.4. But for what? I looked at the exception and all I can say is that this whole JBoss invoker/interceptor stuff is not that easy to tackle. At least not in a time effective manner. This can be some subtle problem in one of the JBoss JAR files from your 4.0.5GA distribtion. And it's not your fault or the fault of Java 5. It's just accidential .

    If I were you, and this is just a recommendation I give to you, I would post that question to a JBoss forum and mention the Java 1.4/5 mismatch.

    In the mean time go ahead with your JBoss tutorial. And therefor go and install Java 1.4 instead of making me crazy .

    Let us know whether it works for you with Java 1.4? You haven't checked that out .

    Regards,
    Darya
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I can install only the JRE right?
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Ahhh I see you give up the Java 5 idea . At least for the moment .

    The JRE 1.4 version should be fine.
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Sorry for the delay.. my internet got knocked out.

    Well I think i need the JDK....... I went to a few jboss installation tutorials and they all say I need to set the JAVA_HOME to the JDK dir........

    When you are on a small hard drive, another 500MB are valuable.
    [ March 20, 2007: Message edited by: Joseph Sweet ]
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi,

    try it with a JRE 1.4 version first if 500 MB is too big

    Regards,
    Darya
    [ March 20, 2007: Message edited by: Darya Akbari ]
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I did, but when I start up JBoss it tells me to change JBOSS_HOME to point to the JDK instead of the JRE, and quits.

    So I tried to install the J2SDK 1.4 on the E: drive (have more room there), but the installaion program ignores me when I tell it to install on E: instead of C:

    It just tells me that C: has not enough room, but disables the E: options.

    (Does it have anything to do with the fact that E: is FAT32 ??? I use it to share stuff with Linux).

    Any idea what is wrong before I lose my mind???
     
    Jaikiran Pai
    Sheriff
    Posts: 10445
    227
    IntelliJ IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Joseph Sweet:
    Thank you.

    1. I don't think I have any reasonable background to understand what is wrong from the link you gave.

    2. As far as I know, classes do not appear twice in the archive files. The war archive contains the servlet. The jar archive contains the bean, remote interface, and home interface.

    I attached the Ant build file... you can see how the archive files are being built. I really have put here all the data which is included in my application. I don't see any detail in the application which doesn't appear above.

    I am just clueless regarding what is wrong???



    Do the following:

    - From the command prompt go to %JBOSS_HOME%/server/default/deploy folder
    - Then run the following command:


    where myApp.ear is the name of your ear file.

    - Post the contents here
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Joseph Sweet:
    So I tried to install the J2SDK 1.4 on the E: drive (have more room there), but the installaion program ignores me when I tell it to install on E: instead of C:

    It just tells me that C: has not enough room, but disables the E: options.

    (Does it have anything to do with the fact that E: is FAT32 ??? I use it to share stuff with Linux).



    I don't think that FAT32 does matter. Use Custom mode when you install JDK 1.4 . There you must explicitely set E:\

    Good Luck
    Darya
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    To Jaikiran Pai :

    Here is the output:



    Any insight?
     
    Jaikiran Pai
    Sheriff
    Posts: 10445
    227
    IntelliJ IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Can you run the same command on the example3.jar and example3.war and post the output here? Forgot to mention that in my earlier post.
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    To Jaikiran Pai :

    Here is the output:






    It looks like there are duplicities in the war and jar???

    I wrote the ant build.xml so that the war will include the servlet, and the jar will include the bean, remote interface and home interface.

    However it does not look like it's what I got... is anything wrong with my ant?
    [ March 20, 2007: Message edited by: Joseph Sweet ]
     
    Jaikiran Pai
    Sheriff
    Posts: 10445
    227
    IntelliJ IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Joseph Sweet:


    Here is the output:






    It looks like there are duplicities in the war and jar???

    I wrote the ant build.xml so that the war will include the servlet, and the jar will include the bean, remote interface and home interface.

    However it does not look like it's what I got... is anything wrong with my ant?



    There lies the problem, as you already have seen. The classes are present in multiple archives. Remove the

    WEB-INF/classes/test/session/MyTestSession.class
    WEB-INF/classes/test/session/MyTestSessionBean.class
    WEB-INF/classes/test/session/MyTestSessionHome.class


    from the war file
    Also, remove

    test/session/SessionTestServlet.class



    from the jar. Try it out. Will look into that ant script, but as of now remove the above mentioned classes manually and give it a try.
    [ March 20, 2007: Message edited by: Jaikiran Pai ]
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I am not sure how to remove files manually from jars, wars etc....?
     
    Jaikiran Pai
    Sheriff
    Posts: 10445
    227
    IntelliJ IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Try this then - Change the following build targets:




    See if it works. I havent tried that script myself so you might have to work on similar lines in that script.
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    That's funny.... because these are exactly the changes that I was employing to my build.xml........

    But it doesn't work......

    For some reason it takes to both the jar and war all the 4 class files, it doesn't exclude the files that are signified in the "excludes" attribute.

    Can't figure out why.....
    [ March 20, 2007: Message edited by: Joseph Sweet ]
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Anyone can see where my little mistake in the ant build.xml is???

     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Joseph,

    I am not sure what you are trying right now. The example you gave us works fine. I said that from begin on, didn't I ?

    The only difference between you and me is that I use Java 1.4 and not Java 5 as you do. So you better care to get Java 1.4. I created the files exactly as you explained them, created all those directories as you described and put all files in these directories in the same way as you described. I didn't change a dot. Neither in your Build XML file nor in any other file.

    Look to the files in your first post. They are fine!!! Or don't you trust yourself anymore ? Now, cool down, take a deep breath. Press the reset button in your head and start on again. Follow exactly those steps 1 too 6 as I posted them at the begin.

    You should have now the same structure as I have. If not here is a fallback for you. Go and download my Eclipse project and import it into your Eclipse:

    your project : joseph.zip

    And don't forget to use Java 1.4 .

    Regards,
    Darya
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Don't forget in jboss-build.properties to adapt
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Darya:

    It is running while I am still on JDK 1.5.

    The problem was with the ant build file (build.xml) that I use, which packed the files incorrectly.

    Probably you did not use the build.xml I provided??

    Had you used mine, you should have had the same problems as I had.

    So here is my current build.xml:

    (It does not work, for some reason it put all the 4 class files in both the war and the jar archives; while I want only the servlet to go into the war, and the bean and two interfaces to go into the jar).

    Can you tell me how to fix the build.xml?


    [ March 20, 2007: Message edited by: Joseph Sweet ]
     
    Darya Akbari
    Ranch Hand
    Posts: 1855
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Joseph Sweet:
    It is running while I am still on JDK 1.5.

    The problem was with the ant build file (build.xml) that I use, which packed the files incorrectly.

    Probably you did not use the build.xml I provided??



    As I said I used exactly the files you gave us. See the project I created for you (joseph.zip).

    Anyway I'm glad that you got it working. Actually I didn't tried it on a Java 1.5 and hence couldn't tell you for sure.

    Whatsoever you got it and that's fine

    Good Luck,
    Darya
     
    Joseph Sweet
    Ranch Hand
    Posts: 327
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    That's still a mystery why the ant file gave us different results.

    I will get back to it tomorrow night.

    Stay tuned.
    [ March 20, 2007: Message edited by: Joseph Sweet ]
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic