[Beginners Corner] - Confused about: Eclipse, Eclipse WTP, and JBoss; what do I
by matthewtap
I have developed using NetBeans and the Sun Java EE 5 Application Server.
But, I am new to Eclipse [I can use it for POJO's], as well as JBoss. I have found mid to high level info on both... there is mid to high level stuff coming out of my ears. But I do not know what exactly is needed.
What I want to do:
-- I'd like to use Eclipse as the IDE, as I used NetBeans.
-- and I'd like to use JBoss as the App Server / Servlet Container [I suppose Tomcat will be the resource for the Servlet Container at least].
But, what I don't know:
-- Is this a standard 'marriage'... or is there an IDE that is packaged with JBoss that I do not know about?
-- Most significantly, the role of the Eclipse WTP -- is this something I would still need if I were to use Eclipse as the IDE along with JBoss as the App Server?
Or, is the Eclipse WTP something that would just duplicate functions that JBoss handles?
I know this is a JBoss forum, but the questions are related to each other.
Since all books / documents I can find on this talk about either JBoss or Eclipse and the WTP, there isn't anything I've found that contrasts the two and helps me understand what I would really need.
For sake of this question, assume I'm wanting to be able to make a 'hello world' version of a Servlet and JSP page, and also to connect to a Derby Database.
I wish I had the time so I could learn everything I need to learn about both, and thus I'd be able to make the determination myself, but I need a starting place, as I feel like I'm looking for the starting blocks while wearing a blind fold.
If anyone who understands this stuff can help me out, I'd be grateful for the assistance.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212118#4212118
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212118
17 years, 2 months
[JNDI/Naming/Network] - Could not get JNDI datasource working
by sdsani
Hi,
I am new to Jboss and at this point learning about Jboss and JSF. Currently I am working on a very small JSF application (JSF, Spring) that connects to a database (H2) and then reads and display some information from that database. Everything works fine when I perform JNDI lookup from my code as mentioned below.
| private Connection getConnectionUsingJNDI() throws Exception
| {
| Properties properties = new Properties();
| properties.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| properties.setProperty(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
| InitialContext ic = new InitialContext(properties);
|
| Connection con = null;
| if (ic != null) {
| DataSource ds = (DataSource) ic.lookup("java:/H2DS");
| con = ds.getConnection();
| }
| return con;
| }
|
Next I tried to configure my JNDI lookup in Spring. Following are the steps that I took.
Added following entry in my spring context file:
| <jee:jndi-lookup id="dSource" jndi-name="java:/H2DS" resource-ref="true"/>
|
Modified my applicationContext.xml file to use new datasource.
| <bean id="employDAO" class="dao.EmployDAO">
| <property name = "dataSource">
| <ref bean="dSource"/>
| </property>
| </bean>
|
When I deploy my application, I am getting a success, however when I hit this application I am getting a null for DS. Please advice. Since i am new to Jboss, i will appriciate if you could post a detailed solution.
Sani
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212109#4212109
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212109
17 years, 2 months
[Persistence, JBoss/CMP, Hibernate, Database] - Having problem to use JNDI datasource.
by sdsani
Hi,
I am new to Jboss and at this point learning about Jboss and JSF. Currently I am working on a very small JSF application (JSF, Spring) that connects to a database (H2) and then reads and display some information from that database. Everything works fine when I perform JNDI lookup from my code as mentioned below.
| private Connection getConnectionUsingJNDI() throws Exception
| {
| Properties properties = new Properties();
| properties.setProperty(InitialContext.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| properties.setProperty(InitialContext.PROVIDER_URL, "jnp://localhost:1099");
| InitialContext ic = new InitialContext(properties);
|
| Connection con = null;
| if (ic != null) {
| DataSource ds = (DataSource) ic.lookup("java:/H2DS");
| con = ds.getConnection();
| }
| return con;
| }
|
Next I tried to configure my JNDI lookup in Spring. Following are the steps that I took.
Added following entry in my spring context file:
| <jee:jndi-lookup id="dSource" jndi-name="java:/H2DS" resource-ref="true"/>
|
Modified my applicationContext.xml file to use new datasource.
| <bean id="employDAO" class="dao.EmployDAO">
| <property name = "dataSource">
| <ref bean="dSource"/>
| </property>
| </bean>
|
When I deploy my application, I am getting a success, however when I hit this application I am getting a null for DS. Please advice.
Sani
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212107#4212107
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212107
17 years, 2 months
[JBoss Portal] - Re: Dashboard configuration - drag and drop
by diparc
I was looking at other posts in the forum and figured that I do need to manage hibernate transactions. I modified the code to do that and it is working now.
Hoping this is the right way though, please share your thoughts -
I am leaving the code snippet here -
| private void createUserAndAssignPortalRole(String userName) throws IllegalArgumentException, ServletException {
| Session session = null;
| Transaction transaction = null;
|
| try {
| session = getIdentitySessionFactory().openSession();
| transaction = session.beginTransaction();
| if(!isUserInPortalDB(userName)) {
| this.filterConfig.getServletContext().log("user not found in portal db, creating user: " + userName);
| User user = getUserModule().createUser(userName, ""); //not storing user passwords in database
| getMembershipModule().assignRoles(user, getRequiredRoleSet());
| }
| }
| catch (IdentityException e) {
| this.filterConfig.getServletContext().log("could not assign portal role to user: " + userName);
| throw new ServletException(e);
| }
| finally {
| if (transaction != null) transaction.commit();
| if (session != null) session.close();
| }
| }
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212106#4212106
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212106
17 years, 2 months
[JBoss Portal] - Re: Dashboard configuration - drag and drop
by diparc
Thanks Sambit & Vivek!
I wrote a servlet filter like you suggested and I am creating the user when the user is not found, also creating the role when not found, and assigning role to user using the membership module -
however, I am getting an exception when it tries to create the user in the portal database -
anonymous wrote :
| org.hibernate.HibernateException: Unable to locate current JTA transaction
| org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61) org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544) org.jboss.portal.identity.db.HibernateUserModuleImpl.getCurrentSession(HibernateUserModuleImpl.java:298) org.jboss.portal.identity.db.HibernateUserModuleImpl.createUser(HibernateUserModuleImpl.java:166)
| JBossPortalAuthorizationFilter.createUserAndAssignPortalRole(JBossPortalAuthorizationFilter.java:83)
|
seems like i need to start and end hibernate transactions -
I am using methods in UserModule, RoleModule and MembershipModule only to achieve this-
you mentioned about the TransactionManager, I am not using that -
can you please advise what i need to do here -
here is the code snippet from doFilter() -
|
| ...
| ...
| //create user and assign roles if user is not defined in portal db
| try {
| createUserAndAssignPortalRole(userName);
| filterChain.doFilter(httpRequest, response);
| }
| catch (IllegalArgumentException e) {
| this.filterConfig.getServletContext().log("Invalid user: " + userName);
| e.printStackTrace();
| denyAccess(userName, httpResponse);
| return;
| }
| }
|
| private void createUserAndAssignPortalRole(String userName) throws IllegalArgumentException, ServletException {
|
| try {
| if(!isUserInPortalDB(userName)) {
| this.filterConfig.getServletContext().log("user not found in portal db, creating user: " + userName);
| User user = getUserModule().createUser(userName, ""); //not storing user passwords in database
| getMembershipModule().assignRoles(user, getRequiredRoleSet());
| }
| }
| catch (IdentityException e) {
| this.filterConfig.getServletContext().log("could not assign portal role to user: " + userName);
| throw new ServletException(e);
| }
| }
|
thanks once again for your help,
D
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212102#4212102
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212102
17 years, 2 months