Ashley Lester

Greenhorn
+ Follow
since Apr 25, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ashley Lester

If I annotate a business method or EJB with @RolesAllowed, I can restrict operations to only authorised users.

Where does JavaEE look in order to test whether a user is in a particular role? Is it something I have to configure on the server?

For example, in my database, I have a 'user' table with a 'role' attribute, the enumerated types in the 'role' attribute are 'user' and 'administrator'.

What can I use as a strategy to make sure that only users with an 'administrator' attribute are allowed access to certain business methods?

Rob Spoor wrote:I haven't worked with GlassFish for a while, but I assume that data source has a JNDI name. You then use that JNDI name in your persistence.xml file, and the persistence unit in your EntityManager declaration. You already have that, so it should work now.



Indeed it does, thanks for your help

Rob Spoor wrote:I have never used @DataSourceDefinition. Instead, I use a container-specific mechanism to define the data source. In JBoss I both used data source XML files in the deployments folder, and defining the data sources in the JBoss configuration (which can be configured using JBoss CLI, among others). In WebLogic and GlassFish I defined data sources in the WebLogic / GlassFish console application.



Ok, cool. My difficulty is figuring out the "correct" way to connect to a data source, and so have access to entity classes, from an EJB.

If I declare a persistence unit through @PersistenceContext, is this sufficient?

For example:



That's just an example. In my own code, I have declared the entity manager through a separate class:



As I have already provided the persistence unit through the declaration of the entity manager, does this mean I can access my entity class without extra annotations? Like the following:



edit: To clarify, as you can see, I already have the database connection attributes defined in Glassfish:

I'm working on a simple application to do CRUD on a database (in Netbeans). I have this workflow:

JSF xhtml page - Backing Bean - EJB - Entity Class - Database

I can ping the database using Glassfish.

I have not yet worked on the JSF page or the backing bean. I am developing an EJB class now.

I read that I have to annotate the EJB with @DataSourceDefinition to define the database connection properties.

I have two questions:

- Is this necessary given that I have a persistence.xml which already defines the JNDI data source name
- Do I need to give this data source definition to all the EJB classes I may want to create

Is there an... easier way?

Thanks

Ashley
I am undergoing a small software application project based on Spring (or Java EE, I haven't decided yet), Hibernate, PostgreSQL, and an Android client.

I have investigated the domain and put together activity models, use cases, functional requirements, so as to have scoped the work. I have modelled the database and implemented a database specification.

I am now starting static and dynamic modelling.

I was taught UML in a software engineering course, but the focus was on concepts, not frameworks. So, the most complex worked examples contained (imagine a sequence diagram with objects across the top) the UI, a coordinating object, something, something else, something else, and so on, message passing between all of them.

With a framework, I have to think about many other things, like servlets, beans, entity classes, sessions, and so on.

How would you approach constructing static and dynamic models specifically to enterprise software frameworks, and what are the differences I need to bear in mind?
9 years ago
I'm a part-time student and work as an analyst full-time. I finish my degree this year and hope to get into software engineering.

It sounds like your book is a good resource for someone learning about Spring.

I've found Spring hard to understand, firstly because of its size, and secondly there are many frameworks which themselves are based on Spring, and it is confusing for someone new to Spring to understand their differences.

What part of the framework does your book cover, and do you include coverage about Hibernate and Maven? Are hibernate and maven required for most Spring projects? And what about frameworks like Play or Roo, I'm guessing they're not covered as you could write several books on each. But it would be good to know at a high level what the differences and advantages / disadvantages are.

Thanks!

9 years ago

Jayesh A Lalwani wrote:Nowadays, most new applications that built on open source technologies are being built on the Spring stack. You don't see support for the full stack among PaaS providers simply because there isn't too much demand for it.

...

So, really there are 2 Java worlds out there
One which throws in a huge mix of Open source technologies into the project. None of these people have any need for a full fledged Application server

ANother which sticks to a supported stack (like Oracle's stack). These people are more likely to go with Oracle's cloud.


That's a very insightful answer. So, reduced demand, open-source developers, lighter-weight frameworks including out-of-the-box juiciness, and an emphasis on stateless RESTful architecture have meant that if you want an Oracle stack, go for it, but it's not where the cool cats are going.

That helps me a lot in figuring out why Java was on the cloud providers, but not in the way I was expecting.

I'm working on a project (part-way through database modelling) which is an Android app which sends info to a server, through which users can log on and do stuff. Its purpose is for surveyors in housing, for mobile working, and so on.

I was going to have a Java EE server for the project. But I think I have the time to look at something else, like Spring, Spring MVC, or Rails, or Roo, or Grails or Play or.......
9 years ago

Jeanne Boyarsky wrote:Ashley,
If you are just learning/practicing you don't need to deploy anywhere. You can just test on your machine. A lot less people are using EJBs than in the past anyway. If you haven't taken a look at Spring, consider that. You'll learn about the same amount than if you used EJBs. And Spring runs on Tomcat.

Java and .NET are certainly more expensive to host when you need a full blown stack than Ruby and PHP. I think Ruby is more similar to what runs in a servlet container though. Which is plenty! See my reference to Spring above.



Spring scared me. I did consider Spring Roo. There are too many frameworks for someone to pick.

Spring scared me because of the xml and the DI. I know I used DI in my Java EE course but that felt like it was more 'hidden' because I was just injecting dependencies into something... I forget what... I think it was something to do with an @remote annotation. It's been a while.

Yep, I am developing on my machine. But it feels nicer to have something more than 1 person can see.

Edit: I'm not against Spring or anything. I've watched a few of the tutorials from koushik on YT. It's taking some time for me to get my head around it. It seems even more huge and wishy-washy and 'do what you want' than Java EE does.
9 years ago

Ulf Dittmer wrote:This is an odd question, IMO. Developing an application without regard to the target platform where it should run, when you already know that the target platform might restrict what technologies you can use, doesn't strike me as a sensible approach. If you don't want to make assumptions as to the target platform during development (an odd assumption), then you should target virtual or physical hosts, where you can run pretty much anything you want. If you want to target an IaaS or PaaS platform, then that platform will impose restrictions on what you can do. That's true for any language you choose to develop in.

I'm not at all sure what "the disparity between Java and non-Java application servers in the cloud" is, nor do I find it unreasonable that the deployment platform influences the development technologies, especially when there is an extremely wide range of deployment technologies to chose from. Lastly, "having to pay through the nose" is completely context-sensitive as to your circumstances, so we can't comment on that.



I agree, development should consider beforehand what platform is going to be used. I don't work in software development (yet). But, iterative development and requirement creep might necessitate a solution which might be outside the offerings of the platform which was considered at the start of the development. I don't know how likely that is.

The disparity I refer to is two disparities, really - that of price, it appeared to me after searching the major cloud providers that java is generally more expensive, and also of features, as in, you might get a servlet container with Java, but an application server with another framework. But, I admit that this has to be compared with the large amount of stuff that you can integrate with Java. You might consider it a more flexible framework than some others.

It may be that enterprise Java, because it contains large, rich, industrial-strength frameworks, and additionally because it is so large, gives it more suitability to the kind of projects which are going to be more expensive.

I may not have phrased the question very well. And, the question is from someone who is not in the industry, so there is a probability that the question doesn't make sense from someone inside the industry. The main point of my question centres around this: consider if you are a learning developer, without much money, and you wanted to deploy a small website in Java, because that is the language you feel comfortable with & learnt with, and you want it to be hosted on a platform offering a server which complies with the EE specifications... well, I certainly felt some discouragement to find that the options I was looking at were making me lean towards a different framework, due to the points above about the price-feature comparison and lack of cheap full EE support.
9 years ago

Luan Cestari wrote:OpenShift does support the Java EE standards (you can deploy into a JBoss/WildFly/TomEE/EAP/etc) (and it is supporting (or it is almost supported,not sure) other interesting things like docker)

About the question, I don't think so. I think this is more a generation thing (younger people will have access to technology and want sth very easy to use, and ruby and python is much more intuitive for starters) (which I would summarize that Java get very known and could survive through the time). A second thing is the engineers that built the cloud platform. They had to choose what to support and if the put too much framework and technology that could lead to issues that those external libraries have which would make people lose the trust with the cloud provider which is bad. So they thought to build from the botton to avoid to ask requirements to any external project (making easy to test and maintain) .



Thanks for pointing out OpenShift to me. I've had a look around it and it looks pretty nice, and cheap. I also agree with your point that there has to be a cut-off in what the cloud is going to support, kind of a cost-reward evaluation. I suppose that if you're developing on the cloud, you might not want an industrial component model like EJB for a small website.
9 years ago
(Not sure if this belongs in this forum. Was thinking of posting it in 'meaningless drivel' or 'java ee'. Please move if I'm in the wrong place.

Java PaaS cloud-based solutions, like Amazon Web Services, Heroku, and so on, may not support the full stack of Java enterprise architecture, such as EJB's. Most Paas providers package a Tomcat servlet container which isn't a full application server. Those services supporting the full stack, like Oracle Cloud, charge hundreds of dollars per instance per month, which is ridiculous for those who are learning and want a person website hosted in the cloud, based on Java, supporting EJB's, for instance.

Question: Does the disparity between Java and non-Java application servers in the cloud persuade people to use lighter frameworks like Ruby on Rails, or Django, and is this a problem?

From a personal point of view, I'm certainly finding it difficult to justify developing a web application in Java if and when deployment happens, I might be using technologies which aren't supported, or technologies I would have to pay through the nose for.
9 years ago
Thanks! I'm liking the boiling down of concepts and taking out the "fluff".

This, and the Java EE pocket guide, are looking much more convenient than the phone-book-sized volumes I currently have on my desk.
9 years ago
This stackoverflow question has comments on it which explain the options better than I could.

http://stackoverflow.com/questions/12618915/how-to-implement-a-db-listener-in-java

I assume that once your server is aware of an update to the database, you are then ok with passing it to the client.

But just to throw some acronyms at you, you should look into JMS or UDP multicast if you aren't already using some sort of message service.
9 years ago

william chaple wrote:Ok so do I need to convert checker or min into a string or both into a string? can someone offer me a clue on what method to use? parse, valueof, ect



The issue here is what happens when you mix String and int together.

Try this:



You're assigning the primitive value 1 to a String "0". Remember, code goes left to right, so the String "0" becomes an object. So, the String understands to append the primitive value 1 to "0" because Java is being kind and autoboxing it for you.

If you do this:



It won't work.

The reason for this is that there isn't a String object existing yet. You're trying to assign a primitive integer into a String object, which it doesn't understand.

That is the same behaviour as what's happening in your code.

So, you either need to:

Option 1: Change how you're constructing the time and use a class like SimpleDateFormat. This will solve the problem.
Option 2: Make checker a String (an int will drop the leading zero) and make sure that you're only assigning Strings to it. This will also solve the problem.
9 years ago
If you want a simple formatted time in the format hh:mm, have you looked at the SimpleDateFormat class?

http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
9 years ago