Simplest way to serve static data from outside the application server in a Java web application

I’ve seen some suggestions like having the image directory being a symbolic link pointing to a directory outside the web container, but will this approach work both on Windows and *nix environments? If you adhere the *nix filesystem path rules (i.e. you use exclusively forward slashes as in /path/to/files), then it will work on Windows … Read more

Another Repeated column in mapping for entity error

The message is clear: you have a repeated column in the mapping. That means you mapped the same database column twice. And indeed, you have: @Column(nullable=false) private Long customerId; and also: @ManyToOne(optional=false) @JoinColumn(name=”customerId”,referencedColumnName=”id_customer”) private Customer customer; (and the same goes for productId/product). You shouldn’t reference other entities by their ID, but by a direct reference … Read more

Describe the architecture you use for Java web applications? [closed]

Ok I’ll do a (shorter) one: Frontend : Tapestry (3 for older projects, 5 for newer projects) Business layer: Spring DAO’s : Ibatis Database : Oracle We use Sping transaction support, and start transactions upon entering the service layer, propagating down to the DAO call’s. The Service layer has the most bussines model knowledge, and … Read more

Servlet for serving static content

I came up with a slightly different solution. It’s a bit hack-ish, but here is the mapping: <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.html</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.jpg</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.png</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.css</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>myAppServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> This basically just maps all content files by extension to the default servlet, and … Read more

How can a JACC provider use the Principal-to-role mapping facilities of the server it’s deployed on?

The short answer is: there’s no standard way to do it. Although Glassfish and JBoss support principal-to-role mappings, JACC does no assume all containers do, and so it delegates the responsibility of keeping those mappings to the JACC provider implementation. From the docs (see: PolicyConfiguration.addToRole method): It is the job of the Policy provider to … Read more

Performing user authentication in Java EE / JSF using j_security_check

I suppose you want form based authentication using deployment descriptors and j_security_check. You can also do this in JSF by just using the same predefinied field names j_username and j_password as demonstrated in the tutorial. E.g. <form action=”j_security_check” method=”post”> <h:outputLabel for=”j_username” value=”Username” /> <h:inputText id=”j_username” /> <br /> <h:outputLabel for=”j_password” value=”Password” /> <h:inputSecret id=”j_password” /> … Read more

What is an EJB, and what does it do?

Why really use them? (Why not just stick to POJO?) IF you need a component that accesses the database, or accesses other connectivity/ directory resources, or is accessed from multiple clients, or is intended as a SOA service, EJBs today are usually “bigger, stronger, faster (or at least more scalable) and simpler” than POJOs. They … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)