I have problem context xml file.
I have wrote below mentioned code but, i couldn't connect to database:
Resource name = "jdbc/Examsite" auth="Container"
type="javax.sql.DataSource" maxActive="20" maxIdle="30"
maxWait="10000" driverClassName="com.mysql.jdbc.Driver"
url=" jdbc:mysql://http://34.209.206.56:3306/oracle_exam_last "
username="****" password="****" />
You have a problem in your URL :
url=" jdbc:mysql://http://34.209.206.56:3306/oracle_exam_last "
//------------------^^^--------------------------------------^
You should not specify the protocole http just the ip and the port number and the database name, also don't make a space in your url :
url=" jdbc:mysql://34.209.206.56:3306/oracle_exam_last"
Related
sorry for my bad english, (Im french :-D).
I want work with TomEE for JPA, but my configuration is bad i think.
I receive a exception when i try to connecte to my database (Mysql).
persistence.xml
<persistence-unit name="elevage" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>elevage</jta-data-source>
<non-jta-data-source>elevageUnmanaged</non-jta-data-source>
<class>com.test.ejb.BeanAnimal</class>
<properties>
<property name="openjpa.jdbc.DBDictionary" value="mysql" />
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
</properties>
</persistence-unit>
tomee.xml
<Resource id="elevage" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage2?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged true
DefaultAutoCommit false
</Resource>
<Resource id="elevageUnmanaged" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage2?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged false
</Resource>
Exception
AVERTISSEMENT: Unexpected exception from beforeCompletion; transaction will roll back
<openjpa-2.4.1-r422266:1730418 fatal general error> org.apache.openjpa.persistence.PersistenceException: user lacks privilege or object not found: OPENJPA_SEQUENCE_TABLE {SELECT SEQUENCE_VALUE FROM OPENJPA_SEQUENCE_TABLE WHERE ID = ? FOR UPDATE} [code=-5501, state=42501]
Request is a "SELECT" and i want take all data in my database. I have see documentation but the problem persiste.
Thank all for your answer !
(if you need more file, tell me :-) )
After a long time tearing my hair, I found a solution, if it can save time, here it is:
2 Configurations!
In development:
tomee.xml is not used, it is necessary to configure openejb.xml whose path is specified in the eclipse console, attention, the access is by hidden file
Path for my machine (Linux):
/home/user/eclipse-workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp2/conf/openejb.xml
At the bottom of the file, you have section "Resource", the configuration is identical to tomee.xml (you can find documentation at this adress : documentation for configuration tomee.xml
In production:
we forget openejb.xml, a configuration is identical but in tomee.xml
to finish, here is my configuration:
persistence.xml
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="elevage" transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<jta-data-source>MyDataBase</jta-data-source>
<non-jta-data-source>MyDataBaseUnmanaged</non-jta-data-source>
<class>com.test.ejb.BeanAnimal</class>
<!-- <class>com.test.ejb.BeanUser</class>-->
<properties>
<property name="openjpa.jdbc.DBDictionary" value="mysql" />
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO" />
</properties>
</persistence-unit>
openejb.xml (in development) and tomee.xml (in production)
<Resource id="MyDataBase" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged true
</Resource>
<Resource id="MyDataBaseUnmanaged" type="DataSource">
JdbcDriver com.mysql.jdbc.Driver
JdbcUrl jdbc:mysql://localhost:3306/elevage?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney&useSSL=false
UserName root
Password pass
JtaManaged false
</Resource>
I am trying to get pool of connections using jndi lookup but have a following error: java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
My context xml placed in web/WEB-INF folder near web.xml
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" crossContext="true" reloadable="true" path="patient/account">
<Resource
name="jdbc/pharmacy"
author="Container"
type="javax.sql.DataSource"
maxActive="32"
maxIdle="8"
maxWait="10000"
username="root"
password="23810198vas"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/pharmacy" />
</Context>
Context envCtx = new InitialContext();
DataSource ds = (DataSource)envCtx.lookup("java:comp/env/jdbc/pharmacy");
Connection connection = ds.getConnection();
For Tomcat , context.xml should be under META-INF and META-INF folder should be at the same level as WEB-INF folder.
27.10.2014: I still really need help for this question.
My friend and I are trying to host a game through SmartFoxServer. He is hosting the server on his computer, and has successfully portforwarded the necessary port (9339) to his local IP. We have done everything in this guide. According to SmartFoxServer's feedback through the admin panel and the server terminal window, the hosting should be successful.
However, when trying to connect to his public IP, I get this error:
[WARN] Security Error: Error #2048: Security sandbox violation: file:
cannot load data from #IP#.
crossdomain.xml
<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" t-ports="*" secure="false" />
</cross-domain-policy>
config.xml
<ServerSetup>
<ServerIP>10.0.0.8</ServerIP>
<ServerPort>9339</ServerPort>
<AutoSendPolicyFile>true</AutoSendPolicyFile>
<MaxUserIdleTime>300</MaxUserIdleTime>
<!-- Server Variables limits (-1 = unlimited) -->
<MaxRoomVars>-1</MaxRoomVars>
<MaxUserVars>-1</MaxUserVars>
<AntiFlood active="false">
<MinMsgTime tolerance="5">1000</MinMsgTime>
<MaxRepeatedMessages>3</MaxRepeatedMessages>
<WarningsBeforeKick>2</WarningsBeforeKick>
<WarningMessage><![CDATA[No flooding allowed!)]]></WarningMessage>
<KickMessage><![CDATA[You've been warned! No flooding! Now you're kicked]]></KickMessage>
<BanMessage><![CDATA[Stop Flooding!! You're being banned]]></BanMessage>
<BanAfter timeSpan="1">3</BanAfter>
</AntiFlood>
<BadWordsFilter active="false">
<FilterMode>filter</FilterMode> <!-- REMOVE or FILTER -->
<StripCharacters><![CDATA[,.;:_!$%&/#*-+]]></StripCharacters>
<Warnings>true</Warnings>
<FilterRoomNames>true</FilterRoomNames>
<FilterUserNames>true</FilterUserNames>
<WarningsBeforeKick>3</WarningsBeforeKick>
<WarningMessage><![CDATA[No swearing!)]]></WarningMessage>
<KickMessage><![CDATA[You've been warned! No Swearing! Now you're kicked]]></KickMessage>
<BanMessage><![CDATA[Stop Swearing! You're being banned!]]></BanMessage>
<BanAfter timeSpan="1">3</BanAfter>
<BadWordsList>
<badWord>motherfucker</badWord>
<badWord>dickhead</badWord>
<badWord>asshole</badWord>
<badWord>shithead</badWord>
<badWord>shit</badWord>
<badWord>fucking</badWord>
<badWord>fuck</badWord>
<badWord>dickhead</badWord>
<badWord>bastard</badWord>
<badWord>nigger</badWord>
<badWord>idiot</badWord>
<badWord>bitch</badWord>
</BadWordsList>
</BadWordsFilter>
<BanCleaning>auto</BanCleaning>
<BanDuration>1800</BanDuration> <!-- 30 min -->
<BannedLoginMessage>You have been banned!</BannedLoginMessage>
<OutQueueThreads>1</OutQueueThreads>
<ExtHandlerThreads>1</ExtHandlerThreads>
<MaxWriterQueue>50</MaxWriterQueue>
<MaxIncomingQueue>8000</MaxIncomingQueue>
<DeadChannelsPolicy>strict</DeadChannelsPolicy>
<MaxMsgLen>4096</MaxMsgLen>
<LogMaxSize>5000000</LogMaxSize>
<LogMaxFiles>5</LogMaxFiles>
<!--
Available options are:
FINEST
FINER
FINE
CONFIG
INFO
WARNING
SEVERE
-->
<FileLoggingLevel>WARNING</FileLoggingLevel>
<ConsoleLoggingLevel>INFO</ConsoleLoggingLevel>
<AdminLogin>sfs_admin</AdminLogin>
<AdminPassword>sfs_pass</AdminPassword>
<AdminAllowedAddresses>
<AllowedAddress>*.*.*.*</AllowedAddress>
</AdminAllowedAddresses>
<IpFilter>0</IpFilter>
<!-- Enable / Disable remote zone info -->
<EnableZoneInfo>false</EnableZoneInfo>
</ServerSetup>
<!--
Zones Configuration.
-->
<Zones>
<Zone name="multiChat">
<Rooms>
<Room name="Main Lobby" maxUsers="50" isPrivate="false" isTemp="false" autoJoin="true" />
</Rooms>
</Zone>
</Zones>
Actionscript 3 / Flash File
import flash.events.SecurityErrorEvent;
import flash.system.Security;
import it.gotoandplay.smartfoxserver.*
import flash.events.MouseEvent;
connect_btn.addEventListener(MouseEvent.CLICK, initiateConnection);
function initiateConnection(evt:MouseEvent):void
{
// ip_text.test = public IP address of server host machine
// int(port_text.text) = 9339
// zone_text.text = "multiChat"
// name_text.text = "testUser"
status_text.text = "Connecting to " + ip_text.text + "...";
var policyLoad:String = "xmlsocket://" + ip_text.text + ":" + port_text.text;
Security.loadPolicyFile(policyLoad)
var smartFox:SmartFoxClient = new SmartFoxClient(true)
smartFox.addEventListener(SecurityErrorEvent.SECURITY_ERROR, sandboxHandler)
smartFox.addEventListener(SFSEvent.onConnection, onConnectionHandler)
smartFox.connect(ip_text.text, int(port_text.text))
smartFox.addEventListener(SFSEvent.onLogin, onLoginHandler)
smartFox.addEventListener(SFSEvent.onRoomListUpdate, onRoomListUpdateHandler)
smartFox.login(zone_text.text, name_text.text, "")
}
function onConnectionHandler(evt:SFSEvent):void
{
if (evt.params.success)
status_text.appendText("Connection successful \n");
else
status_text.appendText("Connection failed \n");
}
function onLoginHandler(evt:SFSEvent):void
{
if (evt.params.success)
status_text.appendText("Successfully logged in as " + evt.params.name + "\n");
else
status_text.appendText(status_text.text + "Zone login error; the following error occurred: " + evt.params.error + "\n");
}
function onRoomListUpdateHandler(evt:SFSEvent):void
{
// Dump the names of the available rooms in the "simpleChat" zone
for (var r:String in evt.params.roomList)
status_text.appendText(status_text.text + evt.params.roomList[r].getName() + "\n");
//smartFox.joinRoom(10)
}
function sandboxHandler(evt:SecurityErrorEvent):void
{
status_text.appendText("Sandbox Error / Flash Security Error Event");
}
Output:
*Attempting to launch and connect to Player using URL DIRECTORY OF FILE
[SWF] DIRECTORY OF FILE - 92561 bytes after decompression
[Sending]:
[WARN] Security Error: Error #2048: Security sandbox violation: file:DIRECTORY OF FILE cannot load data from PUBLIC HOST IP:9339.
[UnloadSWF] DIRECTORY OF FILE
Debug session terminated.
Debug session terminated.*
Change the following line:
<allow-access-from domain="*" t-ports="*"/>
to:
<allow-access-from domain="*" t-ports="*" secure="false" />
If still have some issue, you can check more details reading the official cross-domain policy documentation
Some useful URL's
SmartFoxServer configuration
SmartFox Forum
I regarded stackoverflow as one of the most reliable services in order to get help quickly, but this time I got the answer from somewhere else. I'll rewrite it here.
Maybe someone that has the same problem will consider this useful in the future.
The problem was after all quite simple. The standalone Adobe Flash Player automatically refuses such a connection. However it works when running it in a browser..
You had a typo in your policy file.
On line 4
<allow-access-from domain="*" t-ports="*" secure="false" />
Should have been
<allow-access-from domain="*" to-ports="*" secure="false" />
Note you had t-ports instead of to-ports.
Source: Cross-domain policy file specifications. https://www.adobe.com/content/dam/acom/en/devnet/articles/CrossDomain_PolicyFile_Specification.pdf#G3.344406
I'm using AS3WebSocket module to connect web sockets. It works well when I launch flash locally (flash file is marked as trusted in global settings).
But when I open server page with flash, it doesn't work. I've no error messages, just "disconnect" in log.
WinServer2012, IIS, ASP.NET MVC4
Here are logs:
ws init begin: ws://www.sample.biz/WsHandler.ashx?userId=5
Disconnected null[object WebSocket]
And code:
function SYS_wsInit_begin():void
{
writeLog("ws init begin: " + ws_init_url);
trace(ws_init_url);
try
{
websocket = new WebSocket(ws_init_url,"*");
websocket.addEventListener(WebSocketEvent.CLOSED, handleWebSocketClosed);
websocket.addEventListener(WebSocketEvent.OPEN, handleWebSocketOpen);
websocket.addEventListener(WebSocketEvent.MESSAGE, handleWebSocketMessage);
websocket.addEventListener(WebSocketErrorEvent.CONNECTION_FAIL, handleConnectionFail);
websocket.connect();
}
catch (err:Error)
{
writeLog("ws init failed: " + err.message + err.name);
}
}
function handleWebSocketClosed(event:WebSocketEvent):void
{
writeLog("Disconnected " + event.message + event.target);
trace("Disconnected");
}
function handleWebSocketOpen(event:WebSocketEvent):void
{
writeLog("Connected");
trace("Connected");
}
function handleConnectionFail(event:WebSocketErrorEvent):void
{
writeLog("Connection Failure: " + event.text);
trace("Connection Failure: " + event.text);
}
crossdomain.xml:
<?xml version="1.0" encoding="utf-8" ?>
<cross-domain-policy>
<site-control permitted-cross-domain-policies="all"/>
<allow-access-from domain="*"/>
<allow-http-request-headers-from domain="*" headers="*"/>
</cross-domain-policy>
I've also installed Socket Policy File Server with file:
<?xml version="1.0"?>
<cross-domain-policy xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd">
<site-control permitted-cross-domain-policies="*" />
<allow-access-from domain="*" to-ports="*" />
</cross-domain-policy>
What can I do?
Oh, I've resolved the problem.
After reading, http://forums.adobe.com/message/5297747 I've tried to check 843 port with fiddler, but I got only a redirection to index page.
I checked my IIS configuration. There was a binding on 843 port. After the binding was deleted and socket policy file server restarted the Web-socket connection was established!
I'm having problems with my MDB running in JBoss 5.1.2 connecting to a remote standalone HornetQ via JMS. I know the HornetQ is up and running fine as I can connect to it and place/view messages via HermesJMS. However, my actual app does not seem to be able to successfully connect to it.
Here's my #MessageDriven annotation:
#MessageDriven(
messageListenerInterface = MessageListener.class,
activationConfig = {
#ActivationConfigProperty( //type of destination we pull messages from
propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
#ActivationConfigProperty( //which destination JNDI suffix we pull message from
propertyName = "destination", propertyValue = "queue/inputQueue"),
#ActivationConfigProperty( //how many times to reattempt on service errors
propertyName = "dLQMaxResent", propertyValue = "1"),
#ActivationConfigProperty( //how many seconds to try a reconnect when failure to connect to jms provider
propertyName = "reconnectInterval", propertyValue = "15"),
#ActivationConfigProperty(
propertyName = "providerAdapterJNDI", propertyValue = "java:/RemoteJMSProvider")
}
)
Here's my configuration in my jms-ds.xml file:
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"
name="hornetq:service=MSProviderLoader,name=RemoteJMSProvider,server=remotehost">
<attribute name="ProviderName">RemoteJMSProvider</attribute>
<attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
<!-- The connection factory -->
<attribute name="FactoryRef">/LocalHornetQConnectionFactory</attribute>
<!-- The queue connection factory -->
<attribute name="QueueFactoryRef">/LocalHornetQConnectionFactory</attribute>
<!-- The topic factory -->
<attribute name="TopicFactoryRef">/LocalHornetQConnectionFactory</attribute>
<!-- Connect to JNDI on the host "the-remote-host-name" port 1099-->
<attribute name="Properties">
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=IPADDRESS:1099
</attribute> </mbean>
I can view the RemoteJMSProvider in the JBoss jmx-console. Additionally, in JNDIView, I can see the JNDI name of the Remote JMS Provider. I can also see the jms.queue.inputQueue in the JMX console, though when I attempt to view messages on it, it says there are none, even though I know there are by viewing HermesJMS.
Finally, there are no exceptions in my application. It all appears to be running fine, but it never receives any messages. Even the HornetQ logs show that my IP address has connected, so I'm not sure why I can't read off of the queues:
[RMI TCP Connection(6)-10.3.78.123] 17:02:06,837 FINER [sun.rmi.transport.tcp] RMI TCP Connection(6)-10.3.78.123: (port 1098) client using 10.3.78.123:0
Any ideas?
Here's my HornetQ (2.2.5) configuration information for reference.
hornetq-jms.xml:
<connection-factory name="LocalHornetQConnectionFactory">
<xa>true</xa>
<connectors>
<connector-ref connector-name="netty"/>
</connectors>
<entries>
<entry name="/LocalHornetQConnectionFactory"/>
</entries>
<retry-interval>5000</retry-interval>
<retry-interval-multiplier>1.0</retry-interval-multiplier>
<reconnect-attempts>-1</reconnect-attempts>
<failover-on-server-shutdown>true</failover-on-server-shutdown>
<confirmation-window-size>1048576</confirmation-window-size>
</connection-factory>
<queue name="invalidQueue">
<entry name="/queue/invalidQueue"/>
</queue>
<queue name="inputQueue">
<entry name="/queue/inputQueue"/>
</queue>
<queue name="errorQueue">
<entry name="/queue/errorQueue"/>
</queue>
<topic name="SAFEStorageAcknowledgement">
<entry name="/topic/SAFEStorageAcknowledgement"/>
</topic>
<topic name="SAFEEvents">
<entry name="/topic/SAFEEvents"/>
</topic>
hornetq-configuration.xml:
<address-settings>
<!--default for catch all-->
<address-setting match="#">
<dead-letter-address>jms.queue.errorQueue</dead-letter-address>
<expiry-address>jms.queue.errorQueue</expiry-address>
<redelivery-delay>15000</redelivery-delay>
<max-size-bytes>10485760</max-size-bytes>
<message-counter-history-day-limit>10</message-counter-history-day-limit>
<address-full-policy>BLOCK</address-full-policy>
<redistribution-delay>60000</redistribution-delay>
</address-setting>
</address-settings>
<queues>
<queue name="jms.queue.inputQueue">
<address>jms.queue.inputQueue</address>
</queue>
<queue name="jms.queue.errorQueue">
<address>jms.queue.errorQueue</address>
</queue>
<queue name="jms.queue.invalidQueue">
<address>jms.queue.invalidQueue</address>
</queue>
</queues>
All other HornetQ settings are at default.
Thanks,
Andy
You have to specify on either the ra.xml or as an annotation two activation properties:
ConnectorClassName = org.hornetq.core.remoting.impl.netty.NettyConnectorFactory
ConnectionParameters = host=127.0.0.1;port=5446
On the HornetQ distribution, there's an example called javaee/jca-remote which is using the ra.xml to configure the activation property.