[Clustering/JBoss] - HA-JNDI and HA-JMS problem
by igain
Hi All,
I have 2 jboss nodes configured in cluster which is for QA environment.
When my application try to lookup the Queue destination on HA-JNDI port which is 1100 i get following exception on one node but at the same time it picks the Queue from other node
2007-09-21 11:17:42,293 DEBUG [org.jnp.interfaces.NamingContext] Failed to connect to null:1100
javax.naming.CommunicationException: Failed to connect to server null:1100 [Root exception is javax.naming.ServiceUnavailableException: Failed to connect to server null:1100 [Root exception is java.net.UnknownHostException: null]]
at org.jnp.interfaces.NamingContext.getServer(NamingContext.java:269)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1385)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:594)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
Is this behaviour is correct or not ?
And lookup code is like this
| Properties p = new Properties();
| p.put(Context.INITIAL_CONTEXT_FACTORY,IConstants.INITIAL_CONTEXT_FACTORY);
|
| p.put(Context.URL_PKG_PREFIXES, IConstants.URL_PKG_PREFIXES);
|
| //Host is coming from jboss.bind.address property
| String host = System.getProperty(IConstants.SYSTEM_HOST_PROP);
|
| // HA-JNDI url.
| p.put(Context.PROVIDER_URL, host + ":" + IConstants.PROVIDER_URL_PORT);
|
| InitialContext ctx = new InitialContext(p);
| //looking for jms queue destination
| ctx.lookup(...)
|
Another problem is i tried to put localhost instead of host variable, however in that case it was ont wokring on both the nodes so i did change it to jboss bind address to ensure it picks from the node hwre code is getting executed.
Any help would be appreciated.
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087386#4087386
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087386
18 years, 7 months
[JBoss Seam] - I cannot get this test through, please help
by transvia
I creat a project from seam-gen2.0 CR. I am using Jboss server 4.2.1, Seam2.0 CR, MySQL 5.0. The project can be built, depoyed and run correctly. Then I create a simple test case, but I cannot make it works.
I tested that entity factory can be created; entity manager can also be created. But I cannot do database operation, including select and insert. Please help!
Test code:
package persistentTier;
|
| import java.util.List;
|
| import javax.ejb.Stateless;
| import javax.persistence.EntityManager;
| import javax.persistence.EntityManagerFactory;
| import javax.persistence.Persistence;
| import javax.persistence.PersistenceContext;
| import javax.persistence.Query;
|
| import org.hibernate.Session;
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.mock.SeamTest;
| import org.testng.annotations.Test;
| import org.tt.user.User;
|
| public class EntityManagerTest extends SeamTest {
|
| //@PersistenceContext
| private EntityManager em;
|
| @Test
| public void unitTestEntityManager() throws Exception{
|
| EntityManagerFactory emf = Persistence.createEntityManagerFactory("tt");
|
| em =emf.createEntityManager();
| User user=em.find(User.class, new Double(1));
| assert user.getPassword().equals("5527686");
|
| em.close();
|
| }
|
| }
User class:
package org.tt.user;
|
| import java.io.Serializable;
|
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.GenerationType;
| import javax.persistence.Id;
| import javax.persistence.Table;
|
| import org.hibernate.validator.NotNull;
| import org.jboss.seam.annotations.Name;
|
| @Entity
| @Name ("user")
| @Table (name="user")
| public class User implements Serializable {
|
| private double id;
| private String username;
| private String password;
|
| public User (){
| username="";
| password="";
| }
|
| @Id @GeneratedValue(strategy =GenerationType.AUTO)
| public double getId () {return this.id;}
| public void setId(long id){this.id=id;}
|
| public String getUsername(){return this.username;}
| public void setUsername(String username){this.username=username;}
|
| public String getPassword(){return this.password;}
| public void setPassword(String password){this.password=password;}
| }
|
Database, MySQL 5.0
| CREATE TABLE `user` (
| `id` double NOT NULL auto_increment,
| `username` varchar(50) NOT NULL,
| `password` varchar(50) NOT NULL,
| PRIMARY KEY (`id`)
| ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
|
| /*Data for the table `user` */
|
| insert into `user`(`id`,`username`,`password`) values (1,'oldreaper','5527686');
|
Erro message javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not load an entity: [org.tt.user.User#1.0]
| at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:647)
| at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:194)
| at persistentTier.EntityManagerTest.unitTestEntityManager(EntityManagerTest.java:29)
| Caused by: org.hibernate.exception.SQLGrammarException: could not load an entity: [org.tt.user.User#1.0]
| at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
| at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
| at org.hibernate.loader.Loader.loadEntity(Loader.java:1865)
| at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
| at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
| at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2992)
| at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
| at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
| at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
| at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
| at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
| at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
| at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
| at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
| at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:174)
| ... 23 more
| Caused by: java.sql.SQLException: Table not found in statement [select user0_.id as id2_0_, user0_.username as username2_0_, user0_.password as password2_0_ from user user0_ where user0_.id=?]
| at org.hsqldb.jdbc.Util.throwError(Unknown Source)
| at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
| at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
| at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.doPrepareStatement(BaseWrapperManagedConnection.java:386)
| at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.java:374)
| at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:187)
| at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:497)
| at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:415)
| at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
| at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1538)
| at org.hibernate.loader.Loader.doQuery(Loader.java:661)
| at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
| at org.hibernate.loader.Loader.loadEntity(Loader.java:1851)
| ... 35 more
| ... Removed 22 stack frames
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087385#4087385
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087385
18 years, 7 months
[EJB 3.0] - Mapping Problem
by Sukar1205
I am getting an error when I run Jboss server that says..
| --- MBeans waiting for other MBeans ---
| ObjectName: persistence.units:jar=SourceCode.jar,unitName=SourceCodePU
| State: FAILED
| Reason: javax.persistence.PersistenceException: org.hibernate.MappingException: Repeated column in mapping for entity: EntityBean.KnowledgeBase column: projectID (should be mapped with insert="false" update="false")
| I Depend On:
| jboss.jca:service=DataSourceBinding,name=SQL
| Depends On Me:
| jboss.j2ee:jar=SourceCode.jar,name=ClassificationBeanFinal,service=EJB3
|
This is my code
| @JoinColumn(name = "projectID", referencedColumnName = "projectID")
| @ManyToOne
| private Project projectID;
|
what is the synatx to insert = false and update = false... I tried adding it in JoinColumn but still giving me an error.
THanks in advacne.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087384#4087384
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087384
18 years, 7 months
[EJB 3.0] - Error [ServerThread] Failed
by lmprates
Hello!
I`m starting with EJB3 and in my first test, every time I call an EJB, I get this error in the Jboss console:
| 2007-09-21 14:44:30,046 ERROR [ServerThread] failed
| java.net.SocketException: Connection reset
| at java.net.SocketInputStream.read(SocketInputStream.java:168)
| at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
| at java.io.BufferedInputStream.read(BufferedInputStream.java:235)
| at java.io.ObjectInputStream$PeekInputStream.peek(ObjectInputStream.java:2196)
| at java.io.ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2376)
| at java.io.ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2443)
| at java.io.ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2515)
| at java.io.ObjectInputStream$BlockDataInputStream.readByte(ObjectInputStream.java:2664)
| at java.io.ObjectInputStream.readByte(ObjectInputStream.java:875)
| at org.jboss.remoting.transport.socket.ServerSocketWrapper.checkConnection(ServerSocketWrapper.java:54)
| at org.jboss.remoting.transport.socket.ServerThread.acknowledge(ServerThread.java:217)
| at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:298)
| at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:169)
|
Any help is welcome!
tks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087373#4087373
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087373
18 years, 7 months
[Beginners Corner] - problem in EJB example in JBoss 4.0.5 or JBoss 4.2.1
by vkviswanadh
Hi all, I am a new bie in JBoss world. I am trying to run a small application which prints current time .
I am trying to do this work using EJB 2.0 and JSP.
I created a jar file which is having EJB class files as well as ejb deployment descriptors, JBoss required DDs. (i.e., ejb-jar.xml and jboss.xml)
Then I made a jsp page which contains a JNDI call from that to access the EJB Home interface (normal EJB client call).With this I prepared a war file with all the required DD files (web.xml etc).
Now I prepared a ear file with jar file and war file , application.xml file and trying to deploy the application in JBoss. Once it was deployed in the server (deploying properly with out throwing any error), and trying to call the jsp page from browser
http://localhost:8080/test/firstEJB.jsp
it is throwing error at the browser as
-----------------------------------------------------------------------------
org.apache.jasper.JasperException: An exception occurred processing JSP page /firstEJB.jsp at line 14
11: props.put(Context.PROVIDER_URL, "localhost:1099");
12:
13: Context ctx = new InitialContext(props);
14: FirstHome home = (FirstHome)ctx.lookup("ejb/First");
15: First bean = home.create();
16: String time = bean.getTime();
17: bean.remove();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:518)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
javax.servlet.ServletException: java.lang.LinkageError: loader constraints violated when linking javax/ejb/Handle class
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:855)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:784)
org.apache.jsp.firstEJB_jsp._jspService(firstEJB_jsp.java:94)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
root cause
java.lang.LinkageError: loader constraints violated when linking javax/ejb/Handle class
java.lang.Class.getDeclaredFields0(Native Method)
java.lang.Class.privateGetDeclaredFields(Class.java:2232)
java.lang.Class.getDeclaredField(Class.java:1852)
java.io.ObjectStreamClass.getDeclaredSUID(ObjectStreamClass.java:1555)
java.io.ObjectStreamClass.access$600(ObjectStreamClass.java:47)
java.io.ObjectStreamClass$2.run(ObjectStreamClass.java:381)
java.security.AccessController.doPrivileged(Native Method)
java.io.ObjectStreamClass.(ObjectStreamClass.java:373)
java.io.ObjectStreamClass.lookup(ObjectStreamClass.java:268)
java.io.ObjectStreamClass.initProxy(ObjectStreamClass.java:464)
java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1502)
java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1457)
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
java.rmi.MarshalledObject.get(MarshalledObject.java:135)
org.jnp.interfaces.MarshalledValuePair.get(MarshalledValuePair.java:72)
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:652)
org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
javax.naming.InitialContext.lookup(InitialContext.java:351)
org.apache.jsp.firstEJB_jsp._jspService(firstEJB_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:387)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
-----------------------------------------------------------------------------------
my EJBHOme is
------------------
package com.stardeveloper.ejb.session;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
// Referenced classes of package com.stardeveloper.ejb.session:
// First
public interface FirstHome
extends EJBHome
{
public abstract First create()
throws CreateException, RemoteException;
}
------------------------------------------------------------
my Remote Interface is
package com.stardeveloper.ejb.session;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface First
extends EJBObject
{
public abstract String getTime()
throws RemoteException;
}
--------------------------------------------------------
my EJB Sesion Bean is
package com.stardeveloper.ejb.session;
import java.util.Date;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
public class FirstEJB
implements SessionBean
{
public FirstEJB()
{
}
public String getTime()
{
return "Time is : " + (new Date()).toString();
}
public void ejbCreate()
{
}
public void ejbPassivate()
{
}
public void ejbActivate()
{
}
public void ejbRemove()
{
}
public void setSessionContext(SessionContext sessioncontext)
{
}
}
-------------------------------------------------
My JSP page which is trying to access the EJB is
<%@ page import="javax.naming.InitialContext,
javax.naming.Context,
java.util.Properties,
com.stardeveloper.ejb.session.First,
com.stardeveloper.ejb.session.FirstHome"%>
<%
long t1 = System.currentTimeMillis();
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
props.put(Context.PROVIDER_URL, "localhost:1099");
Context ctx = new InitialContext(props);
FirstHome home = (FirstHome)ctx.lookup("ejb/First");
First bean = home.create();
String time = bean.getTime();
bean.remove();
ctx.close();
long t2 = System.currentTimeMillis();
%>
p { font-family:Verdana;font-size:12px; }
Message received from bean = "<%= time %>".Time taken :
<%= (t2 - t1) %> ms.
---------------------------------
my ejb-jar.xml is
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<display-name>FirstEJB</display-name>
<ejb-name>First</ejb-name>
com.stardeveloper.ejb.session.FirstHome
com.stardeveloper.ejb.session.First
<ejb-class>com.stardeveloper.ejb.session.FirstEJB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<ejb-name>First</ejb-name>
<method-name>*</method-name>
<trans-attribute>Supports</trans-attribute>
</container-transaction>
<security-role>
Users
<role-name>users</role-name>
</security-role>
</assembly-descriptor>
</ejb-jar>
----------------------------------------
my jboss.xml is
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN"
"http://www.jboss.org/j2ee/dtd/jboss.dtd">
<enterprise-beans>
<ejb-name>First</ejb-name>
<jndi-name>ejb/First</jndi-name>
</enterprise-beans>
--------------------------------------
One of the solution for this would be , if I put the EJB jar file (the jar file which is having all the ejb classes as well as deployment descriptors inside that ) inside the war file WEB-INF\lib folder. Then it is working fine , showing the page at the browser.
Suppose if it is a very big application and I can't put that at war\WEB-INF\lib folder. This is not the way to put.
SO any body please put some light on this...What I need to do to work with out putting my ejb jar file inside the war file.
Thanks!
vvk
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087368#4087368
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087368
18 years, 7 months
[JBoss Seam] - Re: 1.2.1->2.0.0 migration: No active application scope
by tynor
I've fixed this by changing my pages.xml configuration. A wildcard that worked in 1.2.1 no longer works in 2.0.0. On reflection, perhaps it never should have worked, but for the sake of the archives, here's what caused the problem:
In my app, I need _all_ application pages to be password protected -- so I had this in my pages.xml:
<page view-id="*" login-required="true">
| <navigation>
| <rule if-outcome="home">
| <redirect view-id="/home.xhtml"/>
| </rule>
| </navigation>
| </page>
|
I'm guessing that the problem is a chicken-egg thing with /login.xhtml (which is conceptually covered by the above wildcard). In 1.2.1, this worked. In 2.0.0, I get the "no active application scope" exception detailed earlier in this thread.
So my fix is to move all my password-protected pages into subdirectories and leave only the non-protected stuff in the root view. pages.xml no longer has a "*" wildcard, only "/foo/*", "/bar/*", etc.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4087365#4087365
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087365
18 years, 7 months