Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Help With Rest EJB

 
hangman
Posts: 220
Angular Framework Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I might be doing something wrong.
I am trying to get the NameService example from http://java.boot.by/ocewsd6-guide/ch04.html to work on Glassfishv3 and I am not sure I am deploying correctly.
I cannot seem to find the code for the NameBean class, so I made up my own.
When I deploy, the server log seems to indicate that everything is going OK, but I am not sure what URLs to try with my curl command.
(I run Glassfish on 8081).

curl http://localhost:8081/restejb
just gives me my prompt back.
Pretty much everything else gives me: HTTP Status 404 The requested resource () is not available.

Thanks to anyone who can help me with this. Here is what I am doing:


$ cat src/NameService.java

$ cat src/NameBean.java


$ mkdir WEB-INF
$ mkdir WEB-INF/classes
$ export GL4=/bapps/glassfish3/glassfish/modules
$ javac -cp WEB-INF/classes:$GL4/javax.ejb.jar:$GL4/jersey-core.jar -d WEB-INF/classes src/*.java
$ jar cvf restejb.war WEB-INF
added manifest
adding: WEB-INF/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/(in = 0) (out= 0)(stored 0%)
adding: WEB-INF/classes/NameBean.class(in = 394) (out= 249)(deflated 36%)
adding: WEB-INF/classes/NameService.class(in = 894) (out= 527)(deflated 41%)
$
$ cp restejb.war /bapps/glassfish3/glassfish/domains/domain1/autodeploy/restejb.war
$

Server log then says:

[#|2011-04-18T09:50:27.606-0700|INFO|glassfish3.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=63;_ThreadName=Thread-1;|[AutoDeploy] Selecting file /bapps/glassfish3/glassfish/domains/domain1/autodeploy/restejb.war for autodeployment.|#]

[#|2011-04-18T09:50:27.937-0700|INFO|glassfish3.1|javax.enterprise.system.container.ejb.com.sun.ejb.containers|_ThreadID=63;_ThreadName=Thread-1;|Portable JNDI names for EJB NameService : [java:global/restejb/NameService, java:global/restejb/NameService!NameService]|#]

[#|2011-04-18T09:50:28.048-0700|INFO|glassfish3.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=63;_ThreadName=Thread-1;|WEB0671: Loading application [restejb] at [/restejb]|#]

[#|2011-04-18T09:50:28.090-0700|INFO|glassfish3.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=63;_ThreadName=Thread-1;|restejb was successfully deployed in 434 milliseconds.|#]

[#|2011-04-18T09:50:28.097-0700|INFO|glassfish3.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=63;_ThreadName=Thread-1;|[AutoDeploy] Successfully autodeployed : /bapps/glassfish3/glassfish/domains/domain1/autodeploy/restejb.war.|#]

 
Bob Nedwor
hangman
Posts: 220
Angular Framework Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It seems that at least part of the answer is here http://netbeans.dzone.com/articles/how-to-combine-rest-and-ejb-31 .

My NameBean needs @Singleton and some other things.

More on this later.

Thanks if anyone has any other answers.
 
Bob Nedwor
hangman
Posts: 220
Angular Framework Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to Milan Kuchtiak for the example previously referenced. I also changed my package from the default (none) to "name" like he did and I also added the ApplicationConfig class like he did (to demonstrate that not even a web.xml is necessary here). I rejarred and re-deployed.

What Milan does not show you is how to call these using curl (in case you do not want to go to the trouble of setting up NetBeans 6.8, etc). Here they are:

curl http://localhost:8081/restejb/resources/application.wadl
curl http://localhost:8081/restejb/resources/name
echo "New Name" > data
curl -T data http://localhost:8081/restejb/resources/name
curl http://localhost:8081/restejb/resources/name
 
A "dutch baby" is not a baby. But this tiny ad is baby sized:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic