I just need a little hint in what direction my research should go.
Because currently I have a spring standalone jar project (spring-context, spring-data-jpa and hibernate entitymanager. Everything set up without xml files).
Now I want to run this application on two computers inside a network. Both should be able to send objects over the network. But I want to accomplish this without a web server (so no tomcat or glassfish).
Is this even possible? and how is this called?
I have problems finding something close to this plan. Most of the time I find tutorials and threads for sending objects with tomcat. But I more or less only need a open port that listens to incomming objects.
EDIT
Later I also want to put a third player in the communication process: A website. So then two standalone jar programs and one website will pass objects around. That's why I hope spring mvc will work for a stanalone solution as well.
(I know that this question will get tagged down, but it's ok, as long as I get some designations I can use to research better, so thanks ...)
You have many specifications. ProtoBuf seems to be interesting https://github.com/google/protobuf/tree/master/java
Without having server it would be a pain for you as you will have to implement concurrency, security and this kind of stuff.
Does Spring Boot work for you? Server is embeded ;-)
What about use normal java sockets? There is plenty information if you google it. If you need help with this just let me know and I can send you some java application. Just type Java Sockets and lets learn!
Alvaro.
I have been doing research for days and am so lost because everyone implements this differently or these tutorials are unclear.
I will be writing a web application that uses API's from sites like AWS, CROWD, etc. to create a single-sign on portal to manage many different things.
I have never worked in web development before, so this is all new. How should I get started in this project? What exact files will I need to create? Any advice would be helpful.
The only constraints that I have been given is that this will run in Tomcat, so I need to use java.
You need to understand the basics of client - server architecture and develop a
web service to standardize the REST based actions such as RPC.
Is there a security Framework available for Java Desktop Applications? When I searched on google I saw persons talking about Spring Security, however it seems to be chiefly web-based. I have been using ordinary java code(Login forms, jdbc) to implement User Level security but I am not comfortable programming this way. Thanks for your assistance
I have decided to use Apache Shiro Security Framework. It is very easy to use and the website host good documentation. Thanks all for the help.
you can still use rolebased access and some sort of directory service for desktop applications and you could do that with spring it's not necessarily only for web access. not that i'm pushing spring specifically.
regards
It's hard to really answer you without knowing what threat model you're thinking of.
Do you doubt that the signed in user has permission to open your application?
Does the application talk to a server and get data from there?
Are you concerned with the user tampering with code?
In the first case, this seems like something that is better handled with OS level permissions.
In the second case, handle your security on the server, you can't trust the client anyway.
In the third case, good luck.
I want to implement a Java HTTP server locally, I mean the server computer would be in my control. I'm expecting not more than 20 clients to send requests to it.
I was wondering how to go about it:
Should I use a J2EE servlet container, like Apache Tomcat?
Could I use J2SE classes and just build it using them?
Are there any existing alternatives?
What does your experience suggest?
There's a simple HTTP server embedded in the Sun 1.6 JRE. It's not JavaEE or servlet-compliant, it's very lightweight, but it might be good enough for your requirements. No need to download any 3rd party stuff if this is all you need.
The javadocs, rather bizarrely, are out on their own, here.
Embed Jetty in your application. Aside from performing quite well, it is delightfully easy to use and configure
You've got many options, not the least of which are Jetty, Grizzly, and TTiny.
I would strongly urge against writing your own web server, unless you've got time to kill and want to spend it writing things that are already available to you for free.
Seriously, reuse an existing solution. Why the hell are you even thinking rolling your own?
Now, 1. I don't understand your question as being about embedding a container. 2. You mentioned long polling several time. So I'd suggest to use GlassFish v3 / Grizzly (because there are many samples, e.g. have a look at the Dead Simple Comet Example on Glassfish v3 / Grizzly).
If you don't want to rely on the way a container implemented Comet support, use atmosphere and any of the container mentioned on the web site:
Atmosphere is a POJO based framework using Inversion of Control (IoC) to bring push/Comet to the masses! Finally a framework which can run on any Java based Web Server, including Google App Engine, Tomcat, Jetty, GlassFish, Weblogic, Grizzly, JBossWeb and JBoss, Resin, etc. without having to wait for Servlet 3.0 Async support or without the needs to learn how Comet support has been differently implemented by all those Containers.
If this is not a concern, just stick with the suggested option (GlassFish v3 / Grizzly).
For a concrete and recent comparison between Comet server implementation, checkout this awesome Comet Maturity comparison grid view (source: Comet Gazing: Maturity). It might help you to make your final choice... or not :)
I guess the biggest question is: why do you want to build this?
If it is for the purpose of personal development, I'd stick to whatever standard libraries come with your JDK and build it on top of that.
If on the other hand you have a particular application that needs a dedicated HTTP server I would try to take one of the open source servlet containers, like Jetty or Tomcat and build on those.
Perhaps look at the list of 26 open source web servers at http://java-source.net/open-source/web-servers.
http://java.sun.com/developer/technicalArticles/Networking/Webserver/WebServercode.html is actual code in a single file implementing a multi threaded webserver. For your requirements, such as they are, this should suffice.
http://java.sun.com/developer/technicalArticles/Networking/Webserver/ is an analysis of the code.
If you will write your own HttpServer you will have to implement all the methods of the HTTP protocol. Tomcat can be easily used locally.
Is it for practice, fun, to implement special requirements or why don't you just embed an existing solution?
Do you really want to build a HTTP server that deals with the protocol directly, or do you just want to write web apps? If all you care about is writing the web apps, then just use Tomcat, or Jetty, or Glassfish, or another server -- it will save you a ton of work.
If you really are interested in writing your own server from scratch, then the best way would be to just use Java SE, and not use any existing server technology.
Ad your 3) option: Try JBoss Netty.
http://fisheye.jboss.org/browse/Netty/trunk/src/main/java/org/jboss/netty/example/http/websocket
I am currently working on a project for school which will be a webapp where the gui will be programmed in Adobe Flex and the backend will be programmed in java, probably as servlets running in Tomcat...
I am working primarily on the backend things, with another guy in my group heading up the Flex stuff.
He is convinced that to communicate with the Java code he'll need to jump through all sorts of hoops. I was under the impression that you could probably just query the servlet and render the response into the application?
I haven't really been able to find any good documentation on Flex (Haven't look that hard either), I just wondered if this is as daunting as he is making it out to be.
Any resources / comments would be greatly appreciated.
Thanks!
Blaze Data Services is the way to go. You register a "MessageBroker" servlet in web.xml which acts as a front controller to your other services.
http://opensource.adobe.com/wiki/display/blazeds/BlazeDS/
http://livedocs.adobe.com/blazeds/1/blazeds_devguide/
http://livedocs.adobe.com/blazeds/1/javadoc/
As cliff.meyers stated, BlazeDS is definitely what you want for a Java backend. It integrates very nicely with Flex.
As far as Flex documentation goes, Adobe has a ton of free video tutorials online, and the official Flex language reference will be helpful, too.
There is also a turn key distro that contain a samples war file that you can deploy to a web server to get a feel for some of Blaze's capabilities.
You can use Red5, a 100% Java alternative to Adobe's FMS.